Properly reading (mid)stream data

1 次查看(过去 30 天)
Greetings,
I'm using Simulink to develop/manage a control system. The model uses the Simulink coder, and gets deployed to a Gumstix Duovero (linux) and runs locally. I've connected a Raspberry Pi to the serial port, and will be using this method to communicate data between the two devices.
I'm currently using some addons from Quarc, and one of these is a stream server. (It's interface agnostic and can be TCP, UDP, serial, etc).
The challenge I am facing is that I'm using doubles, which are 8 bytes each. If I start up the application on the Duovero it immediately starts sending data out the serial port (and that's okay).
However, then the Raspberry Pi application starts, and it also starts reading and writing on the serial port. Since doubles are 8 bytes, it's extremely difficult to start reading midstream on both sides because you can't tell where one double ends and the next begins.
On the Pi, I believe I have a solution (still coding the test - python), which will do some trickery with reading 8 bytes sequentially from the serial port looking for a specific "start byte", and then I hope to sync up the streams.
However, I have absolutely no idea how to accomplish this in Simulink, since block itself sends the data out of its output as a specific length of data. I thought I would crafty and just send the data as ASCII (well, integers) but there is no way to actually convert a double into a string and send it over the line.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Raspberry Pi Hardware 的更多信息

产品


版本

R2014b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by