123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #include "stdlib.h"
- #include "string.h"
- #include "port.h"
- #include "mb.h"
- #include "mbframe.h"
- #include "mbproto.h"
- #include "mbconfig.h"
- #if MB_FUNC_OTHER_REP_SLAVEID_ENABLED > 0
- static UCHAR ucMBSlaveID[MB_FUNC_OTHER_REP_SLAVEID_BUF];
- static USHORT usMBSlaveIDLen;
- eMBErrorCode
- eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning,
- UCHAR const *pucAdditional, USHORT usAdditionalLen )
- {
- eMBErrorCode eStatus = MB_ENOERR;
-
- if( usAdditionalLen + 2 < MB_FUNC_OTHER_REP_SLAVEID_BUF )
- {
- usMBSlaveIDLen = 0;
- ucMBSlaveID[usMBSlaveIDLen++] = ucSlaveID;
- ucMBSlaveID[usMBSlaveIDLen++] = ( UCHAR )( xIsRunning ? 0xFF : 0x00 );
- if( usAdditionalLen > 0 )
- {
- memcpy( &ucMBSlaveID[usMBSlaveIDLen], pucAdditional,
- ( size_t )usAdditionalLen );
- usMBSlaveIDLen += usAdditionalLen;
- }
- }
- else
- {
- eStatus = MB_ENORES;
- }
- return eStatus;
- }
- #endif
- #if MB_FUNC_UPDATE_ENABLED > 0
- eMBException
- eMBFuncUpdate( UCHAR * pucFrame, USHORT * usLen )
- {
- return eMBUpdateCB(pucFrame, usLen);
- }
- #endif
- #if MB_FUNC_SET_ADDR_ID_ENABLED > 0
- eMBException
- eMBFuncSetAddrId( UCHAR * pucFrame, USHORT * usLen )
- {
- return eMBSetAddrIdCB(pucFrame, usLen);
- }
- #endif
- #if MB_FUNC_SET_ADDR_SERIAL_ENABLED > 0
- eMBException
- eMBFuncSetAddrSerial( UCHAR * pucFrame, USHORT * usLen )
- {
- return eMBSetAddrSerialCB(pucFrame, usLen);
- }
- #endif
|