jcurl / RJCP.DLL.SerialPortStream

SerialPortStream is an independent implementation of System.IO.Ports.SerialPort and SerialStream for better reliability and maintainability. Default branch is 2.x and now has support for Mono with help of a C library.
Microsoft Public License
614 stars 196 forks source link

Caching of the modem status #113

Closed galdenny closed 3 years ago

galdenny commented 3 years ago

I am considering to move to this implementation of the serial port in my project. For a specific port I need to check the modem status every 50 ms and evaluate the CTS, DSR, RING and CD/RLSD values. Till now I have a custom c++ dll, that solves my problem, but any time I want to communicate over this port I need to close that and switch back to the normal SerialPort from .Net. I was very happy to see that SerialPortStream can deliver all the signals I described above. The only thing is, that the modem status will be asked every time for those. Given the frequency of the checks, it adds an overhead about 2-3% CPU with my i7. So I was asking, if it would be possible to cache the value of the modem status for a short time, or propagate it to the "surface" so all those signals could be evaluated by only one query.

Thank you in advance.

jcurl commented 3 years ago

No caching is done. If you request it, it goes directly to the underlying Operating System and returns the result. The library makes no assumptions about why you would to poll and at what interval.