Rs 232 pgm - Please help
Hi,
I am a newbie. I have to do Linux rs232 programming to connect a device. the device settings, 9600, 7 bit, 1 start bit, 1 stop bit, Even parity. I have written the below code. But there is no response. Please, .. someone help me. I am very much struck in this. ************************************************* struct termios newtio; struct timeval tv; int retval; char buf[255]; FD_ZERO(&read_set); tv.tv_sec = 5; tv.tv_usec = 0; fd=open("/dev/ttyAM1",O_RDWR | O_NOCTTY |O_NDELAY); if(fd < 0) { fprintf(stderr, "Unable to open /dev/ttyAM1"); exit(1); } fcntl(fd,F_SETFL,FNDELAY); cfsetispeed(&newtio,B9600); cfsetospeed(&newtio,B9600); newtio.c_cflag |= CREAD; newtio.c_cflag |= CLOCAL; newtio.c_cflag |= PARENB; newtio.c_cflag &= ~PARODD; newtio.c_cflag |= ~CSTOPB; newtio.c_cflag &= ~CSIZE; newtio.c_cflag |= CS7; newtio.c_cflag &= ~CRTSCTS; newtio.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL | IGNCR); newtio.c_lflag &= ~(ICANON | ECHO | ISIG ); newtio.c_oflag &= ~(OPOST | ONLCR | OCRNL | ONLRET); tcsetattr(fd,TCSANOW,&newtio); FD_SET(fd,&read_set); write(fd,&cmd,sizeof(cmd)); retval = select(fd+1,&read_set,NULL,NULL,&tv); if(retval) { printf("Data is available"); res=read(fd,buf,255); printf("\n"); printf("%d\n",res); for(i=0;i<res;i++) { printf("%x",buf[i]); } } else printf("No data within five seconds"); printf("retval=%d",retval); close(fd); ********************************************************** Regards, Madhi. |
possibly useful links
http://www.agsrhichome.bnl.gov/Contr...Ado_Digi_.html
http://lpccomp.bc.ca/remserial/ The following link looks quite promising: http://www.egr.msu.edu/classes/ece48...ote_wa-jiw.pdf This product includes a free trial period: http://www.dcbnet.com/notes/0006etherpathredirect.html Also try posting to justlinux.com if you haven't already. They seem quite well informed. |
All times are GMT -5. The time now is 06:48 PM. |