I need to access to a COM port to receive data from a input system. For this, I tried many things. I’ve tried SerialPort.ReadLine that doesn’t function to me and stuck me unity in this instruction. Moreover, I’ve tried to create a Separate Thread with a simple ReadByte (that function to me, but data arriving to fast and it takes disordered data). In separate thread nothing is read and I don’t understand why. I read that separate threads can’t access to unity API but SerialPort is not part of unity API or not? Moreover, I tried to use SerialPort BeginRead and EndRead with Asyncronous call but Unity remain blocked on the BeginRead call despite it is async.
Have you any other idea? How I can do to solve my problem?
Solved using a secondary Thread with a locked variable on a ActionQueue. On each frame in the update method I see if there are some action that the main thread has to invoke for completing this frame. This solves posted problems, if someone else have the same problem like me.