IOCTL

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IOCTL

496件の閲覧回数
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 返答(返信)