IOCTL

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IOCTL

494 Views
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

Labels (1)
0 Kudos
Reply
0 Replies