lpcmanager

Parents ec1f5a69bbf5
Children 12b31893a57f
Smarteh 485: slave address of RX buffer must match the address of sent TX buffer in order to be accepted. If reception is not successful data is not copied to beremiz buffer (memcpy()).
--- 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 @@
&uartDevWriteBuf[i][0],
uartDev[i][1]);
- 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:
if(commStat == TRUE)
{
+ 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 @@
TransmitMode();
/* 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);
return(TRUE);