Sending large packages over serial connection

26 Jan 2012

Hi there,

I've got a sensor hooked up to mbed analog inputs and want to stream the sensor output to my PC via a serial connection.

I've managed to send up to 16 bytes per package (I guess that works because the UART buffer is 16 bytes), but when I want to send more information at once things become very chaotic and I don't really understand what's going on.

On the PC I've got Java with the RxTx API running and use an event based read algorithm, which, as noted, works fine for anyting up to 16 bytes.

I've tried to just put the java read function into a loop that reads until it has received 48 bytes, but that doesn't work as I'm only getting rubbish out and it actually takes a while until 48 bytes have been transmitted which doesn't feel right.

Has anyone got experience with that? Any help would be much appreciated.

26 Jan 2012

hey Lukas, I've written a library for the mbed side anyway to send packets of upto 256bytes, its still in development meaning I add things I need for my own project which uses 3 uart's all streaming data at the same time, its stable enough I fly my quadcopter over an xbee using it, hasnt crashed on me yet (literally and in software )

Import librarySimpleSerialProtocol

A library to send and receive packets over serial, uses MODSERIAL

and if that is too much for what you need (though I love the callback system I wrote :p) you can use one of the libraries its built ontop of as a drop in replacement for Serial

Import libraryMODSERIAL

Bug fix release

that should be enough to help with the dropped bytes

Chris

27 Jan 2012

Hi Chris,

thanks, I will have a look at the library over the next few days. Looks like it could be what I'm looking for! I'll give you an update as soon as I've tried it.

Cheers.

27 Jan 2012

Really need to write some documentation for it, or at least some comments, just updated the example program so it actually works with all the recent changes ive made,

Import programSimpleSerialProtocolExample

An example Program for the SimpleSerialProtocol Library, This program will receive a packet, then echo it back to the client

anyway if you have any problems just ask, its easy to forget basic functionality most people might need but you havn't got a use for