I have a program that communicates via serial port to the target. The target is likely a shell or similar program. In case I want to send several commands to the target, how can I know a command is end so that I can send the next command?
I have had some ideas, like catch the shell prompt or let the command output some text before exits. But these will increase the complexity. I’d like to know if there are some other simpler method to achieve it.
It would be impossible to know if a command ended without information going back to the agent issuing the commands with some sort of completion indication. Consider how a *nix terminal works. The *nix terminal was developed exactly for the same kind of situation — issuing remote commands to another PC over some sort of pipe. In that case, how does the user know she can type another command? In the default case, it lets you know its done by giving you a prompt to issue another command. In an edge case it lets you have the process fork from the shell, in which you get an indication that the job has completed.
It seems the simplest solution is to echo something along the lines of “<< cmd >> complete”.
Some basic psuedocode