AnsweredAssumed Answered

IOCTL

Question asked by netra on Nov 23, 2013

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

Outcomes