- 论坛徽章:
- 0
|
急,谁知道在UNIX下用C写MODEM传输程序?给您磕头了。 (无内容)
/**************************************************************
Function : receive bytes from serial comport
Param In :
iHandle : handle returned by serOpen
uiRecvCnt: bytes of accii buffer
iTimeOut : timeout if equals 0 use default timeout
Param Out :
psBuf : ascii buffer which will be received
Return Code:
=0 : OK
<0 : serTimeOut
serRecvFail
***************************************************************/
int serReceiveBuf( int iHandle, char *psBuf, uint uiRecvCnt, int iTimeOut )
{
int iCnt, iRet;
int fdIn;
fdIn = fileno( pSerial[iHandle]->;fpIn );
if( setjmp(tohere2) ) return (serTimeOut);
signal( SIGALRM, alrm2 );
if( iTimeOut>;0 ) alarm(iTimeOut);
else if( iTimeOut==0 ) alarm( pSerial[iHandle]->;iDefTimeOut );
for( iCnt=0; iCnt<uiRecvCnt; iCnt++ )
{
while( ( iRet=read(fdIn,psBuf+iCnt,1) ) == 0 );
if( iRet<0 )
{
alarm(0);
return (serRecvFail);
}
}
alarm(0);
return (serOK);
} |
|