Using the Command Line Interface (CLI)

A project log for HEXABITZ - Modular Electronics for REAL

A new kind of electronic prototyping!

HexabitzHexabitz 04/03/2018 at 03:460 Comments


Use your favorite serial terminal emulator tool to access the serial COM port of your computer and thus Hexabitz CLI via a USB-to-UART cable. Some examples include RealTerm, Putty, HyperTerminal and SecureCRT. The configurations displayed here are for RealTerm but they are similar to those in other terminal emulators.
If you use standard FTDI USB-UART 3.3V cable for power and communication, connect the colored cable wires as follows:

RealTerm Configurations

In RealTerm Display tab, select Ansi as data display mode. This mode allows you to use the BACKSPACE key to delete previous characters. Optionally, enable Scrollback and increase number of Rows to a suitable number (e.g., 32).
In the Port tab, select 921600 baudrate and open the appropriate COM port. The port will only show up after you power the module and usually it will have \VCP (virtual COM port) in its name.

Once you open the port, press the ENTER keyboard key to start the communication session. You should see the CLI welcome message shown below. It tells you the ID of the module you are connected to and through which array port. Note if the module is native, i.e., not part of an array via a fixed or explored topology, it will show up as ID = 0 (unless you change default ID in the code).

Setting up Baudrate

Default baudrate for all array ports is 921600. You can change this rate with the following methods:

  1. Connect P1 TXD and RXD together momentarily while power-cycling the module. This will setup all array ports to 115200. Once you connect to a CLI port, other messaging ports restore their default baudrate. Note that the CLI will restore its default baudrate on the next power cycle.
  2. Change the value of BOS.clibaudrate parameter in the CLI using set Command. This will save the value to the emulated EEPROM so that you can use the new baudrate each time. You need to reset the module to apply the new baudrate. Note that similar to method 1, the new baudrate will apply to all ports until you connect to the CLI.
  3. Change the value of BOS.clibaudrate parameter in the code and call this API UpdateBaudrate(port, baudrate) to apply the new baudrate to a given port. You can also save it to EEPROM using this code (It will be loaded automatically from EEPROM on each startup):
EE_WriteVariable(VirtAddVarTab[_EE_CLIBaud], (uint16_t)BOS.clibaudrate);
EE_WriteVariable(VirtAddVarTab[_EE_CLIBaud+1], (uint16_t)(BOS.clibaudrate>>16));

If you want to restore the default CLI baudrate, you can either:

memcpy(&BOS, &BOS_default, sizeof(BOS_default));

General Usage Tips

module.Command parameter1 parameter2 parameter3

where module is module ID or name. Some examples:
#0.on 100
>name john
Module 0 is named john

[Press ENTER to execute the previous command again]
>name bob
Module 0 is named bob

[Press ENTER to execute the previous command again] 
Hi from module 0 (bob)

[Press ENTER to execute the previous command again]
Hi from module 0 (bob)

[Press ENTER to execute the previous command again]