Home > Net >  A serial port receives the data often an error
A serial port receives the data often an error

Time:11-22

I use NMODBUS via a serial port every 500 ms read under a machine data, the second machine every 30 s sends a heartbeat packets, by monitoring. Method DataReceived events to read a heartbeat packet data to determine whether a machine online, found that method DataReceived triggering event can and NMODBUS rob data, causing a serial port error, ask how to deal with?

CodePudding user response:

Even package, try to disconnect the two packages, one package data of head and tail, such a received packet is complete, also have a check,

CodePudding user response:

NMODBUS using API, send and receive one and indivisible, API thread to read data on yourself, a serial port. Method DataReceived event sometimes really grab bag, cause NMODBUS read less than complete data, and to send data, my idea is how to make a serial port only reads need heartbeat packets, thank you,
  •  Tags:  
  • C#
  • Related