[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help serial port communication



Here's some code you can build on:

        struct termios  ti;
        int             modem;

        modem = open("/dev/ttyS1", O_RDWR, 0);
        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);

You can check out the termios man page for more details.

C.J.LAWSON wrote:

> Hi,
>   I am trying to set the baud rate of one of my serial ports I am
> writing and application for and I am really at a loss. I have even tried
> to use the setserial package, however I cannot get it to work (probably
> because I do not understand the documentation). Does anyone have/know of
> any code (native C) which does this, which I can learn from.
>
> Thanking you very much in advance
>
>         Jonathan
>
> --
> TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
> debian-user-request@lists.debian.org .
> Trouble?  e-mail to templin@bucknell.edu .



--
Jens B. Jorgensen
jjorgens@bdsinc.com



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: