SerialPort.Write The semaphore timeout period has expired

983 views Asked by At

I'm working on a project where I control a large number of RGB led strips with Teensy Arduino boards. I've tested it with a subset of the boards and everything seems to be fine until I connect them all and start sending my Byte arrays to the SerialPort. As a basis I'm using the OctoWS2811 library in the teensy firmware to address the LEDs (https://www.pjrc.com/teensy/td_libs_OctoWS2811.html). And send my byte array data using a C# application.

I've been testing with 2 usb hubs each having 6 Teensy boards. Separately, everything seems to be functional. But as soon as I connect both USB hubs. I keep getting Semaphore timeout exception

System.IO.IOException: The semaphore timeout period has expired.
    at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
    at System.IO.Ports.SerialStream.EndWrite(IAsyncResult asyncResult)
    at System.IO.Ports.SerialStream.Write(Byte[] array, Int32 offset, Int32 count, Int32 timeout)
    at System.IO.Ports.SerialPort.Write(Byte[] buffer, Int32 offset, Int32 count)

At first glance I seem to be able to send a couple of frames successful after it starts throwing these semaphore exceptions on a couple of the Teensy's.

Any advice on what I could try to prevent this.

It seems like reducing the size of the byte array that's being sent to the Teensy's improves the reliability a but, but not by a lot. So this could only be a coincidence.

It does also seem that a couple of frames do manage to be sent, but after a short while everything starts falling apart.

Thank you in advance for your help.

Kind regards

0

There are 0 answers