termios, ioctl problem

From: Carole MacDonald (elora_c_at_yahoo.com)
Date: 10/21/03

  • Next message: Julián Albo: "Re: termios, ioctl problem"
    Date: 21 Oct 2003 10:33:30 -0700
    
    

    I have a C++ program that communicates with a device on a serial port
    using /dev/ttyS0. When my program checks for data with ioctl() and
    then do a read(), certain byte values are being dropped: 0x11 (start)
    and 0x13 (stop). I can send these out from my program just fine, I
    just can't read them in. I've looked at the termios structure and I'm
    sure I'm setting a flag improperly, but I can't figure it out. Here's
    what the stty -a output looks like:

    speed 9600 baud; rows 0; columns 0; line = 0;
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
    eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase =
    ^W;
    lnext = ^V; flush = ^O; min = 1; time = 0;
    -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
    -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl
    ixon -ixoff
    -iuclc -ixany -imaxbel
    -opost olcuc ocrnl onlcr onocr onlret ofill ofdel nl1 cr3 tab3 bs1 vt1
    ff1
    -isig -icanon iexten -echo -echoe echok echonl noflsh xcase tostop
    echoprt
    -echoctl echoke

    and the code I'm using to set the settings on the port:
    //set the options for the Port
    fcntl(m_fd,F_SETFL,0);
    tcgetattr(m_fd,&settings);
    settings.c_lflag = ~(ICANON | ECHO | ECHOE | ISIG | ECHOCTL);
    settings.c_oflag &= ~OPOST;
    tcsetattr(m_fd,TCSANOW,&settings);
    fcntl(m_fd,F_SETFL,FNDELAY);

    If anyone can help me figure out the proper flags, I'd really
    appreciate it.

    Thanks,
    Carole


  • Next message: Julián Albo: "Re: termios, ioctl problem"

    Relevant Pages

    • Re: rs485 on SBC84500
      ... > data to a serial port. ... If a sufficient driver was never created, you end up using ioctl ... to control the devices registers directly from user space. ...
      (comp.os.linux.embedded)
    • Re: SetCommState() fails with "A device attached to the system is not functioning"
      ... IOCTL codes required. ... There are something like 40 IOCTLs that a serial port must support. ... It sounds like the fix is not in SetCommState, but in the device driver for the virtual ...
      (microsoft.public.vc.mfc)
    • RS232 Problem
      ... I have a program that communicates with an instrument via the RS232 interface. ... If I go into the Device Manager and disable and then re-enable the port, ... My customer has a recent WinXP computer that runs an earlier version of the program, but not the latest versions, giving my "communications failure" response when it tries to receive data. ... The ports are running at 9600 baud for one program and 19600 baud for another. ...
      (microsoft.public.windowsxp.basics)
    • Printers and parallel ports
      ... I need to write a C# program which communicates with a thermal printer. ... communicate with the port. ... dll's readFile method with the parallel port. ... hexadecimal code 0x05 to my printer which must return me a byte ...
      (microsoft.public.dotnet.general)
    • find com port mapped to USB
      ... I need to write a PC program that communicates with a small device that have ... Firmware guy showed me that the device can initialize its USB port, ... if the device started its USB port setup successfully. ...
      (microsoft.public.vc.mfc)