DashReadEvalPrint is a Dash program that provides an interactive console for testing and debugging Dash features. Instead of continuously re-programming the Dash to try different functionality, you can send commands and receive output via the USB serial interface. This is similar to the read-eval-print loop (REPL) consoles for dynamic languages like Python and Ruby.

Programming the Dash

If you haven't already, set up the Arduino software with Hologram's boards as described in the Programming and Firmware guide.

Make sure you have the latest version of the library by opening the Boards Manager (Tools -> Board -> Boards Manager) and selecting Updateable from the Type dropdown. If Hologram Dash appears in the list of updateable boards, update to the latest version.

Then, open the Dash REPL sketch by selecting: File -> Examples -> DashReadEvalPrint -> dashreplbasic You can also find the source on GitHub.

Connect the Dash to your computer with a USB cable. In the menu bar go to Tools -> Port and select the appropriate serial or USB port. Typically the ports are named as follows according to your operating system:

  • Windows: COMx
  • MacOS: /dev/cu.usbmodemxxxx
  • Linux: /dev/ttyUSBx or /dev/ttyACMx

where x is a system-specific identifier. If you are still unsure of which port to use, disconnect the Dash and check which port disappears from the list. Then re-connect the Dash and select that port.

If you're on Windows 8.1 or earlier and no port shows up when plugging in the Dash, see our Windows guide for driver installation instructions.

Press the PROG (program) button on the Dash, and upload the dash_repl_basic sketch by clicking the Upload button in the Arduino SDK.

Nova Block Diagram

Using the REPL

The dash_repl_basic program reads input and displays output on the USB serial interface. The easiest way to talk to the Dash over serial is with the Arduino IDE's Serial Monitor:

Nova Block Diagram

At the top of the Serial Monitor is an input box for sending text to the Dash. Under that is a larger box which displays text received from the Dash. At the bottom of the window are settings for the serial connection. Configure the dropdown boxes as follows:

  • Line ending: Newline
  • Baud rate: 9600 baud

Note: You can communicate with the Dash using any terminal emulator that supports serial connections. See the Serial guide for some alternatives to the Arduino software.

Then you're ready to enter commands in the REPL. Type 'help' and click Send. The Dash will return a list of all the commands it supports:

Nova Block Diagram

After printing the usage information, the Dash prints a command prompt:

bash Dash>

This indicates that it's ready to receive another command.

The REPL implements commands for most of the Dash API. If you want to see the code that gets executed for a given command, look at the source code for the DashReadEvalPrint library.

SMS debugging

The REPL program will print info about any received SMS messages to the serial console. It will also send a message to the Hologram Cloud with the sender's phone number.

For example, if you send an SMS from the Hologram Dashboard with content "Hello Dash!" and from number +13125554010, the program prints the following to the serial console:

CLOUD SMS RECEIVED:
SMS SENDER: +13125554010
SMS TIMESTAMP: 2017/03/07,22:38:07
SMS TEXT:
Hello Dash!
SMS received message sent to cloud.

The corresponding cloud message will be:

Nova Block Diagram

Examples

Run the help command in the Dash REPL to see the complete list of supported commands. This section illustrates a handful of useful commands and their expected output.

The text after the Dash> prompt is the command, and the following lines are the output from the Dash.

Cloud messaging

Send a message to the Hologram Cloud with payload Hello Hologram! and topic REPL_MESSAGE:

bash Dash> cloud send "Hello Hologram!" REPL_MESSAGE
Sending message... Complete

Adding topics is optional; the Data Engine will always add certain system-provided topics.

If your message includes double quotes, you must escape them:

bash Dash> cloud send "{"sensor": "temperature", "value": 24.5}"
Sending message... Complete

LED

Turn on the user LED:

bash Dash>led on
led on

Or turn it off:

bash Dash>led off
led off

Flash the LED on for 100ms, off for 1900ms:

bash Dash>led pulse 100 1900
led pulse 100ms/1900ms

Clock

Print the current system time:

bash Dash>clock
1970/01/01,00:19:57

Set the system time from the cellular network:

bash Dash>clock sync
2017/03/06,14:20:12