Linux MS/TP Fixes (#1051)
* Linux MS/TP: * dlmstp_init: * Maximize thread priority if permitted * MSTP_Put_Receive/dlmstp_receive: * Use a buffer so incoming frames are not dropped during bursts * dlmstp_receive: * Make timeout optional * MSTP_Get_Reply: * Lock the mutex before using the PDU Queue * Iterate over all queued replies to find a match (instead of only checking the first) * Sleep for a millisecond before checking again to wait for the application provide a reply * RS485_Check_UART_Data: * Ensure waiter is initilized before using with select * Ensure bytes are read before adding to FIFO TSM: * Add log when `datalink_send_pdu` fails for consistency with all other `datalink_send_pdu` calls dlenv_maintenance_timer: * Fix Tx/Rx labels in MSTP statitistics print * don't log on queued requests
This commit is contained in:
+5
-8
@@ -249,6 +249,8 @@ void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
ssize_t n;
|
||||
int handle = RS485_Handle;
|
||||
FIFO_BUFFER *fifo = &Rx_FIFO;
|
||||
waiter.tv_sec = 0;
|
||||
waiter.tv_usec = 5000;
|
||||
|
||||
SHARED_MSTP_DATA *poSharedData = (SHARED_MSTP_DATA *)mstp_port->UserData;
|
||||
if (poSharedData) {
|
||||
@@ -258,9 +260,6 @@ void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
|
||||
if (mstp_port->ReceiveError == true) {
|
||||
/* do nothing but wait for state machine to clear the error */
|
||||
/* burning time, so wait a longer time */
|
||||
waiter.tv_sec = 0;
|
||||
waiter.tv_usec = 5000;
|
||||
} else if (mstp_port->DataAvailable == false) {
|
||||
/* wait for state machine to read from the DataRegister */
|
||||
if (FIFO_Count(fifo) > 0) {
|
||||
@@ -270,10 +269,6 @@ void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
/* FIFO is giving data - just poll */
|
||||
waiter.tv_sec = 0;
|
||||
waiter.tv_usec = 0;
|
||||
} else {
|
||||
/* FIFO is empty - wait a longer time */
|
||||
waiter.tv_sec = 0;
|
||||
waiter.tv_usec = 5000;
|
||||
}
|
||||
}
|
||||
/* grab bytes and stuff them into the FIFO every time */
|
||||
@@ -285,7 +280,9 @@ void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
}
|
||||
if (FD_ISSET(handle, &input)) {
|
||||
n = read(handle, buf, sizeof(buf));
|
||||
FIFO_Add(fifo, &buf[0], n);
|
||||
if (n > 0) {
|
||||
FIFO_Add(fifo, &buf[0], n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user