From 8d2d51b45c271a1714967882a54334c08b11dada Mon Sep 17 00:00:00 2001 From: Timothe Jost <timothe.jost@wanadoo.fr> Date: Thu, 4 Jul 2024 12:18:33 +0200 Subject: [PATCH] improvement in proxyInit and openSerialPort --- sources/src/functions.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sources/src/functions.c b/sources/src/functions.c index 872c506..da34170 100644 --- a/sources/src/functions.c +++ b/sources/src/functions.c @@ -101,6 +101,7 @@ static int openSerialPort(const char *serial_port) printf("Input Serial Port Baud Rate: %d\n", input_baud); printf("Output Serial Port Baud Rate: %d\n", output_baud); + printf("serial_fd value: %d\n", fd); return fd; } @@ -122,14 +123,14 @@ void proxyInit(unsigned int udp_port, char *serial_device, const char *udp_addre for (int i = 0; i < MAX_SERIAL_PORTS; i++) { serial_fd = openSerialPort(serial_ports[i]); - if (serial_fd) + if (serial_fd < 0) { - printf("Successfully opened serial port: %s\n", serial_ports[i]); - break; + printf("Failed to open serial port: %s\n", serial_ports[i]); } else { - printf("Failed to open serial port: %s\n", serial_ports[i]); + printf("Successfully opened serial port: %s\n", serial_ports[i]); + break; } } } -- GitLab