Serial commmunication

Hi all,
I’d like to send: “@00MB040400014E*” via serial port. Communication parameters should be: parity=even; baud=9600; bits=7; stopb=2; . Could anyone give me a sample of program, which can do it?

stty baud=9600 par=even bits=7 stopb=2 < /dev/ser1

echo @00MB040400014E* > /dev/ser1

Or did you want it in C? :smiley: If you want to always use the com port with those parameters, I would look at restarting devc-ser8250 with those options so they are the default. If you really want to change the settings in code, take a look at the termios stucture in the helpviewer as well as the tcgetattr() and tcsetattr().

If you are just talking about writing to the serial port, simply fopen() the serial port, fwrite() your data, and fclose() it when done.

On a related note I want to use the io_devctl handler in a modified version of the USB printer driver supplied by QNX. When I use stty baud=1200 </dev/usbdev0 the io_devctl is called but I can’t figure out how to decode it to a set baudrate command. In the lib ddk directory it suggests that I add a DEVCTL_SETBAUD which is define as 0x0010 but the this sample uses a different calling contect of the devctl routine to that in the USB samples.

Is their something which tells me how to decode the msg->i.cmd structure to tie in with stty it seems to be related to the __DIO* macros but where I believe the cmd should be (the lower 8 bits ) is 0x13 not 0x10. also where are the classes defined.

Sorry for the ramble

Paul

Look in the headers - /usr/include/sys/dcmd_*.h in particular. It should help.

Thanks Rick,
I think you can read in my mind:). Could you give me it in C?
I’m totally new in QNX and i don’t feel good enough in it to change the default settings permamently.
I want to send that expression :slight_smile: to the PLC.

rick thanks for making me look at this the answer isn’t in dcmd_* for my particular problem but while I was greping around in there for a mention of the Baud rate it did pick up the structure I’m after in termios.