Send bytes over UART
Posted: Thu Feb 06, 2020 3:59 am
I'm trying to control a TMC2009 driver over UART and I need to send the commands as bytes but I only seem to be able to send characters. What do I need to change to get it sending bytes not characters?
I've got the following code for the UART,
I've got the following code for the UART,
Code: Select all
int sendData(const char* logName, const char* data)
{
const int len = strlen(data);
const int txBytes = uart_write_bytes(UART_NUM_2, data, len);
ESP_LOGI(logName, "Wrote %d bytes", txBytes);
return txBytes;
}
static void tx_task()
{
static const char *TX_TASK_TAG = "TX_TASK";
while (1) {
sendData(TX_TASK_TAG, "0xA000004F");
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}