Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

using UART to collect 2 rx_buf

Hi, I have configured normal uart, where you send 1 tx_buf and wait for the rx_buf until you get a response. This setup was fine until the logging feature was requested. However, I need a different type of setup because I also need to log data.

I am collecting data on sd card. I am communicating with motion controller over uart to drive a motor. I can send the string "GN\r" over uart in a tx_buf and receive the speed response and then I can print it to a file on the sd card. However, The motion controller also sends a response back when it reaches the destination. Then I have send disable motor command over uart to stop the motor.

lets say  I have a timer. In the timer interrupt a local rx_buf catches speed data after transmitting the tx_buf. and in the mainloop  I have another uart communication going, the tx_buf says notify at position x and the local rx_buf in the loop is going to catch the response "P/r/n"

Will this work? Do I need concurrency or RTOS? or what would be the ideal uart setup for this? Will a simple timeout work? Please share you thoughts

Parents
  • Having multiple uart communications over different contexts is very normal as long as they are not interfering with each other. Based on your description, it seems that sending the motor commands and receiving response to it will happen together which can be in one context/thread. You can have start/stop different uart rx based on timer or other interthread communication functionality to get other responses from the motor.

    Will this work? Do I need concurrency or RTOS? or what would be the ideal uart setup for this? Will a simple timeout work? Please share you thoughts

    Does not look like a complex requirement, so it should work. RTOS will make your life easy in terms of have native support of inter thread communications to start/stop uart RX only when not sending commands to the motor.

  • Thanks. Everything you said makes sense. if i find any specific issues while implementing it. I will post a different question on the forum with more specific description

Reply Children
Related