serial port programming - SGI

This is a discussion on serial port programming - SGI ; All, I wrote a program doing serial communication via RS422 port /dev/tty4d2 off an Octane2 SGI. I receive data fine. But, when I am sending data, for some reason what I send is not always what is received. I print ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: serial port programming

  1. serial port programming


    All,

    I wrote a program doing serial communication via RS422 port /dev/tty4d2
    off an Octane2 SGI.
    I receive data fine. But, when I am sending data, for some reason what
    I send is not always what is received.
    I print out the cmd before sending and it always seems correct, but it
    does not reach correctly.
    Here are snippets of the code I have written with my configuration. Am
    I setting the output configuration correctly?
    Any help would be greatly appreciated.


    _newSettings.c_iflag &= ~(IXON | IXANY | IXOFF);
    _newSettings.c_iflag &= ~(BRKINT | IGNPAR | ICRNL | IUCLC);
    _newSettings.c_iflag &= ~ISTRIP;

    _newSettings.c_oflag &= ~OPOST;
    _newSettings.c_oflag |= 0;
    _newSettings.c_oflag &= ~(ONLCR | TAB3);

    _newSettings.c_cflag |= CREAD;
    _newSettings.c_cflag |= CLOCAL;
    _newSettings.c_cflag |= CS8;
    _newSettings.c_cflag &= ~CSTOPB;
    _newSettings.c_cflag |= (PARENB | PARODD); //odd parity

    _newSettings.c_lflag &= ~(ICANON | ISIG | ECHO | ECHOE);

    _newSettings.c_ospeed = 38400;
    _newSettings.c_ispeed = 38400;

    _newSettings.c_cc[VMIN] = 0;
    _newSettings.c_cc[VTIME] = 0;

    if (tcsetattr(_portFd, TCSANOW, &_newSettings) == -1)
    {
    cout << "we have problem";
    cout << endl;
    }

    struct strioctl str;
    int arg = 0;
    arg = RS422_ON;
    str.ic_timout = 0;
    str.ic_len = 4;
    str.ic_dp = (char *)&arg;
    str.ic_cmd = SIOC_RS422;

    if (ioctl(_port, I_STR, &str) < 0)
    {
    cout << "we have problem setting to rs422" << endl;
    }

    if (tcflush(_port, TCIFLUSH) == -1)
    {
    cout << "error flushing old data" << endl;
    }

    //now we do other stuff



    Thanks in advance,
    Patrick


  2. Re: serial port programming

    In article <1107195755.209347.319370@f14g2000cwb.googlegroups. com>,
    wrote:
    >
    >All,
    >
    >I wrote a program doing serial communication via RS422 port /dev/tty4d2
    >off an Octane2 SGI.
    >I receive data fine. But, when I am sending data, for some reason what
    >I send is not always what is received.
    >I print out the cmd before sending and it always seems correct, but it
    >does not reach correctly.
    >Here are snippets of the code I have written with my configuration. Am
    >I setting the output configuration correctly?
    >Any help would be greatly appreciated.



    It's possibly misleading for me to read much into a partial
    code snippet, but you don't show a tcgetattr() to start, which
    always the way to start on the serial port flags (to get the
    initial setting).

    >_newSettings.c_iflag &= ~(IXON | IXANY | IXOFF);

    [rest of code removed to save space]

    David Anderson
    [No, not a serial port expert. Hope this helps.]

  3. Re: serial port programming

    Thanks David....that seems to have worked....at least for now.

    Patrick


+ Reply to Thread