Re: ONYX2 Serial Port Question

New Message Reply Date view Thread view Subject view Author view

Mark Aubin (aubin++at++mustang.engr.sgi.com)
Wed, 29 Sep 1999 12:19:23 -0700 (PDT)


On Sep 29, 1:28pm, Gamble, Murray - Kan AV HFE wrote:
> Subject: RE: ONYX2 Serial Port Question
>
> Hi Mark,
>
> Thank you for your suggestions. I have checked the serial device manager
> on both the ONYX2 and the Octane and there are no devices configured on
> any of the ports. I am using the serial ports in the simplest manner
> possible. That is I'm using "open, read, write and close" commands to
> send/receive data from the serial ports. As I stated in my original
> post, ports 1 & 2 on our ONYX2 work fine, ports 3 & 4 on the ONYX2 do
> not. With that in mind, I don't think that it is a problem with the
> termio structure.
>
> Any other ideas?
>
> Thanks again,
>
> Murray.
>

Hi Murray,

Yes, it is all clear now.

You cannot use the serial devices reliably in the manner stated.

You must use the ioctl command to set the state of the
serial port. If you don't, the port will be in an unknown
state. Could be wrong baud rate, wrong data bits, wrong
flow control, etc.

I put together a program that will let you check the state
of a serial port. This will reveal why some ports work and
some don't.

http://reality.sgi.com/aubin/checkport.c

Here's an example of how to set the port for a B&G flybox:

int fd;
struct termio tio;

if ((fd = open("/dev/ttyd2", O_RDWR|O_NDELAY)) == -1) {
    fprintf(stderr, "Failed to open port.\n");
    exit(-1);
}

tio.c_iflag = IGNBRK|IXON|IXOFF;
tio.c_oflag = 0;
tio.c_cflag = CS8|CREAD|CLOCAL;
tio.c_lflag = ICANON;
tio.c_ospeed = B19200;

if ((ioctl(fd, TCSETAF, &tio)) < 0) {
    fprintf(stderr, "Failed to initialize port.\n");
    exit(-1);
}

--Mark Aubin
  aubin++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Wed Sep 29 1999 - 12:19:31 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.