Modified version of ModbusTCP
Dependencies: EthernetNetIf mbed
Diff: main.cpp
- Revision:
- 3:d7d7c67f21fa
- Parent:
- 0:62be54b8975d
--- a/main.cpp Tue Mar 13 13:16:24 2012 +0000 +++ b/main.cpp Thu Mar 15 15:28:14 2012 +0000 @@ -127,13 +127,13 @@ #if MB_TCP_ENABLED == 1 Net::poll(); #endif -/* + if(tm.read()>.5) { led1=!led1; //Show that we are alive tm.start(); } -*/ + eStatus = eMBPoll( ); /* Here we simply count the number of poll cycles. */ @@ -249,11 +249,9 @@ case MB_REG_WRITE: // Write coils - if(iIntBitNum==0){ - usRegCoilBuf[iIntBufNum]=0; - } - ucTemp=(pucRegBuffer[iExtBufNum]>>iExtBitNum) & 1; - usRegCoilBuf[iIntBufNum]|=ucTemp<<iIntBitNum; + ucTemp=usRegCoilBuf[iIntBufNum]&(~(1<<iIntBitNum)); + ucTemp|=((pucRegBuffer[iExtBufNum]>>iExtBitNum) & 1)<<iIntBitNum; + usRegCoilBuf[iIntBufNum]=ucTemp; break; } iIntRegIndex++;