If talking to your device involves sending a command and waiting for any of several different responses... or a timeout... I would try
Expect. It is almost always easier than home-brewing your own logic for figuring out which state the wretched device has wandered into
this time.
Expect can talk to any program that has a conventional interactive interface. Most people spawn a telnet or ssh session, but you could use Expect to drive minicom. I think that it is also possible to use Expect->exp_init(\*FILEHANDLE) to connect directly to a Linux tty port, but I haven't had a chance to try it.