AnsweredAssumed Answered

MQX with UART... How to receive?

Question asked by Massimiliano Sturla on Sep 30, 2014
Latest reply on Oct 2, 2014 by Massimiliano Sturla

Hi, I'm stuck on the UART - RX ....

I'm using FRDM-K64 demo board and MQX 4.1.1

From user config I'm set a new (ttyb) UART, the UART1.

I correctly send data from K64 to my PC via serial port, but I have problem with receive routine...

I can read the receive buffer with this function (from rs485 example NOT for frdm-k64 but for one TWR)

 

fread(data_buffer, 1, 18, ttybSci1_dev);

 

where ttybSci1_dev is name of my port. The problem is that I can read but MQX do not tell me when a packet (or a byte) arrive, like linux with the signal


i suppose RX interrupt are managed by MQX and redefined tham I bypass MQX routine that acquire the byte


there is, something similar SIGNAL in linux, that I can use? Something that alert me when a byte arrive?


Example:


/* For write I use: */

char data_bufferTR[] = "\nTaskRead";

write(ttybSci1_dev, data_bufferTR, strlen(data_bufferTR));

fflush(ttybSci1_dev);

/* For read I use */

void   *semReceivedData;

if (_sem_open("SemaphoreForDataRX", &semReceivedData) != MQX_OK) {

   printf("\nOpening semReceivedData semaphore failed.");

   _task_block();

}

if (_sem_wait(semReceivedData, 0) != MQX_OK) {

         printf("\nWwaiting for semReceivedDatasemaphore failed");

         _task_block();

}                 

fread(data_buffer, 1, NumberByteReceived, ttybSci1_dev)



So I need how to give the semaphore semReceivedData when MQX receive a packet (or a byte and I  will join all in a packet)

Many thanks,

Massimiliano

Outcomes