Cerberus Bee Serial Send Speed

I am trying to send an array of bytes from a file every 50ms and am finding the performance numbers lower than I would expect.


  SerialPort sp = new SerialPort("COM2", 1000000, Parity.None, 8, StopBits.Two);
  sp.Open();
  read_count = FileHandle.Read(data, 0, 2048);
  sw.Start();
  sp.Write(data, 0, 2048);
  sw.Stop();

sw is a stopwatch that calculates time in milliseconds. When I run this, it takes about 145ms to send the data. I am running using Ctrl-F5 (without debugging.) If I decrease the number of bytes send, the time goes down. Given the baud rate set to 1,000,000 , I would expect this to be faster.

Would a board like the Hydra perform faster? Any suggestions? Thank you.

Not an answer, I know, but is two stop bits a deal breaker? Might be hitting something weird/special there. What is the receiver, an xbee? A TTL uart? Perhaps there’s also a buffering issue.

Thanks Brett for the reply. I tried removing the two bit stop and had the same issue. I also tried setting the baud rate down to 500,000 and my test yeilds the same amount of time. So, I think I am hitting some limitation. I wonder if other boards have the same issue. I have been looking at the Hydra but want to make sure it passes this test first.

Running this code:

var sp  = new SerialPort("COM2", 500000, Parity.None, 8, StopBits.Two);
var data = new byte[2048];

sp.Open();

var start = DateTime.Now.Ticks;
sp.Write(data, 0, data.Length);
var end = DateTime.Now.Ticks;

Debug.Print(string.Concat("took ", (end - start) / TimeSpan.TicksPerMillisecond, " ms."));

I get this output (on a Cerb40, not the most recent firmware):

[em]took 35 ms.[/em]

Using a baud rate of 1,000,000 it takes 18ms.

Thanks for your help. I had an issue with setting the thread priority too low.