Skip to content

Commit b1a54c8

Browse files
committed
Don't use character timeouts on Linux and macOS
1 parent 0f74ac8 commit b1a54c8

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

serialport/serialport.c

-34
Original file line numberDiff line numberDiff line change
@@ -306,38 +306,11 @@ void serialport_set_baudrate(unsigned int baudrate)
306306
}
307307
}
308308

309-
void serialport_set_character_timeout_0_1s(unsigned int t)
310-
{
311-
if (t > 255)
312-
t = 255;
313-
#ifndef __APPLE__
314-
term.c_cc[VMIN] = 0;
315-
term.c_cc[VTIME] = t; // VTIME is measured in 0.1s
316-
317-
LOGDEBUG("setting character timeout %i", t);
318-
319-
if (tcsetattr(serial_port, TCSANOW, &term)!=0)
320-
{
321-
LOGDEBUG("set timeout failed");
322-
}
323-
324-
LOGDEBUG("done");
325-
#endif
326-
timeout = t;
327-
}
328-
329-
unsigned serialport_get_character_timeout_0_1s()
330-
{
331-
return term.c_cc[VTIME];
332-
}
333-
334-
335309
void serialport_set_timeout(unsigned int t)
336310
{
337311
if(t != timeout)
338312
{
339313
LOGDEBUG("setting timeout %i", t);
340-
serialport_set_character_timeout_0_1s((t + 99)/100);
341314
timeout = t;
342315
}
343316
}
@@ -347,7 +320,6 @@ unsigned serialport_get_timeout()
347320
return timeout;
348321
}
349322

350-
351323
int serialport_open(const char *device, unsigned int baudrate)
352324
{
353325
LOGINFO("opening port %s at %d", device, baudrate);
@@ -445,17 +417,11 @@ unsigned serialport_write(const unsigned char* data, unsigned int size)
445417
void serialport_flush(void)
446418
{
447419
static unsigned char b;
448-
unsigned int t;
449420

450421
if(serial_port)
451422
{
452-
t = serialport_get_character_timeout_0_1s();
453-
serialport_set_character_timeout_0_1s(0);
454-
455423
tcdrain(serial_port);
456424
while(read(serial_port, &b, 1) > 0);
457-
458-
serialport_set_character_timeout_0_1s(t);
459425
}
460426
}
461427

0 commit comments

Comments
 (0)