Problems with communication via serial port

Problems with communication via serial port

Post by Klaus Schneid » Wed, 16 Sep 1998 04:00:00



Hi,

I'm trying to write a C program wich is to communicate with a Z80
mini-computer via serial port. Now, if I use the program with QNX,
everything works fine, but if I'm trying to use it with Linux,
no communication is possible. The data being transfered is useless.
(I've built in checksums) I guess it's because of the port
parameters, but I cannot figure out what to change. I have looked
into the man page and the programming document at
"http://dns.easysw.com/~mike/serial" but it's no use, it does not
work with Linux.
Please help!

Here's my code to set the port parameters:

        struct termios opts;

        if (tcgetattr(hSer,&opts)) {
                close(hSer);
                return -2;
        }
        /* Set I/O speed */
        cfsetispeed(&opts,B4800);
        cfsetospeed(&opts,B4800);

        /* No Parity */
        opts.c_cflag &= ~PARENB;

        /* 8 data bits, 2 stop bits
        opts.c_cflag &= ~CSIZE;
        opts.c_cflag |= CS8;
        opts.c_cflag |= CSTOPB;

        /* raw Input */
        opts.c_lflag &= ~(ICANON | ECHO | ISIG);

        /* no parity check (QNX: ISTRIP strips top bit not parity bit) */
        opts.c_iflag &= ~(INPCK | ISTRIP);

        /* no software flow control */
        opts.c_iflag &= ~(IXON | IXOFF);
        #ifndef linux
        opts.c_iflag &= ~IXANY; /* (IXANY undefined with QNX) */
        #endif

        /* raw output */
        opts.c_oflag &= ~OPOST;

        /* No extentions */
        opts.c_lflag &= ~IEXTEN;

        /* Now, set it */
        if (tcsetattr(hSer,TCSANOW,&opts) != 0) {
                close(hSer);
                return -2;
        }

Thanks,
Klaus

 
 
 

1. communication via serial port

Hi !
I must to learn how to communicate via serial port under LINUX.
I have never programed at low level.
If anyone can  give me advice how should I start (I mean what should I
do I first), I'll be very glad. Is there any www. , or mayby some book,
which will be helpful for me ?

        Thanks anybody who help me !
        Peter


    because I don't have enough time to read all nevs list.

2. Radeon 9500 opengl, mandrake 9.1 glibc2.3

3. Serial Port Communications via C Program

4. problem with syslog(), C function :(

5. How to set up serial port when programming serial communication

6. How do you format a disk?

7. One way ping

8. serial port communication problem with null modem

9. Solaris 8,9,10 serial consoles via serial port how to raise speed?

10. Serial communication via openbsd?

11. Serial Communication via Modems

12. Linux serial port communication - Need help!!!!!!!!!