Im looking to integrate a command interface in a project that im making that will accept commands overs serial from a PC.
The idea is that the device will do its thing but it gets sent a command, it will perform it. This is different to most examples i've managed to find which is just an idling device waiting for serial data.
So for example, a device which controls LEDs and plays an animation. Lets say theres 3 preset animations, and when it turns on it always plays number 1. On the PC side I would send a command 'play preset 2', or 'change color to green' or sending a live real time animation to the device to play on the LEDs.
So my question is that I can not find much information on this "design pattern" ? I do not know where to start to look. The closest i've come is pre-made arduino serial parsing libraries. However im looking for more of C / non arduino / theoretical approach.
I have looking into serial protocols but that is just things such as SPI and I2C etc, not actually how to implement a control / command interface in software.
I also found out about HDLC, again though it seems to be more of a standard / a protocol. A similar thread is https://stackoverflow.com/questions/1445387/how-do-you-design-a-serial-command-protocol-for-an-embedded-system Which has some very nice information but again its to do with the protocol / communication itself.
Im trying to find how to code / implement this to create a command or control ability.
Do I use an infinite loop to monitor and catch the serial for an incoming command, and use a list of IF statements to choice what command to carry out, but then what happens when no commands and the system should be as normal, or if it misses a command?
Interrupt driven, state machine?
Is there an official name for this that can be used to research and find examples?
For anyone who has the same question, I found this really nice example while researching, http://www.adnbr.co.uk/articles/parsing-simple-usart-commands