IOCTL

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

IOCTL

720 次查看
netra
Contributor IV

I am using mqx3.5 .

I wrote a small code to read packet from rs485

  int rxBytes = 0,BytesToBeRead = 0;

   BOOL  bytesPresent = FALSE ;    /* To avoid blocking */

 

    while(length)

    {

        if( MQX_OK == ioctl(comPort->handle, IO_IOCTL_CHAR_AVAIL ,&bytesPresent))

        {

            if( bytesPresent )

            {

                rxBytes += fread(pBuffer+rxBytes, SINGLE_BYTE_ELEMENTS, 1, comPort->handle);

                length--;

            }

            else

            {

                break;   

            }           

        }

    }

   

    return(rxBytes);

This code is working fine but it is getting an extra bit in the beginning of the packet which is not sent by other end device but received in  pBuffer.

Please do help

Thanks in advance

Nisha

标签 (1)
0 项奖励
回复
0 回复数