move uart_speed to conn struct and display baudrate only for real UART
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "common.h"
|
||||
#include "comms.h"
|
||||
#include "util_posix.h" // msclock
|
||||
|
||||
|
||||
@@ -103,7 +104,6 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed);
|
||||
/* Gets the current speed of the serial port, in baud.
|
||||
*/
|
||||
uint32_t uart_get_speed(const serial_port sp);
|
||||
extern uint32_t uart_speed;
|
||||
|
||||
#endif // _UART_H_
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
// To memorise baudrate, we don't want to call get_speed systematically
|
||||
uint32_t uart_speed;
|
||||
|
||||
typedef struct {
|
||||
HANDLE hPort; // Serial port handle
|
||||
DCB dcb; // Device control settings
|
||||
@@ -124,8 +121,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;
|
||||
}
|
||||
|
||||
@@ -157,7 +153,7 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) {
|
||||
bool result = SetCommState(spw->hPort, &spw->dcb);
|
||||
PurgeComm(spw->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
|
||||
if (result)
|
||||
uart_speed = uiPortSpeed;
|
||||
conn.uart_speed = uiPortSpeed;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user