Re: C program to issue Applescript commands
From straight C? Not directly (I don't think - I think you'd need to use the old Carbon APIs for executing scripts or something). You could probably cook up some way to fork a process to run an osascript command and pass arguments in to the AppleScript. I don't have any example around for that but you should be able to find examples of starting another process from C and passing command-line parameters to the run handler in AppleScript.
It would probably be much easier just using Python. In fact, if the device is a serial device, Jim Yergey's Simple Serial plugin
might do most of what you need. If it's doing network communication, then Perry's Cynical Network
plugin might work.