Handle change to asyncqueue to handle binary protocols

r2280 | dcl | 2008-01-15 12:37:52 +1100 (Tue, 15 Jan 2008) | 2 lines
This commit is contained in:
Douglas Clowes
2008-01-15 12:37:52 +11:00
parent 2ebe674425
commit cad1e0a4d5

View File

@@ -382,6 +382,7 @@ int NHQ200_Check_Status(pNHQ200 self)
/* Can be called to check for correct operation of the NHQ200 */ /* Can be called to check for correct operation of the NHQ200 */
{ {
int iRet, iRetry, busy, notbusy; int iRet, iRetry, busy, notbusy;
int iRspLen;
char pCommand[20]; char pCommand[20];
char pReply[132]; char pReply[132];
/* Check the busy status. /* Check the busy status.
@@ -395,8 +396,9 @@ int NHQ200_Check_Status(pNHQ200 self)
printf("Checking status..."); printf("Checking status...");
do do
{ {
iRspLen = 79;
sprintf(pCommand,"S%d", self->iControl); sprintf(pCommand,"S%d", self->iControl);
iRet=AsyncUnitTransact(self->unit, pCommand, strlen(pCommand), pReply, 79); iRet=AsyncUnitTransact(self->unit, pCommand, strlen(pCommand), pReply, &iRspLen);
if (iRet <= 0) if (iRet <= 0)
{ {
printf("Comms error!\n"); printf("Comms error!\n");
@@ -497,6 +499,7 @@ int NHQ200_Config(pNHQ200 *pData, int iTmo, int iRead, int iControl,
int NHQ200_Send(pNHQ200 *pData, char *pCommand, char *pReply, int iLen) int NHQ200_Send(pNHQ200 *pData, char *pCommand, char *pReply, int iLen)
{ {
int iRet; int iRet;
int iRspLen;
int commandlen; int commandlen;
pNHQ200 self; pNHQ200 self;
@@ -505,7 +508,8 @@ int NHQ200_Send(pNHQ200 *pData, char *pCommand, char *pReply, int iLen)
/* Send command direct to the NHQ200 */ /* Send command direct to the NHQ200 */
commandlen=strlen(pCommand); commandlen=strlen(pCommand);
iRet=AsyncUnitTransact(self->unit, pCommand, commandlen, pReply, iLen); iRspLen = iLen;
iRet=AsyncUnitTransact(self->unit, pCommand, commandlen, pReply, &iRspLen);
return iRet; return iRet;
} }
@@ -550,6 +554,7 @@ int NHQ200_Set(pNHQ200 *pData, float fVal)
{ {
char pCommand[20], pCommandRead[20], pReply[132], pCommandGo[20]; char pCommand[20], pCommandRead[20], pReply[132], pCommandGo[20];
int iRet; int iRet;
int iRspLen;
const float fPrecision = 0.1; const float fPrecision = 0.1;
float fDelta, fRead; float fDelta, fRead;
pNHQ200 self; pNHQ200 self;
@@ -567,11 +572,13 @@ int NHQ200_Set(pNHQ200 *pData, float fVal)
sprintf(pCommandRead,"D%d", self->iControl); sprintf(pCommandRead,"D%d", self->iControl);
/* send Dn=nnn command, we get a blank line response */ /* send Dn=nnn command, we get a blank line response */
iRet = AsyncUnitTransact(self->unit,pCommand,strlen(pCommand),pReply,131); iRspLen = 131;
iRet = AsyncUnitTransact(self->unit,pCommand,strlen(pCommand),pReply, &iRspLen);
if (iRet <= 0) if (iRet <= 0)
return iRet; return iRet;
/* read the set value again using the Dn command */ /* read the set value again using the Dn command */
iRet = AsyncUnitTransact(self->unit,pCommandRead,strlen(pCommandRead),pReply,131); iRspLen = 131;
iRet = AsyncUnitTransact(self->unit,pCommandRead,strlen(pCommandRead),pReply, &iRspLen);
if (iRet <= 0) if (iRet <= 0)
return iRet; return iRet;
printf("D%d: Response %d chars: '%s'\n",self->iControl, iRet, pReply); printf("D%d: Response %d chars: '%s'\n",self->iControl, iRet, pReply);
@@ -588,7 +595,8 @@ int NHQ200_Set(pNHQ200 *pData, float fVal)
if(fDelta < fPrecision) if(fDelta < fPrecision)
{ {
sprintf(pCommandGo, "G%d", self->iControl); sprintf(pCommandGo, "G%d", self->iControl);
iRet = AsyncUnitTransact(self->unit,pCommandGo,strlen(pCommandGo),pReply,131); iRspLen = 131;
iRet = AsyncUnitTransact(self->unit,pCommandGo,strlen(pCommandGo),pReply, &iRspLen);
if (iRet <= 0) if (iRet <= 0)
return iRet; return iRet;
printf("G%d: Response %d chars: '%s'\n",self->iControl, iRet, pReply); printf("G%d: Response %d chars: '%s'\n",self->iControl, iRet, pReply);