How to make odrive run automatically?Please help with my project

Hi all,
it has been two months since I got my first odrive(odrive3.6 with fw 0.5.1),and I have learned related knowledge(e.g.,Brushless motor control principle,stm32, freertos…yes, I am a layman). My PC runs in win10, and I can control odrive with odrivetool as expected, but it’s not enough.
My project requires that once the external voltage signal,which is measured by a sensor, is greater than the threshold, the motor output specified torque. So the key point is how to make odrive run automatically without typing codes in odrivetool. I have envisaged two approaches:

  1. Make a upper machine software in PC. After been A-D converted by a stm32 board, the voltage signal will be sent to PC, then the software transfer control commands to odrive according to the size of signal,via USB. In this way, we can make man-machine interface,but it’s a little complicated to me;

2.It’s similar to approach 1,but there is no PC in control system. The stm32 board convert the voltage signal,jugde the size of voltage,then transfer control commands to odrive via UART.
Are these two approaches feasible?
What’s the data transfered to odrive from PC via USB and stm32 via UART expectively? I have read the source code of firmware but couldn’t find it. For example,when we type “odrv0.axis0.controller.input_torque=0.1” in odrivetool, what data is sent to odrive on earth? A hexadecimal number?
I am looking forward to your reply, it would be grateful if you help me!!!

The best solution here is to use CAN bus or UART directly from the STM32.

Hi, thank you for your reply. So the key point is communication between two stm32, right? I’m going to use UART. What data sent to odrive with freertos embeded can represent torque commands?

How to use UART: UART Interface | ODrive

The ASCII protocol (which is default for UART): ASCII Protocol | ODrive

I’ve read these guides already. I think I need to learn more related knowledge. Thanks a lot!