Step 3: Adding Comms

This step corresponds to test_stg_lib_3. Procedures of interest are comms_init() and comms_proc_cmd(). Both are in device.tbs.

New stuff

OK, now comms. We use terminal software, for example, our own I/O Ninja software ( to send commands and receive replies. The "IP" setting defines the IP address of the device, while the "PN" setting specifies the port number on the device side. Setting initialization will cause these settings to have default values of and 1000, as specified through the setting configurator.

Writing and Reading Settings already explained the difference between the usage of stg_get()/stg_set() and stg_sg(). Here is a practical illustration: comms_init() uses "simplified" stg_get(). With this, there is no need to check the execution result each time we need to read a setting — should there be any problem, callback_stg_error() will be called and we respond to the error there.

Comms_proc_cmd(), on the contrary, needs to respond to each command with a meaningful status code. This is why it relies on stg_sg(), which returns the status code directly.

There are two commands: "S" (set setting) and "G" (get setting). Both commands should end with the CR (shown as <CR> below).

Set command format is S setting_name , index , setting_value. The command returns the execution result, which is expressed by a single character (see below).

Get command format is G setting_name , index. The command returns the execution result. If execution was successful, setting value is also returned.

Execution result codes are: A for OK, C for when the setting name is unknown or the index is invalid, F when there was some sort of failure, I when the setting value is invalid, and U for "weird internal errors".

The result

Here is a sample printout from I/O Ninja, we write and read one of the "PTN" setting's members. We set this member to "R-G-B-" and then read this value back:

** Tibbo Basic **

Established TCP connection with from 3790