|
|
|
Serial interface problem (ttyS0) | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
|
Dear all,
I'm still running Linux (2.6.23) on Toradex (PXA270) module.
I experienced problem when receivning data at lower baudrate then
initialized
ttyS0 is initialized at 38400bps and incoming data (NMEA stream) is coming
at 19200bps
In this case kernel crash with "Out of memory" message.
Here is sample of program:
void main(int argc, char *argv[])
{
int hPort;
struct termios tio;
hPort=open("/dev/ttyS0",O_RDWR|O_NOCTTY|O_NDELAY|O_NONBLOCK);
if(hPort!=INVALID_HANDLE_VALUE) {
if(tcgetattr(hPort,&tio)==0) {
tio.c_cflag|=(CLOCAL | CREAD);
cfsetispeed(&tio,B38400);
cfsetospeed(&tio,B38400);
tio.c_cflag&=~CRTSCTS;
tio.c_iflag&=~(IXON | IXOFF | IXANY | INLCR | IGNCR | ICRNL | IUCLC);
tio.c_lflag&=~(ICANON | ECHO | ECHOE | ISIG);
tio.c_oflag&=~(OPOST | ONLCR | OCRNL );
tio.c_cflag&=~(CSIZE | PARENB | PARODD | CSTOPB);
tio.c_cflag&=~PARENB;
tio.c_iflag&=~(INPCK | ISTRIP);
tio.c_cflag&=~CSTOPB;
tio.c_cflag|=CS8;
if(tcsetattr(hPort,TCSANOW, &tio)==0) {
printf("Comm opened ok!\r\n");
int iRead;
BYTE buf[100];
for(int i=0;i<10;i++) {
memset(buf,0,sizeof(buf));
iRead=read(hPort,buf,sizeof(buf)-1);
if(iRead)
printf("read out:%s\r\n",buf);
else
printf("no char\r\n");
sleep(1);
}
close(hPort);
return 0;
}
}
close(hPort);
}
return 0;
}
Am I doing something wrong during initialization. I will post dmesg log in
next post.
Many thanks
Erazem
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
[Linux ARM] [Linux ARM MSM] [Linux ARM Kernel] [Fedora ARM] [IETF Annouce] [Security] [Bugtraq] [Linux] [Linux OMAP] [Linux MIPS] [ECOS] [Asterisk Internet PBX] [Linux API]
![]() |
![]() |