1234567891011121314151617181920212223242526272829303132 |
- /**
- * @Author: 李建
- * @Date: 2024/9/7 10:46
- * Description: modbus 写入设备序列号的实现
- * Copyright: Copyright (©) 2024 永续绿建. All rights reserved.
- */
- #include "mb.h"
- #include "mbframe.h"
- // 定义ymodem协议包的起始始偏移地址
- #define MB_PDU_YMODEM_PACK_OFFSET ( 0 )
- // 定义帧头的偏移地址
- #define MB_PDU_YMODEL_PACK_HEADER_OFFSET ( MB_PDU_YMODEM_PACK_OFFSET + 1 )
- /* ----------------------- Static functions ---------------------------------*/
- eMBException prveMBError2Exception(eMBErrorCode eErrorCode);
- #if MB_FUNC_WRITE_DEVICE_SERIAL_ENABLE
- eMBException eMBFuncWriteDeviceSerial(eMBRTUSlaveObj *obj, UCHAR *pucFrame, USHORT *usLen) {
- eMBErrorCode eRegStatus;
- eMBException eStatus = MB_EX_NONE;
- eRegStatus = obj->callback->eMBWriteDeviceSerialCB(&pucFrame[MB_PDU_YMODEL_PACK_HEADER_OFFSET],
- &pucFrame[MB_PDU_YMODEL_PACK_HEADER_OFFSET], usLen);
- /* If an error occured convert it into a Modbus exception. */
- if (eRegStatus != MB_ENOERR) {
- eStatus = prveMBError2Exception(eRegStatus);
- }
- return eStatus;
- }
- #endif
|