question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Synchronous performance is slower than .NET SerialPort

See original GitHub issue

Hi, first of all, thanks for this lib, reliability is greater and CPU usage is lower, great work! However, i noticed that the performance when doing several small packets synchronously is slower than .NET default SerialPort

My setup is as follows:

  1. Program send 64 bytes to device and blocks the thread with a AutoresetEvent.WaitOne
  2. Device writes those 64 bytes to the flash memory and sends an ACK\n back to the program
  3. Program receive data on the serial using the DataReceived event, validates the ACK\n and unblocks the Thread by AutoresetEvent.Set()
  4. Repeat until done

Comparison - this is the same code, device and firmware on both cases, the only thing that’s changed is the serial port: SerialPortStream: b15009e5-d70a-4858-8171-e90d03a02ec3

.NET SerialPort net

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jcurlcommented, Dec 19, 2019

I would expect you can just include the csproj into your solution file.

1reaction
jcurlcommented, Dec 19, 2019

Assuming that you’re blocking on your own ManualResetEvent for an event to occur, you might want to block on the Read itself.

Your colleague may be getting higher rates as all read/write is just a buffer operation, and every i/o loop just looks at what is pending to read/write.

The delays you’re seeing are probably thread changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Synchronous performance is slower than .NET SerialPort
Blocking directly on the Read() is at least twice as fast, but still slower than SerialPort. My colleague's protocol is fundamentally different ...
Read more >
SerialPort.ReadLine() slow compared to manual method?
I ran into this issue in 2008 talking to GPS modules. Essentially the blocking functions are flaky and the solution is to use...
Read more >
Thread: Serial port reading is very slow
Hi Folks I have a simple synchronous function that write n bytes to the serial port and reads the same number of bytes...
Read more >
What is better - using SerialPort with or without await/async ...
I'm having an implementation using SerialPort in C# using Visual Studio 2019. I'm using it in a Windows Application, using .NET Framework ...
Read more >
If you *must* use .NET System.IO.Ports.SerialPort
The BytesToRead property (completely unreliable); The Read, ReadExisting, ReadLine methods (handle errors completely wrong, and are synchronous); The PinChanged ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found