- Fixed a bug fix with Fixed motor in TAS code
- Made AMOR write HDF-5 data in chunks - Added driver for a PSI-DSP magnet controller as used at SLS - Added code for directly accessing RS232 controllers connected to a terminal server, thereby bypassing the SerPortServer - A rounding problem in the PSD histogram memory was resolved.
This commit is contained in:
108
network.c
108
network.c
@ -402,7 +402,7 @@ CreateSocketAdress(
|
||||
}
|
||||
|
||||
/* data or block for read, read */
|
||||
buffer[0] = '\0';
|
||||
memset(buffer,0,lLen);
|
||||
iRet = recv(self->sockid,buffer,lLen,0);
|
||||
if(iRet == 0)
|
||||
{/* eof */
|
||||
@ -414,10 +414,114 @@ CreateSocketAdress(
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[iRet] = '\0';
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
int NETAvailable(mkChannel *self, int timeout)
|
||||
{
|
||||
fd_set lMask;
|
||||
struct timeval tmo ={0,1};
|
||||
int iRet;
|
||||
|
||||
if(!VerifyChannel(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* setup for select */
|
||||
tmo.tv_usec = timeout;
|
||||
FD_ZERO(&lMask);
|
||||
FD_SET(self->sockid,&lMask);
|
||||
if((self->sockid >= FD_SETSIZE) || (self->sockid < 0) )
|
||||
/* invalid descriptor */
|
||||
{
|
||||
return -1; /* eof */
|
||||
}
|
||||
iRet = select( (self->sockid + 1),&lMask, NULL, NULL,&tmo);
|
||||
if( iRet < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(FD_ISSET(self->sockid,&lMask))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int NETReadTillTerm(mkChannel *self, int timeout,
|
||||
char *pTerm, char *pBuffer, int iBufLen)
|
||||
{
|
||||
int iRet, termLen, i, j, nLoop;
|
||||
int read = 0;
|
||||
|
||||
|
||||
if(!VerifyChannel(self))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
how may cycles to read in order to have a timeout
|
||||
*/
|
||||
nLoop = timeout/10;
|
||||
if(nLoop <= 0)
|
||||
{
|
||||
nLoop = 1;
|
||||
}
|
||||
|
||||
for(i = 0; i < nLoop; i++)
|
||||
{
|
||||
iRet = NETAvailable(self,10);
|
||||
if(iRet < 0)
|
||||
{
|
||||
return iRet;
|
||||
}
|
||||
else if(iRet == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
data is pending, read it
|
||||
*/
|
||||
iRet = recv(self->sockid,pBuffer+read,iBufLen - read,0);
|
||||
if(iRet < 0)
|
||||
{
|
||||
return iRet;
|
||||
}
|
||||
else
|
||||
{
|
||||
read += iRet;
|
||||
}
|
||||
if(read >= iBufLen)
|
||||
{
|
||||
pBuffer[iBufLen-1] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
pBuffer[read+1] = '\0';
|
||||
}
|
||||
/*
|
||||
have we found a terminator ?
|
||||
*/
|
||||
for(j = 0; j < strlen(pTerm); j++)
|
||||
{
|
||||
if(strrchr(pBuffer,pTerm[j]) != NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; /* timeout! */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int NETClosePort(mkChannel *self)
|
||||
{
|
||||
|
Reference in New Issue
Block a user