- Added separate drivable motors for four circle H, K, L
- Added a listen mode to commandlog in order to support the batchEditor - Some small fixes to exe* for BatchEditor
This commit is contained in:
@ -134,6 +134,10 @@ int writeRS232(prs232 self, void *data, int dataLen)
|
||||
if(pPtr != NULL)
|
||||
free(pPtr);
|
||||
|
||||
if(iRet != 1){
|
||||
return BADSEND;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
@ -213,17 +217,21 @@ int readRS232TillTerm(prs232 self, void *data, int *datalen){
|
||||
replylen = *datalen;
|
||||
iRet = NETReadTillTermNew(self->pSock,self->timeout,self->replyTerminator,
|
||||
(char *)data, replylen);
|
||||
if(self->debug > 0)
|
||||
if(self->debug > 0 && iRet == 1)
|
||||
{
|
||||
printf("RS232 IN/TERM : %s",(char *)data);
|
||||
if(strchr((char *)data,'\n') == NULL)
|
||||
{
|
||||
puts("");
|
||||
puts("");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
if(iRet == 0)
|
||||
{
|
||||
if(self->debug > 0)
|
||||
{
|
||||
printf("RS232 IN/TERM : TIMEOUT:%s\n",(char *)data);
|
||||
}
|
||||
return TIMEOUT;
|
||||
}
|
||||
else if(iRet == -1)
|
||||
@ -307,9 +315,9 @@ int transactRS232(prs232 self, void *send, int sendLen,
|
||||
write data
|
||||
*/
|
||||
iRet = writeRS232(self,send,sendLen);
|
||||
if(iRet < 0)
|
||||
if(iRet <= 0)
|
||||
{
|
||||
return iRet;
|
||||
return BADSEND;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -320,12 +328,23 @@ int transactRS232(prs232 self, void *send, int sendLen,
|
||||
reply, replyLen);
|
||||
if(self->debug > 0)
|
||||
{
|
||||
printf("RS232 IN/TRANS: %s",(char *)reply);
|
||||
if(strchr((char *)reply,'\n') == NULL)
|
||||
if(iRet == 1)
|
||||
{
|
||||
puts("");
|
||||
printf("RS232 IN/TRANS: %s",(char *)reply);
|
||||
if(strchr((char *)reply,'\n') == NULL)
|
||||
{
|
||||
puts("");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
else if(iRet == 0)
|
||||
{
|
||||
printf("RS232 IN/TRANS: TIMEOUT\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("RS232 IN/TRANS/INCOMPLETE: %s",(char *)reply);
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
if(iRet == 0)
|
||||
{
|
||||
@ -362,7 +381,7 @@ void getRS232Error(int iCode, char *errorBuffer,
|
||||
break;
|
||||
case TIMEOUT:
|
||||
strncpy(errorBuffer,
|
||||
"Timeout reading data",
|
||||
"Timeout or network error when reading data",
|
||||
errorBufferLen);
|
||||
break;
|
||||
case FAILEDCONNECT:
|
||||
@ -374,6 +393,9 @@ void getRS232Error(int iCode, char *errorBuffer,
|
||||
strncpy(errorBuffer,"Did not find terminator in read buffer",
|
||||
errorBufferLen);
|
||||
break;
|
||||
case BADSEND:
|
||||
strncpy(errorBuffer,"Network problem: failed to send",errorBufferLen);
|
||||
break;
|
||||
default:
|
||||
strncpy(errorBuffer,strerror(errno),
|
||||
errorBufferLen);
|
||||
@ -407,6 +429,21 @@ int initRS232(prs232 self)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
void closeRS232(prs232 self)
|
||||
{
|
||||
assert(self);
|
||||
|
||||
if(self->pSock != NULL)
|
||||
{
|
||||
if(pServ->pReader != NULL){
|
||||
NetReadRemoveUserSocket(pServ->pReader,self->pSock->sockid);
|
||||
}
|
||||
NETClosePort(self->pSock);
|
||||
free(self->pSock);
|
||||
self->pSock = NULL;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
prs232 createRS232(char *host, int iPort)
|
||||
{
|
||||
|
Reference in New Issue
Block a user