Carey Evans wrote: > "Jens B. Jorgensen" <[EMAIL PROTECTED]> writes: > > > Here's some code you can build on: > > > > struct termios ti; > > int modem; > > > > modem = open("/dev/ttyS1", O_RDWR, 0); > > I think it's generally necessary to do O_RDWR|O_NONBLOCK to open a > disconnected serial port, then set CLOCAL with termios, and finally > turn off O_NONBLOCK with fcntl. Of course, for just setting the speed > it should be enough to change the open().
Oh really? You need O_NONBLOCK eh? Why don't you put your compiler where your speculation is and compile/run the attached program. > > ioctl(modem, TCGETS, &ti); /* fill the termios struct with the > > current settings */ > > cfsetispeed(&ti, B9600); /* set input speed to 9600, could be B300 > > - B230400 */ > > cfsetospeed(&ti, B9600); /* set output speed */ > > ioctl(modem, TCSETS, &ti); > > close(modem); > > I prefer to use tcgetattr and tcsetattr than ioctl, although the end > result is exactly the same. Yes, this is the "modern" way. > > You can check out the termios man page for more details. > > Although it describes *how* to do it, it's a bit short on what and > why. You could try looking at the source for things like minicom, dip > and pppd. True enough, although I believe all this depends upon your level of programming experience (unix programming) more than anything. -- Jens B. Jorgensen [EMAIL PROTECTED]
testsp.c
Description: application/unknown-content-type-c_auto_file