Search code examples
c#multithreadingserial-portmodbus

multi thread serial ports


I am trying to multi thread in serial ports. Say that I have X serial port. Each port has Y devices(modbus).I am taking out data from each device. To take out data from the device I need to send a message, then wait for the respond. I would like to speed up the application, that is why I would like to multi thread in it.

Is it possible to send and wait for multiple messages in one serial port?

Regards
Daniel


Solution

  • No, it's not. The serial port doesn't orgainze the data in such a way. It just takes bytes in and allows you to take bytes out in a sequential manner. Attempting what you're asking will not work. You'll get garbled serial port data, if not outright errors. There's just no way to say "These bytes belong to that message".

    Sorry, that's just the basic design of how they work.