From 386074fd3ffd04ae21cb914dc84969c9fd981c5e Mon Sep 17 00:00:00 2001 From: kutayboz Date: Fri, 9 Jun 2023 02:02:07 +0300 Subject: Overhaul. Created bg96 lib. --- src/serial.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/serial.c') diff --git a/src/serial.c b/src/serial.c index 8456e68..88e9a4c 100644 --- a/src/serial.c +++ b/src/serial.c @@ -57,7 +57,8 @@ int openSerialPort(char pathToPort[]) { return serialPort; } -int querySerialPort(char **output, int serialPort, char *input) { +int querySerialPort(char **output, int serialPort, char *input, + int timeoutSeconds) { time_t timeStart; unsigned long idx; @@ -104,8 +105,8 @@ int querySerialPort(char **output, int serialPort, char *input) { break; } } - } else if (bytesRead == 0 && time(NULL) - timeStart > 180) { - printf("Response timeout after 180 seconds\n"); + } else if (bytesRead == 0 && time(NULL) - timeStart > timeoutSeconds) { + printf("Response timeout after %d seconds\n", timeoutSeconds); returnCode = 1; break; } -- cgit v1.3