From c61cb222704641579a44dbca4b32d6484ec31527 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 12 Dec 2014 14:25:24 +1100 Subject: [PATCH] Handle bigger modbus messages --- site_ansto/hardsup/modbus_asyncprotocol.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/site_ansto/hardsup/modbus_asyncprotocol.c b/site_ansto/hardsup/modbus_asyncprotocol.c index cde567e9..3779447b 100644 --- a/site_ansto/hardsup/modbus_asyncprotocol.c +++ b/site_ansto/hardsup/modbus_asyncprotocol.c @@ -20,7 +20,7 @@ */ #define PROTOCOL_NAME "MODBUS_AP" #define PROTOCOL_INIT MODBUSInitProtocol -#define ADUSIZE 17 +#define ADUSIZE 300 /* * MODBUS DataTypes @@ -63,7 +63,7 @@ struct modbus_private_t { int aduLen; int RespLen; int DatLen; - unsigned char ADU[ADUSIZE]; /* Allows upto 8 bytes if data */ + unsigned char ADU[ADUSIZE]; /* Allows up to 255 bytes of data */ pDynString rdBuffer; }; @@ -89,6 +89,10 @@ static ProtoPrivate *makeProtoPrivate() static ProtoPrivate *Proto_KillPrivate(ProtoPrivate *priv) { if (priv) { + if (priv->wrBuffer) { + DeleteDynString(priv->wrBuffer); + priv->wrBuffer = NULL; + } if (priv->rxBuffer) { DeleteDynString(priv->rxBuffer); priv->rxBuffer = NULL; @@ -268,7 +272,7 @@ static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_bu int ADUlen, PDUlenPlusUID; unsigned int i, j; char *cmdLine; - unsigned char ADU[32], ieee[4]; + unsigned char ADU[ADUSIZE], ieee[4]; cmdLine = GetCharArray(wrBuffer); for (i=0; i < 4; i++)