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

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

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

621 次查看
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 项奖励
回复
1 回复

414 次查看
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 项奖励
回复