I have refactored the terminal to be an object. It is simply instantiated by writing
Code: Select all
Terminal t(USART3, commandList);
All the code from usart_setup() in hwinit.cpp has now gone into terminal.cpp. All commands are now passed a Terminal object which in turn can be passed to fprintf to output something on a specific terminal should there be multiple. Might use that on the Tesla charger to have both the USB and the Wifi terminal.
If there is only one terminal, printf just prints to that. More specifically it prints to the terminal last instantiated.
Moreover the "fastuart" command is now built into the terminal and so is the new "enableuart" command. The latter will enable or disable the USART TX pin depending on nodeid. That will be used to share one ESP8266 module between multiple STM32 processors.
What that means: your project can have a parameter for nodeid and pass that to the terminal. t.SetNodeId(). So if you have nodes 1, 2, 3 and type
Code: Select all
enableuart 2
A disabled node will still listen for the "enableuart" command, obviously, but also to the "fastuart" command so that baudrates are kept equal.
Lastly, the Run() function is now non-blocking, i.e. in your main() you will need and endless loop that calls Run(). That is in case you need to serve more than one terminal.
Will do some testing of this on Damiens Dual Motor Prius board.