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.
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.
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.
[Code]
public static void Main()
{
OutputPort led = new OutputPort((Cpu.Pin)69, true);
SerialPort sp = new SerialPort(“COM1”, 250000, Parity.None, 8, StopBits.Two);
sp.Open();
// write the data and close the file
byte[] data = new byte[513];
Stopwatch sw = Stopwatch.StartNew();