File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < algorithm>
12#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
23#include " serial.h"
34#include < fstream>
@@ -140,6 +141,25 @@ auto serialRead(
140141 const int timeout,
141142 const int multiplier
142143) -> int {
144+
145+ if (ioctl (hSerialPort, TCGETS2, &tty) == -1 ){
146+ errorCallback (status (StatusCodes::SET_STATE_ERROR));
147+ return 0 ;
148+ }
149+
150+ if (timeout > 0 && timeout < 100 ) {
151+ tty.c_cc [VTIME] = 1 ;
152+ } else {
153+ tty.c_cc [VTIME] = timeout / 100 ;
154+ }
155+
156+ tty.c_cc [VMIN] = bufferSize;
157+
158+ if (ioctl (hSerialPort, TCSETS2, &tty) == -1 ){
159+ errorCallback (status (StatusCodes::SET_STATE_ERROR));
160+ return 0 ;
161+ }
162+
143163 int bytesRead = read (hSerialPort, static_cast <char *>(buffer), bufferSize);
144164
145165 if (bytesRead >= 0 ){
You can’t perform that action at this time.
0 commit comments