Hi TI,
It need a delay[Task_sleep(500)] for next uart_printf as below, wondering why
Please help, thanks!!!
=====================================
1. TI Sample code: ble_examples-simplelink_cc2640r2_sdk-2.20.zip\ble_examples-simplelink_cc2640r2_sdk-2.20\examples\rtos\CC2640R2_LAUNCHXL\bleapps\simple_serial_socket_server
2. SDK: simplelink_cc2640r2_sdk_2_20_00_49
=====================================
%%%Current project code as below%%%
static void SimpleSerialSocketServer_taskFxn(UArg a0, UArg a1)
{
// Initialize application
SimpleSerialSocketServer_init();
uart_printf("SimpleSerialSocketServer_init\r\n");
Task_sleep(500);
uart_printf("SimpleSerialSocketServer_init1\r\n");
}
%%%Related UART code in currently project%%%:
static void SimpleSerialSocketServer_init(void)
{
UART_Params uartParams;
UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.readCallback = uartReadCallback;
uartParams.writeCallback = UartWriteCallback;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartHandle = UART_open(Board_UART0, &uartParams);
UART_control(uartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);
UART_read(uartHandle, uartReadBuffer, UART_MAX_READ_SIZE);
}
static void UartWriteCallback(UART_Handle handle, void *txBuf, size_t size)
{
// Free the last printed buffer
if (NULL != uartCurrentMsg)
{
ICall_free(uartCurrentMsg);
uartCurrentMsg = NULL;
}
// If the list is not empty, start another write
if (!List_empty(&uartWriteList)) {
uartCurrentMsg = (uartMsg_t *) List_get(&uartWriteList);
UART_write(uartHandle, uartCurrentMsg->buffer, uartCurrentMsg->len);
}
else
{
uartWriteActive = 0;
}
}
static void uartReadCallback(UART_Handle handle, void *rxBuf, size_t size)
{
// Pass the number of read bytes using the arg0 field
//SimpleSerialSocketServer_enqueueMsg(SSSS_OUTGOING_DATA, NULL, NULL, size);
}
int uart_printf(const char *fmt, …) //max 64 chars
{
uint8_t i, size=0;
va_list args;
va_start(args, fmt);
vsprintf((char *)Uart_TxBuf, fmt, args);
va_end(args);
for(i=0; i<UART_BUFFER_SIZE; i++)
{
size = i;
if(Uart_TxBuf[i] == NULL)
break;
}
//NPITask_sendToHost((uint8_t *)&buf,i);
UART_write(uartHandle,(const Char *)&Uart_TxBuf,i);
//SendCommand2MCU(infoRsp, Uart_TxBuf, size);
}
Viki Shi:
连续使用uart_printf 是需要一点延迟,uart_printf 本身需要一点时间,如果没有延迟,可能会造成下一个数据丢失
Pellun Wu:
回复 Viki Shi:
Hi TI,
1. 請問多久延遲為正常? 可否提供不需要Delay的方法(修改UART參數)?
2.蔽司於CC2640上一樣方法實做此uart_printf , 並不需要任何delay, 請問差異為何?
謝謝!
Viki Shi:
回复 Pellun Wu:
请查看下这个文档: dev.ti.com/…/