One thing I can see right away is that you can’t do this:
while (!SUART.available()) {}
You can’t busy-wait in the SimpleFOC main loop. The loopFOC() and move() functions have to be called as quickly as possible, ideally at a rate of 3kHz or more.
So waiting for Serial input in the middle of this loop is not possible. You’ll have to change the logic to be something like
while (SUART.available()>=2) {
// read the value and do something
}
Also the call to listen() isn’t needed, I don’t think.
In general, why use SoftwareSerial? This won’t have as good performance as a real serial port, and might interfere with the SimpleFOC execution. Can’t you use a real serial port? STM32 MCUs typically have more than one…
[Edit]
Can you use I2C? Our drivers repository has code for the I2CCommander, which works for machine to machine communications…
Alternatively, you could also use the normal Serial based Commander to update the target value.
Writing communications code is tricky, so if you can use something existing, then it will make your life easier I think.