help port com2 - Linux

This is a discussion on help port com2 - Linux ; hello, Linux red hat 9 would have an example in language C which opens the port com2 in 19200 bauds 8 bits without parity, which make it possible to send since a file of the ASCII characters and which also ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: help port com2

  1. help port com2

    hello,
    Linux red hat 9
    would have an example in language C which opens the port com2 in 19200
    bauds 8 bits without parity, which make it possible to send since a file
    of the ASCII characters and which also make it possible to receive then
    in another file of other characters asii?
    thank you by advance
    Jip



  2. Re: help port com2

    jean-pierre sarteaux wrote:
    > Linux red hat 9
    > would have an example in language C which opens the port com2 in 19200
    > bauds 8 bits without parity, which make it possible to send since a file
    > of the ASCII characters and which also make it possible to receive then
    > in another file of other characters asii?


    Sorry, but I don't understand all what you write. But I give it try
    anyway since nobody else did it for some days;-)

    You typically open a serial port by opening it's device file
    using open(2). On most (all?) systems the device file is
    /dev/ttyS0 for what's callled com1 in DOS-speak and /dev/ttyS1
    for com2. Take care to open the device file in non-blocking mode
    (i.e. with the O_NONBLOCK flag), the open() call could hang
    otherwise. You can switch later to blocking mode by using
    fcntl(2) with a F_SETFL command if you need to. Once you have
    it open you must set up the transmission settings. Thse not
    only include the baud rate, number of bits and parity but also
    a lot other. The man page for tcsetattr(3) will give you a list
    of all of them and how to set them. The list is quite long and
    doesn't help much in understanding what all the settings stand
    for, so better also have a look at serial programming guide for
    POSIX operating systems:

    http://www.easysw.com/~mike/serial/serial.html

    Once that's all out of the way you can start sending or
    receiving data using write(2) or read(2). You will probably
    get problems when you start trying to deal with the serial
    port (I at least did), so don't be afraid to ask more question
    here - at least one or two of the leading experts on dealing
    with the serial port under Linux are reading this group and
    are kind enough to answer all the complicated questions;-)

    The conversion from one character set to another hasn't any-
    thing to do with the serial port, the program running on one
    or the other side will have to take care of that. On your
    Linux macine probably a tool lik 'recode' is installed, this
    can be used to translate between a huge number of different
    character sets - just use it to convert the file before
    sending the result to the other side (or use it to convert
    after you have received the file).

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

  3. Re: help port com2


    Hi Jens,
    Thank you for your help and councils
    Sorry for my bad English

    Regards.

    Jipi


    Jens Thoms Toerring a *crit :

    > jean-pierre sarteaux wrote:
    > > Linux red hat 9
    > > would have an example in language C which opens the port com2 in 19200
    > > bauds 8 bits without parity, which make it possible to send since a file
    > > of the ASCII characters and which also make it possible to receive then
    > > in another file of other characters asii?

    >
    > Sorry, but I don't understand all what you write. But I give it try
    > anyway since nobody else did it for some days;-)
    >
    > You typically open a serial port by opening it's device file
    > using open(2). On most (all?) systems the device file is
    > /dev/ttyS0 for what's callled com1 in DOS-speak and /dev/ttyS1
    > for com2. Take care to open the device file in non-blocking mode
    > (i.e. with the O_NONBLOCK flag), the open() call could hang
    > otherwise. You can switch later to blocking mode by using
    > fcntl(2) with a F_SETFL command if you need to. Once you have
    > it open you must set up the transmission settings. Thse not
    > only include the baud rate, number of bits and parity but also
    > a lot other. The man page for tcsetattr(3) will give you a list
    > of all of them and how to set them. The list is quite long and
    > doesn't help much in understanding what all the settings stand
    > for, so better also have a look at serial programming guide for
    > POSIX operating systems:
    >
    > http://www.easysw.com/~mike/serial/serial.html
    >
    > Once that's all out of the way you can start sending or
    > receiving data using write(2) or read(2). You will probably
    > get problems when you start trying to deal with the serial
    > port (I at least did), so don't be afraid to ask more question
    > here - at least one or two of the leading experts on dealing
    > with the serial port under Linux are reading this group and
    > are kind enough to answer all the complicated questions;-)
    >
    > The conversion from one character set to another hasn't any-
    > thing to do with the serial port, the program running on one
    > or the other side will have to take care of that. On your
    > Linux macine probably a tool lik 'recode' is installed, this
    > can be used to translate between a huge number of different
    > character sets - just use it to convert the file before
    > sending the result to the other side (or use it to convert
    > after you have received the file).
    >
    > Regards, Jens
    > --
    > \ Jens Thoms Toerring ___ jt@toerring.de
    > \__________________________ http://toerring.de



+ Reply to Thread