Spark.IO-CLI-CommandReference

De MCHobby - Wiki
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.

Introduction

Bien que nous ayons traduit cette référence dans sa presque intégralité, vous trouverez ce document en version anglaise de CLI command reference sur le site de Spark.

Login & Wifi

spark setup wifi

Un raccourcis bien pratique pour ajouter un autre réseau wifi sur un Core connecté via USB. Assurez-vous d'avoir connecté votre Core via un câble USB et qu'il clignote lentement en bleu (en mode "listening")

# Comment mettre la config WiFi à jour.
# Assurez-vous dabord que votre Core soit connecté et en mode listening
$ spark setup wifi

spark login

Faire un Login et stocker l'ACCESS_TOKEN pour utiliser votre compte Spark pour interagir sur Spark Cloud.

# Comment se logger - créer et sauver l'access token pour votre session avec le CLI
$ spark login

spark logout

Se déconnecter (logout) du compte spark cloud et révoke l'access token de votre session CLI.

# Comment retirer l'access token stocké dans la session du cli
$ spark logout

Gestion des Cores

spark list

Generates a list of what cores you own, and displays information about their status, including what variables and functions are available

# how to show what cores of yours are online
# and what functions and variables are available
$ spark list

Checking with the cloud...
Retrieving cores... (this might take a few seconds)
my_core_name (0123456789ABCDEFGHI) 0 variables, and 4 functions
  Functions:
    int digitalWrite(string)
    int digitalRead(string)
    int analogWrite(string)
    int analogRead(string)

spark core add

Adds a new core to your account

# how to add a new core to your account
$ spark cloud claim 0123456789ABCDEFGHI
Claiming core 0123456789ABCDEFGHI
Successfully claimed core 0123456789ABCDEFGHI

spark core rename

Assigns a new name to a core you've claimed

# how to change the name of your core
$ spark core rename 0123456789ABCDEFGHI "pirate frosting"

spark core remove

Removes a core from your account so someone else can claim it.

# how to remove a core from your account
$ spark core remove 0123456789ABCDEFGHI
Are you sure?  Please Type yes to continue: yes
releasing core 0123456789ABCDEFGHI
server said  { ok: true }
Okay!

Flasher

Sends a firmware binary, a source file, or a directory of source files, or a known app to your core.

Flashing a directory

You can setup a directory of source files and libraries for your project, and the CLI will use those when compiling remotely. You can also create spark.include and / or a spark.ignore file in that directory that will tell the CLI specifically which files to use or ignore.

# how to compile and flash a directory of source code to your core
$ spark flash 0123456789ABCDEFGHI my_project

Flashing one or more source files

# how to compile and flash a list of source files to your core
$ spark flash 0123456789ABCDEFGHI app.ino library1.cpp library1.h

Flashing a known app

Two pre-built apps are included with the CLI to help you get back on track. Tinker, and the CC3000 patching app. You can flash these both over the cloud or locally via USB and dfu-util through the CLI.

# how to flash a "known app" like tinker, or the cc3000 patcher to your core
$ spark flash 0123456789ABCDEFGHI tinker
$ spark flash 0123456789ABCDEFGHI cc3000

# how to flash if your core is blinking yellow and connected over usb
# requires dfu-util
$ spark flash --usb tinker
$ spark flash --usb cc3000

Compiling remotely and Flashing locally

To work locally, but use the cloud compiler, simply use the compile command, and then the local flash command after. Make sure you connect your core via USB and place it into mode dfu (anglais, spark).

# how to compile a directory of source code and tell the CLI where to save the results
$ spark compile my_project_folder --saveTo firmware.bin
OR
# how to compile a list of source files
$ spark compile app.ino library1.cpp library1.h --saveTo firmware.bin

# how to flash a pre-compiled binary over usb to your core
# make sure your core is flashing yellow and connected via USB
# requires dfu-util to be installed
$ spark flash --usb firmware.bin

Compiler

Compiles one or more source file, or a directory of source files, and downloads a firmware binary.

compiling a directory

You can setup a directory of source files and libraries for your project, and the CLI will use those when compiling remotely. You can also create spark.include and / or a spark.ignore file in that directory that will tell the CLI specifically which files to use or ignore. Those files are just plain text with one line per filename

# how to compile a directory of source code
$ spark compile my_project_folder

example spark.include

The spark.include and spark.ignore files are just regular text files with one filename per line. If your directory has one of these files, the CLI will use it to try and determine what to include or ignore when compiling your app.

# spark.include
application.cpp
library1.h
library1.cpp

example spark.ignore

# spark.ignore
.ds_store
logo.png
old_version.cpp

Compiling one or more source files

# how to compile a list of source files
$ spark compile app.ino library1.cpp library1.h

Appels

spark call

Calls a function on one of your cores, use spark list to see which cores are online, and what functions are available.

# how to call a function on your core
$ spark call 0123456789ABCDEFGHI digitalWrite "D7,HIGH"
1

spark get

Retrieves a variable value from one of your cores, use spark list to see which cores are online, and what variables are available.

# how to get a variable value from a core
$ spark get 0123456789ABCDEFGHI temperature
72.1

spark monitor

Pulls the value of a variable at a set interval, and optionally display a timestamp
  • Minimum delay for now is 500 (there is a check anyway if you keyed anything less)
  • hitting CTRL + C in the console will exit the monitoring
# how to poll for a variable value from one or more cores continuously
$ spark monitor 0123456789ABCDEFGHI temperature 5000
$ spark monitor 0123456789ABCDEFGHI temperature 5000 --time
$ spark monitor all temperature 5000
$ spark monitor all temperature 5000 --time
$ spark monitor all temperature 5000 --time > my_temperatures.csv

Outils

spark identify

Retrieves your core id when the core is connected via USB and in listening mode (flashing blue).

# helps get your core id via usb and serial
# make sure your core is connected and blinking blue
$ spark identify
$ spark identify 1
$ spark identify COM3
$ spark identify /dev/cu.usbmodem12345

$ spark identify
0123456789ABCDEFGHI

spark subscribe

Subscribes to published events on the cloud, and pipes them to the console. Special core name "mine" will subscribe to events from just your cores.

# opens a connection to the API so you can stream events coming from your cores
$ spark subscribe
$ spark subscribe mine
$ spark subscribe eventName
$ spark subscribe eventName mine
$ spark subscribe eventName CoreName
$ spark subscribe eventName 0123456789ABCDEFGHI

spark serial list

Shows currently connected Spark Core's acting as serial devices over USB

# shows a list of cores connected via serial usb
$ spark serial list

spark serial monitor

Starts listening to the specified serial device, and echoes to the terminal

# opens a read-only serial monitor for a particular core
$ spark serial monitor
$ spark serial monitor 1
$ spark serial monitor COM3
$ spark serial monitor /dev/cu.usbmodem12345

spark keys (xxx)

CLI intègre plusieurs utilitaires de gestion des clés.

Les différents fonctions à votre disposition sont:

  • spark keys doctor
  • spark keys new
  • spark keys load
  • spark keys save
  • spark keys send
  • spark keys server

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.