Home > Back-end >  Use readfile can realize kept reading serial port?
Use readfile can realize kept reading serial port?

Time:09-17

Equipment up a machine has a serial port data, I use a thread to read cycle, but the use of readfile is often read buffer is too big, there are other ways???

CodePudding user response:

Write their own a little trouble, can consider similar Victor control that would be much simpler,

CodePudding user response:

reference 1st floor ZHGWBZHD response:
write their own a little trouble, can be considered similar to Victor control that would be much simpler,
ok I try thanks

CodePudding user response:

Too much buffer is what mean? Readfile execution failed? If so, you can build a buffer, a bit bigger, each read come in later, just in a buffer, and then to deal with buffer, the data from serial port threads only responsible for the data read into the buffer, in addition to open a data processing threads, constantly dealing with the data line, don't read the data from serial port handling over again to read, so, large amount of data is too late

CodePudding user response:

The system with SetupComm buffer larger is ok, don't need to set up your own buffer, due to the reason of the thread, in the case of high data rate, your thread may be suspended and cannot receive data in time, its own buffer Settings again big also useless, you can also use timeSetEvent, this is a thread in the system, can guarantee the millisecond response, but for real-time serial communication is not so high,
  • Related