Hi,
fread() is a blocking function if I use your example the only way I can get fread() to not block is by using ittyc (ittycin my case)
however it doesn't receive the character that I send to it and it stops my transmit task from working. Also the documentation isnt very helpful. Pleas help Thanks
#define TIMEOUT_ERR false;
void receive_task(uint32_t initial_data )
{
MQX_FILE_PTR rs232_dev = NULL;
char data_buffer[5] = {0};
uint32_t num_chars;
bool timed_out;
//rs232_dev = fopen( "ttyc:", ( char const * ) IO_SERIAL_NON_BLOCKING ); // receives characters okay but blocks. Note //IO_SERIAL_NON_BLOCKING has no effect?
rs232_dev = fopen( "ittyc:", ( char const * ) IO_SERIAL_NON_BLOCKING ); // does not block with or without // IO_SERIAL_NON_BLOCKING. doent receive // character sent to it
while(TRUE)
{
// printf("\n receive task blocked - debug\n");
//_task_block();
/* Read the data(s) in non blocking mode .. */
_time_delay(150);
num_chars = fread( data_buffer, 1, 2 , rs232_dev);
if (num_chars)
{
if(data_buffer[0] == 'r' )
{
/* receive all the other chars .. */
// post data to callee task - TBD
data_buffer[0] = 0;
}
}
else
{
timed_out = TIMEOUT_ERR;
//post timout event to callee - TBD
}
};
}
Transmit Task disabled. and code commented out
Has anyone solved this problem?
Thanks