SerialFlow allows to send and receive packaged arrays of integer values via serial port.
SerialFlow allows to send and receive packaged arrays of integer(short only) values via serial port.
Packet format:
- begin - 0x12
- end - 0x13
- value separator - 0x10
- escape - 0x7D
Simple packet example:
0x12,0x1,0x0,0x10,0x7D,0x12,0x0,0x13
corresponds to: [1,18]
Now handles only short int values. Example:
#include "mbed.h" #include "SerialFlow.h" SerialFlow pc(USBTX, USBRX); AnalogIn gyro_x(p17); // data from gyro x axis AnalogIn gyro_y(p18); // data from gyro y axis int main(){ // two short values pc.setPacketFormat(SerialFlow::COMPLEX_1, 2, 2); while(1){ pc.setPacketValue((short)(gyro_x*1023.0)); pc.setPacketValue((short)(gyro_y*1023.0)); pc.sendPacket(); wait(0.01); } }
On the PC side you can use this program to catch data flows: http://www.poprobot.ru/files/sfmonitor_0.9.zip
Changes
Revision | Date | Who | Commit message |
---|---|---|---|
4:ebf658b28c5f | 2012-10-21 | Decimus | USE_MODSERIAL flag is on by default |
3:7cbfd422c98e | 2012-10-21 | Decimus | Optional MODSERIAL support with default 32byte buffer. It's needed to send more then 5 short-type values. |
2:7868220b4fdf | 2012-09-17 | Decimus | Method "baud" |
1:5f80d8d44549 | 2012-09-11 | Decimus | New methods receivePacket and getPacket |
0:3bc176d9a274 | 2012-09-09 | Decimus | Ability to send several short integer values |