- Added Sycamore protocol and command context to SICS
- Added sinfo to SICS - Added driver for TCP/IP Astrium velocity selector - Added driver for TCP/IP Astrium chopper controller SKIPPED: psi/amor2t.c psi/amorstat.c psi/dornier2.c psi/ecb.c psi/el734hp.c psi/fowrite.c psi/libpsi.a psi/make_gen psi/nextrics.c psi/pardef.c psi/pimotor.c psi/pipiezo.c psi/polterwrite.c psi/psi.c psi/scontroller.c psi/serial.c psi/tasinit.c psi/tasscan.c psi/tcpdocho.c psi/tcpdornier.c psi/tricssupport.c psi/velodornier.c
This commit is contained in:
@ -250,6 +250,32 @@ int readRS232TillTerm(prs232 self, void *data, int *datalen){
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
int readRS232UntilWord(prs232 self,
|
||||
char *buffer, int buflen, char *word){
|
||||
time_t endTime;
|
||||
int status;
|
||||
int bytesRead = 0;
|
||||
|
||||
endTime = time(NULL) + self->timeout;
|
||||
memset(buffer,0,buflen);
|
||||
while(time(NULL) < endTime){
|
||||
if(availableRS232(self)){
|
||||
bytesRead = recv(self->pSock->sockid,buffer + bytesRead,
|
||||
buflen - bytesRead - 1,0);
|
||||
if(bytesRead < 0){
|
||||
return BADREAD;
|
||||
}
|
||||
if(strstr(buffer,word) != NULL) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
SicsWait(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int availableRS232(prs232 self)
|
||||
{
|
||||
@ -736,6 +762,31 @@ int RS232Action(SConnection *pCon, SicsInterp *pSics,
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[1],"readchar") == 0){
|
||||
if(argc < 3){
|
||||
SCWrite(pCon,"ERROR: need number of chars to read",eError);
|
||||
return 0;
|
||||
}
|
||||
iRet = Tcl_GetInt(pSics->pTcl,argv[2],&iRead);
|
||||
if(iRet != TCL_OK){
|
||||
SCWrite(pCon,"ERROR: failed to convert argument to number",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!availableRS232(self))
|
||||
{
|
||||
SCWrite(pCon,"Nothing to read!",eError);
|
||||
return 1;
|
||||
}
|
||||
iRet = readRS232(self,pBuffer,&iRead);
|
||||
if(iRet < 0)
|
||||
{
|
||||
getRS232Error(iRet,pError,255);
|
||||
SCWrite(pCon,pError,eError);
|
||||
return 0;
|
||||
}
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[1],"available") == 0)
|
||||
{
|
||||
iRet = availableRS232(self);
|
||||
|
Reference in New Issue
Block a user