This discussion is archived
2 Replies Latest reply: Jan 8, 2013 6:04 PM by 983469 RSS

How to develop rs232 program?

983469 Newbie
Currently Being Moderated
I develop serial program in linux, it work fine. but when i port it to solaris, it will became more garbled characters...
I use this sample code:
http://www.vr.ncue.edu.tw/esa/EmbeddedSystemProgramming2010/ch06.htm

i only modify this code in two line:

/* real baudrate value in my device:B57600 */
#define BAUDRATE B57600
/* real device:/dev/cua/1 */
#define MODEMDEVICE /dev/cua/1

And not modify other place , but result appear more garbled characters, not normal character.
So i want to ask this question about this difference in solaris between linux in serial port?
And where is relational documents for reference?
Thanks.

My OS is Solaris 11.1
  • 1. Re: How to develop rs232 program?
    Nik Expert
    Currently Being Moderated
    Hi.

    IMHO Solaris not have big difference when forking with serial device.
    Genaraly, garbled characters mean that selected speed not correspond to device speed.

    What device connected to rs232 port ?

    /dev/cua - not loking ports, so can be used at one time by different programs with different settintg.
    try use /dev/term/1

    It can be hardware problem. Try use tip -57600 /dev/term/1 and check for garbled characters.


    Can you clear you recive garbled characters or other side recive from you garbled characters ?


    Regards.
  • 2. Re: How to develop rs232 program?
    983469 Newbie
    Currently Being Moderated
    Thanks for your help.

    After modify these lines, it has been worked:
    #define MODEMDEVICE "/dev/term/1"

    ...
    /*
    newtio.c_cflag = BAUDRATE|CS8|CLOCAL|CREAD;
    newtio.c_iflag = IGNPAR;
    newtio.c_oflag = 0;
    newtio.c_lflag = ICANON;
    */
    Modify to below, reference this:
    https://groups.google.com/d/topic/comp.unix.solaris/qDh5mMgEd7g/discussion

    cfsetispeed(&newtio,BAUDRATE);
    cfsetospeed(&newtio,BAUDRATE);
    newtio.c_cflag |= CS8;
    newtio.c_cflag &= ~PARENB;
    newtio.c_cflag &= ~CSTOPB;
    newtio.c_cflag &= ~CSIZE;
    newtio.c_cflag &= ~CRTSCTS;
    newtio.c_cc[VMIN] = 1;
    newtio.c_cc[VTIME] = 0;

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points