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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Run on Target Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!