for carriage return, [image_count] for variables, etc.)
and click on Send Now. The text will be parsed and sent to the serial device and the response will then
appear in the console log. Note that this is different from the send sequence which will be sent each time
the serial module is encountered in the processing pipeline. The Send Now button is a manual testing
mechanism meant for debugging purposes. Also note that the returned text will be parsed by the
Receive Sequence so that you can test your parsing code and see if the variables have been created.
Use the Watch Variables module to see those variables being created.
9. Refresh Rate - to slow the scrolling of the numbers select a different refresh rate for the console. This will just slow down
how quickly RoboRealm reads information from the device.
10. Initialization Sequence - The initialization data sequence sends the provided string to the serial device
on initialization of communication. You may want to use
this to command the receiving device into a specific mode ready for communication with RoboRealm. This initialization
sequence is sent each time the serial communication is reset. This happens when you click on the "Stop" button in
this interface, change one of the above parameters (Baud, Port, etc) or when the RoboRealm starts running for the
first time. It is NOT sent when the Run button in the main RoboRealm interface is toggled.
11. Send sequence - Used to enter commands sent per pipeline loop (i.e. image processed) by RoboRealm. You can
use this sequence to transmit variables created by other RoboRealm modules to the
serial device. Each time an image is captured and processed the serial module will
interpret the Send Sequence text and send the result to the serial device.
12. Enable - Allows you to temporarily disable sending text to the serial device while performing
edits. Note that the Send Sequence textarea will turn red to indicate this setting.
13. Send Rate - Some serial devices cannot handle data streams even given a slower baud rate. Use this
dropdown to select how quickly you want the data to be sent. At AFAP (As Fast As Possible) the data
will be sent out about 30 times a second (this assumes a camera running at 30 fps).
14. Send only on change - If your data does need to be sent out to your serial device every iteration
through the processing pipeline loop this selection will prevent the same data from being sent to the
serial device that was last sent. This is also an elegant way to reduce the data bandwidth to the
device if your sequence does not change rapidly.
15. Receive sequence - used to receive and parse text send from the serial device. The
text string is matched against the incoming serial bytes. When a match is found
variables are added into RoboRealm for use in other modules. Reading into variables just
requires adding in a variable at the appropriate spot within the receive string similar to the
scanf routine in C/C++. The Receive sequence works similar to an expect string, i.e. you need to
specify patterns that match the incoming text and substitute the areas that need to be
fed into variables with the [ variable_nane ] format. Note that even if you are missing
one space or newline the patter will not match and the variable will be zero or blank.
Example
To read digital inputs from a VEX Robotics System robot over the serial port you can configure the settings to port COM5, baud 115200, 8 data bits,
no parity, 1 stop bit with the sequences as:
Initialization Sequence
\x0f\x0f\x08\x40\xb8\x04
Send Sequence
\xaa\x55\x00\x00\x00\x0B\x00\x00
Receive Sequence
DIN [din1] [din2] [din3] [din4] [din5] [din6]<lf>
which would command the Vex in the online mode (be sure to download that code to your
Vex robot) and read in the digital inputs into variables din1, din2, din3, etc. You can add
the Watch Variables module to see these variables change when you press
a bump switch on the Vex.
Note that the Vex online mode needs to be downloaded prior to using this serial sequence. Be sure
your Vex is reacting to the online interface provided by Vex to ensure correct online operation.
To receive data from a serial device that transmits binary data back to the PC (as apposed to the
ASCII mode sent by the Vex) you would use something like
\[binary_input_1]:\[binary_input_2]
which would read binary numbers delimited by ':' and ended with \r into the two variables (\1024:\667\n) but
[ascii_input_1]:[ascii_input_2]
would read in two ASCII numbers into the two variables (1024:667\n).
For ARRAYS such as CIRCLES generated by the Circle shape finder the format of the data will include as
the first number the size of the array. For example in the send sequence if you use:
[CIRCLES]
the text sent will be something like:
65,173,154,20,1499,255,255,255,271,15,15,255,255,255,204,203,20,1499,255,255 ...
where 65 is the total number of numbers (not all are included in this example) of the array. Note that
the size should always be 65 mod 13 = 0.
For binary data if you use
\\[CIRCLES]
the data sent will be something like:
\65\0\0\0\173\0\0\0\154\0\0\0\20\0\0\0\219\5\0\0\255\0\0\0 ...
Note that all numbers are 4 bytes long (due to the double \\ usage) with least significant byte first.
You can also send images to the serial device as RGB triplet or a single gray (green value) of the
current image. You do this by inserting
<rgb_image>
into the send text stream. That command will be replaced with the current image. Note that you may
want to include the image dimensions before sending the image unless you always expect an exact size.
See Also
SSC
Parallax
For more information
CodeGuru: Serial Communications in Windows
The Code Project: Serial library for C++