A bit of reformatting and set the ADUlen in the default case

This commit is contained in:
Douglas Clowes
2014-08-29 12:34:53 +10:00
parent ef0c7cc0d5
commit 13a0547f5d

View File

@ -17,7 +17,7 @@
* data
* ETX
* BCC
*/
*/
#define PROTOCOL_NAME "MODBUS_AP"
#define PROTOCOL_INIT MODBUSInitProtocol
#define ADUSIZE 17
@ -44,7 +44,17 @@ struct cmdPar {
double MBdata[2000];
};
enum MBFCODES { RdCoil=1, RdInp=2, RdHldReg=3, RdInpReg=4, WrCoil=5, WrReg=6, WrMCoils=15, WrMRegs=16 };
enum MBFCODES {
RdCoil=1, /* Read Coil - single output bit */
RdInp=2, /* Read Input - single input bit */
RdHldReg=3, /* Read Holding Register */
RdInpReg=4, /* Read Input Register */
WrCoil=5, /* Write Coil - force output bit */
WrReg=6, /* Write Register */
WrLoop=8, /* Write Loopback */
WrMCoils=15, /* Write Multiple Coils */
WrMRegs=16 /* Write Multiple Registers */
};
typedef struct modbus_private_t Private, *pPrivate;
struct modbus_private_t {
@ -171,8 +181,8 @@ static double ieee2double(unsigned char ieee[4]) {
/*-------------------------------------------------------------------------*/
/** @brief Parse a command string of the form "MBAddr:Fcode:SAddr:Dtype:MBdata"
Dtype U16, U32, F32 with optional byte order array eg U32[3,2,1,0]
*/
Dtype U16, U32, F32 with optional byte order array eg U32[3,2,1,0]
*/
static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) {
int len;
unsigned int i;
@ -323,6 +333,7 @@ static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_bu
break;
default:
// Not Implemented
ADUlen = 7;
break;
}
/* Length field in MBAP includes byte 7 of the MBAP, so Length = ADU length - 6. */