modelica-3rdparty/Modelica_DeviceDrivers

A difficulty about serial port communication (this is not a bug report)

max-privato opened this issue · 1 comments

The Modelica_DeviceDrivers library contains an example in which packets are sent and received through serial port: TestSerialPackager_SerialPort.

I've used that technique rather successfully to communicate from a LabView application towards a PC containing a tool (either OpenModelica or Dymola) simulating a Modelica model.

Unfortunately, frequently I have alignment troubles: I must receive a four-number packet (t, u, I, q) but occasionally receive (u, I, q, t) or (I, q, t, u), etc. When this occurs at the beginning of a run, it continues throughout the run. That means that the issue comes from how I start the whole thing.
So I suppose this happens because some data were left from the previous run on the sending serial port, or that when I start the two programs, in the beginning, there could be some lost byte somewhere before the two applications send and receive regularly.

I thought that I could, at the beginning of a transmission, send from LabView a special sequence of numbers, and make the Modelica application discard everything up to (including) that sequence. This should allow good synchronization... but I don't know how to implement this using Modelica_DeviceDrivers!

Is there a way to implement this packet alignment, either using the previous idea or any other technique?
Or I must abandon the serial port towards UDP or TCP?

I tank anyone wanting to comment on this.

aha!
I've solved using a different task to purge bytes before starting listening.
So, I'm going to close this.