An update: Using the built-in RS485 half-duplex mode and just inverting the RTS line when talking to the secondary endpoint seems to have solved the problem for me.
ESP_Angus wrote: ↑Tue Oct 29, 2019 2:21 am
By default, it's un-pinned so it can run on either CPU and its priority is 18 (for memory), so it would preempt the UART task on CPU1 if something was also running on CPU0.
I just tested with my task priority (pinned to core 1) set at 19 (WiFi and LWIP tasks are still pinned to core 0), the problem does seem to have disappeared, but it's possible that I just haven't seen it yet.
Also, regarding this:
quote=ESP_Angus post_id=51055 time=1572304149 user_id=1923]
If you make a minimal example that just does the RS-485 operation and nothing else, does it still exhibit the same behaviour? Is there any chance you could post the code for a minimal example like this, please?
[/quote]
I don't have the liberty to test this at the moment, but here's the basic flow if somebody on the ESP team would like to try and reproduce.
Code: Select all
comQueueItem message; // comQueueItem is a custom struct
while(1) {
if(uxQueueMessagesWaiting(comQueue) { // There is another function for external subsystems to enqueue a custom struct message
if(xQueueReceive(comQueue, (void*) &message, portMAX_DELAY) != pdTRUE) {
continue;
}
uint8_t responseData[message.responseLen]; // message.responseLen is the full expected length of the packet
configureUART(message.endpoint); //invert or remove inversion on RTS line depending on endpoint
uart_write_bytes(UART_NUM_2, (char*) message.data, message.requestLen); // message.data malloc'd uint8_t*, filled out before enqueueing message. message.requestLen is the full request packet length.
uart_read_bytes(UART_NUM_2, responseData, message.responseLen, 1000/portTICK_PERIOD_MS); // message.responseLen is the expected response packet length
// decode raw data into a message struct based on the endpoint (protocols differ between the two)
// call the callback function with the endpoint-specific struct as a void*
}
}