Timeouts in C# serial port -
i using c#
serial port library communicating sensor , pc . getting timeouts serialport.read()
method though there info in there. used serial sniffers check receiving packet @ port how .net not pick of them , times out. reading bytes , bytes receiving 2112 less serial port buffer size. tried multiple things , thinking of using native c/c++
, calling in c#
. can share more thoughts or used native c/c++
code in c#
.
running @ baud rates 460800 921600
those pretty unusual baud rates, rather high. not using datareceived event gets rather critical how phone call read() method. take time off doing else, including windows thinking more of import needs done , context-switches away thread, , receive buffer overflow. not implementing serialport.errorreceived event standard error don't see overflows, see missing data.
writing code in c++ unlikely bring relieve. there's 1 api serial ports, serialport lean wrapper , uses winapi functions c++ code would.
so take of next steps:
implement errorreceived event know overflows occur favor using datareceived event don't depend on calling read() enough set readbuffersize nice big number driver can take slack set handshake property driver can tell device stop sending when buffer full check if can implement protocol device doesn't fire-hose machine lower baud rate if still isn't reliable enough. c# c visual-c++ timeout serial-port
No comments:
Post a Comment