move uart_speed to conn struct and display baudrate only for real UART

This commit is contained in:
Philippe Teuwen
2019-04-27 01:15:52 +02:00
parent e9bfc3eb7a
commit 12937884f6
5 changed files with 11 additions and 15 deletions

View File

@@ -60,9 +60,6 @@
# define SOL_TCP IPPROTO_TCP
#endif
// To memorise baudrate, we don't want to call get_speed systematically
uint32_t uart_speed;
typedef struct termios term_info;
typedef struct {
int fd; // Serial port file descriptor
@@ -214,8 +211,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
}
}
}
uart_speed = uart_get_speed(sp);
printf("[=] UART Setting serial baudrate %u\n", uart_speed);
conn.uart_speed = uart_get_speed(sp);
return sp;
}
@@ -422,7 +418,7 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) {
cfsetospeed(&ti, stPortSpeed);
bool result = tcsetattr(spu->fd, TCSANOW, &ti) != -1;
if (result)
uart_speed = uiPortSpeed;
conn.uart_speed = uiPortSpeed;
return result;
}