Other Parts Discussed in Thread: SYSCONFIG
I am using simpleLink SDK version 4.10
I am using UART port in non-blocking mode initialized as below:
UART_Handle InitTerm(void)
{
UART_Params uartParams;
int32_t semStatus;
/* Create semaphore */
semStatus = sem_init(&sem, 0, 0);
if (semStatus != 0) {
/* Error creating semaphore */
while (1);
}
UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.readTimeout = 1000;
uartParams.readCallback = callbackFxn;
uartParams.baudRate = 115200;
uartHandle = UART_open(CONFIG_UART_0, &uartParams);
if(uartHandle)
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
/* remove uart receive from LPDS dependency */
UART_control(uartHandle, UART_CMD_RXDISABLE, NULL);
return(uartHandle);
}
Callback function is defined as below:
void callbackFxn(UART_Handle handle, void *buffer, size_t count,
void *userArg, int_fast16_t status)
{
if (status != UART_STATUS_SUCCESS) {
/* RX error occured in UART2_read() */
while (1);
}
numBytesRead = count;
sem_post(&sem);
}
I am trying to receive data using read function as below:
int GetRawCmd(char *pcBuffer, unsigned int uiBufLen)
{
char cChar;
int buffindex = 0;
uint32_t status = UART_STATUS_SUCCESS;
while (1) {
numBytesRead = 0;
/* Pass NULL for bytesRead since it's not used in this example */
status = UART_read(uartHandle, &cChar, 1);
Display_printf(display, 0, 0, "out of read\r\n");
if (status != UART_STATUS_SUCCESS) {
/* UART_read() failed */
Display_printf(display, 0, 0, "read failed\r\n");
while (1);
}
Display_printf(display, 0, 0, "waiting for callback\r\n");
/* Do not write until read callback executes */
sem_wait(&sem);
Display_printf(display, 0, 0, "callback recv\r\n");
if((cChar == '\r') || (cChar == '\n')){
pcBuffer[buffindex] = '\0';
break;
}else{
pcBuffer[buffindex] = cChar;
buffindex++;
}
}
return buffindex;
}
I am using second uart port for debug statements. The following debug statements are displayed:
out of read
waiting for callback
No further debug statements are received. This means that it keep waiting for semaphore which is released in callback function. Call back is not received even if I sent characters from tera term on PC, I am using USB to serial converter to connect second uart port to PC. This setup function good if I am using blocking uart mode.
Please help with debugging as why callback function is not received.