1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Cant open serial port properly ... I dont understand whats wrong ...

Discussion in 'Embedded' started by Doublehp, Feb 23, 2004.

  1. Doublehp

    Doublehp Guest

    This message is related with

    http://groups.google.fr/groups?dq=&...TF-8&group=alt.microcontrollers.8bit&start=25

    I received from motorola the following answer:
    "This customer use Linux and have trouble to send 0x0A or 0x0D, this
    is due
    to his Linux I/O driver. Metrowerks CodeWarrior for HC08 is run under
    Windowes OS and it
    works fine on 908JB8 without any trouble on send 0x0A or 0x0D down."


    can someone untar http://demaine.free.fr/monitor_68hc08/src/ read the
    file rs232.c and try to find whats wrong between lines 49 to 71 ?

    I really dont understand what could make opening the port in a wrong
    mode ...

    You dont really need to comile ... just read my last post, my logbook
    p29 and my source file.

    Thanks for any help
     
    Doublehp, Feb 23, 2004
    #1
    1. Advertising

  2. You may need to specify the translation mode as binary, as I'm not sure
    what
    the default translation mode under Linux is.

    Mike Anton


    "Doublehp" <> wrote in message
    news:...
    > This message is related with
    >
    >

    http://groups.google.fr/groups?dq=&...TF-8&group=alt.microcontrollers.8bit&start=25
    >
    > I received from motorola the following answer:
    > "This customer use Linux and have trouble to send 0x0A or 0x0D, this
    > is due
    > to his Linux I/O driver. Metrowerks CodeWarrior for HC08 is run under
    > Windowes OS and it
    > works fine on 908JB8 without any trouble on send 0x0A or 0x0D down."
    >
    >
    > can someone untar http://demaine.free.fr/monitor_68hc08/src/ read the
    > file rs232.c and try to find whats wrong between lines 49 to 71 ?
    >
    > I really dont understand what could make opening the port in a wrong
    > mode ...
    >
    > You dont really need to comile ... just read my last post, my logbook
    > p29 and my source file.
    >
    > Thanks for any help
     
    Michael Anton, Feb 24, 2004
    #2
    1. Advertising

  3. Doublehp

    Doublehp Guest

    (Doublehp) wrote in message news:<>...

    after 2h of chat on IRC, someone said me that i forgot to enter
    nonOPOST mode, so I added line 70 with the proper line as described on
    http://www.easysw.mike/serial/serial.html

    /* canonical raw input */
    vars->serial->c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
    vars->serial->c_lflag &= ~OPOST;
    vars->serial->c_cflag |= (CS8); /* use 8bit data */
    // term_prop->c_cflag |= (CLOCAL | CREAD);
    tcsetattr(fd, TCSAFLUSH, vars->serial);

    but I still had the same bug ... so that people offered that very
    horrible hack:
    I put

    sprintf(stty,"stty -a < %s",vars->device);
    system(stty);

    after tcsetattr

    Q: why isnt the line with ~OPOST enough ???
     
    Doublehp, Feb 24, 2004
    #3
  4. Doublehp

    Brian Dean Guest

    On Tue, Feb 24, 2004 at 02:49:47PM -0800, Doublehp wrote:

    > vars->serial->c_lflag &= ~OPOST;


    > but I still had the same bug ... so that people offered that very
    > horrible hack:
    > I put
    >
    > sprintf(stty,"stty -a < %s",vars->device);
    > system(stty);
    >
    > after tcsetattr
    >
    > Q: why isnt the line with ~OPOST enough ???


    OPOST needs to be applied to c_oflag (output modes), not c_lflag
    (local modes).

    Cheers,
    -Brian
    --
    Brian Dean,
    BDMICRO - MAVRIC & MAVRIC-II ATmega128 Based Dev Boards
    http://www.bdmicro.com/
     
    Brian Dean, Feb 25, 2004
    #4
  5. Doublehp

    Doublehp Guest

    Brian Dean <> wrote in message news:<>...
    > On Tue, Feb 24, 2004 at 02:49:47PM -0800, Doublehp wrote:
    >
    > > vars->serial->c_lflag &= ~OPOST;

    >
    > > but I still had the same bug ... so that people offered that very
    > > horrible hack:
    > > I put
    > >
    > > sprintf(stty,"stty -a < %s",vars->device);
    > > system(stty);
    > >
    > > after tcsetattr
    > >
    > > Q: why isnt the line with ~OPOST enough ???

    >
    > OPOST needs to be applied to c_oflag (output modes), not c_lflag
    > (local modes).
    >
    > Cheers,
    > -Brian


    You are right. Thank you all of you for your help
     
    Doublehp, Feb 26, 2004
    #5
  6. Doublehp

    Wim Lewis Guest

    In article <>,
    Doublehp <> wrote:
    >after 2h of chat on IRC, someone said me that i forgot to enter
    >nonOPOST mode, so I added line 70 with the proper line as described on
    >http://www.easysw.mike/serial/serial.html
    >
    >/* canonical raw input */
    > vars->serial->c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);


    Actually, this is setting *non*canonical input (turning off ICANON).
    "Canonical" input means translating the terminal's idea of CR into
    Unix's idea (0x0A). By default, the serial port is configured to
    talk to a terminal, so flags like that are turned on.

    See "man termios" for all the gory details. Yo ucan probably get what
    you want with "raw" mode: call tcgetattr(), cfmakeraw(), and then
    tcsetattr() to apply the modified attributes back onto the serial device.
    cfmakeraw() does almost the same thing you're doing in the code snippet
    you posted, except it modifies a few more flags.

    --
    Wim Lewis <>, Seattle, WA, USA. PGP keyID 27F772C1
     
    Wim Lewis, Feb 26, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shirl

    Cant Detect HD whats wrong?

    Shirl, Jan 1, 2006, in forum: Abit
    Replies:
    9
    Views:
    1,676
    Lurking Rat in 'Da Hood®
    Jan 2, 2006
  2. The Major
    Replies:
    2
    Views:
    1,482
    The Major
    Dec 8, 2004
  3. Louise
    Replies:
    3
    Views:
    227
    Steve
    Apr 11, 2004
  4. Maciek

    I dont understand

    Maciek, May 21, 2004, in forum: ATI
    Replies:
    12
    Views:
    397
    Darthy
    May 24, 2004
  5. Dagger
    Replies:
    2
    Views:
    382
Loading...

Share This Page