Spark.IO-CLI-UpdateRemotely

De MCHobby - Wiki
Révision datée du 21 décembre 2014 à 19:24 par Admin (discussion | contributions) (Page créée avec « {{Spark.IO-CLI-NAV}} {{traduction}} {{bloc-etroit|text=You can write whole apps and flash them remotely from the command line just as you would from the build IDE. Let's wr... »)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

You can write whole apps and flash them remotely from the command line just as you would from the build IDE. Let's write a small blink sketch to try it out.

Copy and paste the following program into a file called blinky.ino

#Copy me to blinky.ino
#define PIN D7
int state = 0;

void setup() {
    //tell the core we want to write to this pin
    pinMode(PIN, OUTPUT);
}
void loop() {
    //alternate the PIN between high and low
    digitalWrite(PIN, (state) ? HIGH : LOW);

    //invert the state
    state = !state;

    //wait half a second
    delay(500);
}

Then let's compile that program to make sure it's valid code. The CLI will automatically download the compiled binary of your program if everything went well, and show you the url. The server will also keep a copy of your binary around for you for about 24 hours.

# how to compile a program without flashing to your core
$ spark compile blinky.ino
Including:
blinky.ino
attempting to compile firmware
pushing file: blinky.ino
grabbing binary from: https://api.spark.io/v1/binaries/01234567890ABCDEFGH
saved firmware to firmware_123456781234.bin
Compiled firmware downloaded.

Now that we have a valid program, let's flash it to our core! We can use either the source code again, or we can send our binary.

# how to flash a program to your core (from source code)
$ spark flash my_core_name blinky.ino

OR - how to flash a pre-compiled binary to your core

$ spark flash my_core_name firmware_123456781234.bin
Including:
firmware_123456781234.bin
attempting to flash firmware to your core my_core_name
flash core said  {"id":"01234567890ABCDEFGH","status":"Update started"}

Source: Spark CLI (command line interface) créé par Spark.IO.

Traduction réalisée et augmentée par Meurisse D pour MCHobby.be - Translated and upsized by Meurisse D. for MCHobby.be

Traduit avec l'autorisation de Spark.IO - Translated with the permission from Spark.IO - Spark.IO

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.