LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Serial Programming on an i486 (https://www.linuxquestions.org/questions/programming-9/serial-programming-on-an-i486-9009/)

Sree 11-21-2001 02:39 AM

Serial Programming on an i486
 
hi all,

This is my first posting.
Here I have a problem related with linux serial programming
in C.Hope u can help me in this.

I have a C program that communicates with a remote terminal
unit via serial port.The program uses termios structure to initialise
the port.
The program works as expected in kernel
version 2.4.2-2 on an i686 macine.

This same program when tested on a 586 (Kernel 2.2.14-12 on an i586)
machine fails to read the port properly.
Writing to the port was working properly.
The setserial and stty commands produced the same result on both machines.

Later i found that minicom(communicating with hyperterminal in windows) also
showed the same problem while reading the port on the 486 macine.
Writing to the port was working properly.
Communication was proper when hyperterminal was used on
both sides.




Here is the o/p of the setserial command.

/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test

and here is the settings on the port using stty command while my program is
running.



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 nl0 cr0 tab0 bs0 vt0
ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke


If anybody knows what is creating the problem...
please do help..

regards,
sree

Lazarus 12-10-2001 06:13 AM

If this is any help wrote a process that communicates with a device I have that receives teletext data. I use /dev/ttyS0 for this.

I use this procedure to set up the port.

ttext_setraw()
{
if(ttext_debug) printf("\nEntering setraw\n");
if(ioctl(fp,TCGETA,&tbuf) == -1)
{
printf("\n\nSetraw IOCTL error fp = %d\n\n",fp);
close(fp);
delay(2);
longjmp(serial_fail,0);
}
tbuf.c_iflag &=~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT);
tbuf.c_oflag &=~OPOST;
tbuf.c_lflag &=~(ICANON | ISIG | ECHO);
tbuf.c_cflag &= (B9600 | CS8 | CLOCAL | CREAD );
tbuf.c_cc[4]=1; /* min */
tbuf.c_cc[5]=2; /* time was 2 */
if(ioctl(fp,TCSETAF,&tbuf) == -1)
{
fprintf(outptr,"\nsetraw failed to set IOCTL attributes\n");
fflush(outptr);
return(-1);
}
if(ttext_debug) printf("\nLeaving setraw\n");
return(0);
}

I read the serial port thus read(fp,&ic,1)
and write to it write(fp,&ic,1)

I open the port thus

fp=open("/dev/ttyS0",O_RDWR | O_NONBLOCK );

I hope this points you in the right direction.

pinoy 12-10-2001 01:37 PM

Are you connecting two computers directly? Make sure you have the proper cross-over cables.

narinder 07-03-2003 06:09 AM

May be a bit useful
 
hi ,
I am also trying to communicater over serial port and i am able to do it sucessfully but sometimes i am getting overrun error( once in 15-20 transactions). I am using inb(port) and outb(port) to read and write a byte on the serial port. If this information is anyhow helpful to you its ok and if you knw how to get rid of this overrun error please let me knw.
and one personal question " are you sreejith ?" as ur nick name being SREE

captainstorm 07-03-2003 07:35 AM

I remember there was a howto named "serial port howto mini" some where available on the internet.

captainstorm 07-03-2003 07:36 AM

Yeah, find on http://www.tldp.org/HOWTO/HOWTO-INDEX/howtos.html


All times are GMT -5. The time now is 03:24 AM.