--- a/LPCBus/MC9_Devices_decl.c Mon May 08 08:31:17 2017 +0200
+++ b/LPCBus/MC9_Devices_decl.c Tue May 16 08:47:29 2017 +0200
@@ -320,22 +320,22 @@
- memcpy(uartDevReadBuf_drv, &uartDevReadBuf, sizeof(uartDevReadBuf_t));
- if(!rt_mutex_acquire(&UART_ReadMutex, TM_INFINITE )){
- if(uartDevReadBuf_plc_state == EMPTY){
- uartDevReadBuf_t *uartDevReadBuf_tmp;
- uartDevReadBuf_tmp = uartDevReadBuf_plc;
- uartDevReadBuf_plc = uartDevReadBuf_drv;
- uartDevReadBuf_drv = uartDevReadBuf_tmp;
- uartDevReadBuf_plc_state = FULL;
- rt_mutex_release(&UART_ReadMutex);
// Check communication status:
+ memcpy(uartDevReadBuf_drv, &uartDevReadBuf, sizeof(uartDevReadBuf_t)); + if(!rt_mutex_acquire(&UART_ReadMutex, TM_INFINITE )){ + if(uartDevReadBuf_plc_state == EMPTY){ + uartDevReadBuf_t *uartDevReadBuf_tmp; + uartDevReadBuf_tmp = uartDevReadBuf_plc; + uartDevReadBuf_plc = uartDevReadBuf_drv; + uartDevReadBuf_drv = uartDevReadBuf_tmp; + uartDevReadBuf_plc_state = FULL; + rt_mutex_release(&UART_ReadMutex); uartCommStatusBuf[i][0] = TRUE;
uartCommErrCntBuf[i][0] = 0;
@@ -499,7 +499,7 @@
/* Copy received buffer */
- if(count == uartBufSize){
+ if((count == uartBufSize) && (tmp[uartBufSize-TAIL_LEN] == address)){ if(ChecksumValid((unsigned char*)tmp+1, uartBufSize)){
memcpy(readBuf,tmp+1,uartBufSize-TAIL_LEN-1);