...
To test bidirectional UART messaging:
- Your computer and
Include Page |
---|
_def_mote | _def_mote | are and mote are connected over a USB cable.Your Include Page |
---|
_def_mote | _def_mote | - is Your mote is programmed with the
02_uart_raw
sample application. - Your computer runs the following:
- The
uart_raw_app.py
Python script (available in the Include Page |
---|
| _def_ocsdk_dir_src |
---|
| _def_ocsdk_dir_src |
---|
|
/app/02-uart_raw/
directory). - A terminal client to enter CLI commands for the .
...
Tip |
---|
You need to know the API and CLI serial ports corresponding to your Include Page | _def_ mote | _def_mote | . You will connect the uart_raw_app.py
Python script to the API port, and the terminal client to the CLI port.Refer to the SmartMesh IP Tools Guide for information about how to identify the different serial ports.
Overview
...
The 02-uart_raw
...
Sample Application
The 02-uart_raw
sample application defines
three one CLI
commands:- use
len
to specify the length, in bytes, of the packet the uartTxTask
task transmits. - use
delay
to specify the duration, in ms, for the uartTxTask
task to wait between two successive packets. - use
tx
to specify the number of packets to transmit, and trigger the uartTxTask
task to start transmitting.
command: tx
<num_packets> <length> <delay> - transmit num_packets
packets of length
bytes, with an interpacket delay of delay
ms.
The uart_raw_app.py
Python script connects to the API port of your Include Page |
---|
_def_mote | _def_mote | your mote. It defines a number of commands allowing you to transmit UART frames to the Include Page |
---|
_def_mote | _def_mote | the mote. It also prints the UART frames it receives. Start the uart_raw_app.py
Python script by double-clicking on its file.
Note |
---|
Before you run this application, make sure you have Python and pyserial installed on your computer. Refer to the SmartMesh IP Tools Guide for installation instructions. |
The uart_raw_app.py
Python script defines the same CLI commands are the 02-uart_raw
sample application, i.e. len
, delay
and tx
. On top of those, the uart_raw_app.py
Python script defines the connect
command to connect it to the API serial port of your Include Page |
---|
_def_mote | _def_mote | your mote.You can type help
on both the 02-uart_raw
sample application and the uart_raw_app.py
Python script to obtain the list of available commands.Type help
on the your Include Page |
---|
_def_mote | _def_mote | :
No Format |
---|
> uart_raw app, ver 1.2.0.1
SmartMeshIP stack, ver 1.4.0.5
> help
help <command>
Commands:
mtrace
mset
mget
mseti
mgeti
mxtal
mfs
mlog
mtrace
minfo
mshow
len
delay
tx
> |
Type help
in An example of the help text in the uart_rawapp.py
Python script is shown below:
No Format |
---|
uart_app OCFDK Sample application
> help
Commands:
connect <comPort>
baudrate <bps>
stopbits <stopbits>
len <numBytes>
delay <numMs>
tx <numPackets>
exit
> |
Send UART frames from the Include Page |
---|
_def_mote | _def_mote
Implementation Details
The 02-uart_raw
sample application creates two tasks:
- The
uartTxTask
task opens the UART with a default set of connection parameters used in the dn_open()
call - the rate
, stopBits
, parity
, and ibTimeout
(inter-byte timeout). When the tx CLI command is called, the task transmits a number of UART "packets" from your mote to the uart_raw_app.py
Python script, and prints them on the CLI. - The
uartRxTask
task listens for incoming UART bytes and prints them to the CLI. The uart_raw_app.py
Python script can be used to test reception. The mote uses the inter-byte timeout provided in the dn_open()
call to "frame" the incoming bytes.
First, connect the uart_raw_app.py
Python script to the API port of
your Include Page |
---|
_def_mote | _def_mote | your mote (here on COM28
).
No Format |
---|
> connect COM28
> |
On
the Include Page |
---|
_def_mote | _def_mote | the mote, type the following command to send 5 packets of 10 bytes each, with an inter-packet delay of 100 ms to the uart_raw_app.py
Python script.
> len 10
> delay uart_raw app, ver 1.2.0.1
SmartMeshIP stack, ver 1.4.1.8
Connecting to UART: Rate=115200, SB=0, Parity=0, IBT=100
> tx 5 10 100
> Sending 5 UART packets, 10 bytes, delay 100 ms
uart TX ( 5): 00 01 02 03 04 05 06 07 08 09
uart TX ( 4): 00 01 02 03 04 05 06 07 08 09
uart TX ( 3): 00 01 02 03 04 05 06 07 08 09
uart TX ( 2): 00 01 02 03 04 05 06 07 08 09
uart TX ( 1): 00 01 02 03 04 05 06 07 08 09
done. |
The following is printed by the uart_raw_app.py
Python script. Note that the uart_raw_app.py
uses the 00 as a break between packets - there is no data framing in the raw UART (other than the interpacket delay).
No Format |
---|
uart RX: 00 01 02 03 04 05 06 07 08 09
uart RX: 00 01 02 03 04 05 06 07 08 09
uart RX: 00 01 02 03 04 05 06 07 08 09
uart RX: 00 01 02 03 04 05 06 07 08 09
uart RX: 00 01 02 03 04 05 06 07 08 09 |
Receive UART frames at the
On the uart_raw_app.py
Python script, type the following command to send 5 packets of 10 bytes each, with an inter-packet delay of 100 ms to the
:len
> delay
> tx5
Sending 5 UART packets, 10 bytes, delay 100 ms
uart TX ( 5): 00 01 02 03 04 05 06 07 08 09
uart TX ( 4): 00 01 02 03 04 05 06 07 08 09
uart TX ( 3): 00 01 02 03 04 05 06 07 08 09
uart TX ( 2): 00 01 02 03 04 05 06 07 08 09
uart TX ( 1): 00 01 02 03 04 05 06 07 08 09
done.
> |
The following is printed at the
: No Format |
---|
uart RX (10 bytes) 00 01 02 03 04 05 06 07 08 09
uart RX (10 bytes) 00 01 02 03 04 05 06 07 08 09
uart RX (10 bytes) 00 01 02 03 04 05 06 07 08 09
uart RX (10 bytes) 00 01 02 03 04 05 06 07 08 09
uart RX (10 bytes) 00 01 02 03 04 05 06 07 08 09 |
The mote uses the inter-byte timeout provided in the dn_open()
call to "frame" the incoming bytes.