Hi everyone
There is a problem with the function UART_read(). I get a message on UART. Maximum message length is wantedRxBytes = 5. The message does not have a specific length. I need to know the exact number of bytes received. UART_read() always returns zero, however, the message is accepted. The source code of the program is presented below:
static void readCallback(UART_Handle handle, void *rxBuf, size_t size) { Event_post(eventH, UART_RX_COMPLETE); } void taskFxn(UArg arg0, UArg arg1) { eventH = Event_create(NULL, NULL); UART_Handle handle; UART_Params params; UART_Params_init(¶ms); params.writeDataMode = UART_DATA_BINARY; params.readDataMode = UART_DATA_BINARY; params.readMode = UART_MODE_CALLBACK; params.readCallback = &readCallback; params.baudRate = 2400; handle = UART_open(Board_UART, ¶ms); UART_control(handle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL); wantedRxBytes = 5; uint8_t rxBuf [wantedRxBytes]; Int RxBytes = UART_read(handle, rxBuf, wantedRxBytes); uint8_t tBuf [5] = {0x01, 0x02, 0x03, 0x04, 0x05}; while(true) { uint16_t events = Event_pend(eventH, Event_Id_NONE, 0xFFFFFFFF, BIOS_WAIT_FOREVER); if (events & UART_RX_COMPLETE) { UART_write (handle, tBuf, RxBytes); Task_sleep(10000); Event_post(eventH, UART_TX_COMPLETE); } if (events & UART_TX_COMPLETE) { RxBytes = UART_read(handle, rxBuf, wantedRxBytes); } } } Thanks in advance.