Main Site Documentation

Panda II Serial Write Speed


I am writing 512 bytes to the Panda UART port on COM1 and am finding it takes ~40 ms to send. I created a stopwatch and start before the write call and stop on the following line.

 sp.Write(data, 0, data.Length);

Is this expected? Is this dependent on the CPU clock speed? I want to send 512 bytes every 50ms. I am trying to determine if performance on the Panda will be an issue. Thanks.


Baud rate?


SerialPort sp = new SerialPort("COM1", 250000, Parity.None, 8, StopBits.Two);

250,000 is required by the protocol I am using.

I have another thread running which I know is consuming resources, but the sp.write call is taking longer to complete than I expected. I am trying to determine if I am CPU bound or not. I tried increasing the thread priority, but didn’t see much of a difference.


You might want to use RLP if you need strict timing. See RS485 driver on codeshare.


Thank you. I will check the sample out.


Make a simple program which just does the serial send, and measure the time. This will help to determine if
there is an interaction happening with other threads in your program.


I ran the following code and it takes about 23ms to complete. So it appears the sp.Write call is synchronous and not asynchronous. If I increase the baud rate or decrease the bytes sent, the time goes down.

public static void Main()


OutputPort led = new OutputPort((Cpu.Pin)69, true);
SerialPort sp = new SerialPort(“COM1”, 250000, Parity.None, 8, StopBits.Two);

// write the data and close the file

byte[] data = new byte[513];
Stopwatch sw = Stopwatch.StartNew();

for (int x = 0; x < (1000); x++)


data[0] = 0;

sp.Write(data, 0, data.Length);

Debug.Print("Time: " + sw.ElapsedMilliseconds);




@ Mickpat -

the data rate you measured is about 223000 per second.

the synchronous part may be due to the size of the internal transmit buffer.

I think the test showed your original problem was not serial sent speed.