trying to RS485 example on k60 tower kit having some issue in fread

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

trying to RS485 example on k60 tower kit having some issue in fread

474 Views
vallinaths
Contributor II

using the rs485 example code

void rs485_read_task

   (

      uint_32 initial_data

   )

{

   MQX_FILE_PTR rs485_dev = NULL;

   char  data_buffer[256];

   rs485_dev  = fopen( RS485_CHANNEL, NULL );                    

   if( rs485_dev == NULL )

   {

      /* device could not be opened */

      _task_block();

   } 

 

   /* wait for data */

   fread(data_buffer, 1, 18, rs485_dev);

 

   while(1)

   {   

    printf("\n - Buffer_DAta              = %s Hz", &data_buffer);

   };

}

The write task is printing the "RS485 example " in the serial terminal ,so write routine is working sine  , but the read task is not reading the character typed on serial terminal . if anybody has tried this program please support anything to be modified .

0 Kudos
1 Reply

267 Views
chandrasekarkan
Contributor III

Hi

      As you are trying to read 18 bytes in the fread call, it will block the task until all 18 bytes are received in the buffer.

Try reading byte by byte..

0 Kudos