I've been setting up a machine to communicate with a spectrophotometer in our lab.

Initially I used moserial to test commands and responses, before writing a shell script to handle the communication.

I've been trying to set the port up in the correct fashion using stty, and currently have this command:
stty -F /dev/ttyS0 ispeed 9600 ospeed 9600 -cstopb parenb parodd cs7 raw

This works, up to a point. that is, I can receive simple ASCII output from the spectro, but it appears the hex control codes are getting lost.

If I open moserial, and open and close the port, then go back to my script, everything works. So currently, whenever the machine boots, I have to open moserial, open a port, close it again, before being able to use myscript.

Clearly moserial is setting up something, which then remains set up, and continues to work. Issuing the stty command again, after closing moserial, does not take us back to a non-working state.

Moserials port settings, from its own settings file, are:

So essentially I need to translate those to an stty command, or see which bit of the stty command I'm missing. I know I have the first settings ok, but what does 'handshake=1' and 'access_mode=0' mean to moserial? I know that in moserial the 'hardware handshake' option is on.