##// END OF EJS Templates
Improved beaglebone support.
jeandet -
r36:566051021c9c alexis
parent child
Show More
@@ -25,14 +25,14 rs232speed_t rs232cfspeed(unsigned int B
25
25
26 rs232port_t rs232open(char* psPortName)
26 rs232port_t rs232open(char* psPortName)
27 {
27 {
28 rs232port_t fd;
28 rs232port_t fd;
29 fd = (rs232port_t)open(psPortName, O_RDWR | O_NOCTTY | O_NDELAY);
29 fd = (rs232port_t)open(psPortName, O_RDWR | O_NOCTTY | O_NDELAY);
30 fcntl((int)fd, F_SETFL, 0);
30 fcntl((int)fd, F_SETFL, FNDELAY);
31 //fd = open(psPortName, O_RDWR | O_NOCTTY);
31 //fd = open(psPortName, O_RDWR | O_NOCTTY);
32 #ifdef debug
32 #ifdef debug
33 if(fd==-1)printf("can't open Port\n");
33 if(fd==-1)printf("can't open Port\n");
34 #endif
34 #endif
35 return fd;
35 return fd;
36 }
36 }
37
37
38 int rs232close(rs232port_t fd)
38 int rs232close(rs232port_t fd)
@@ -125,6 +125,10 int rs232setup(rs232port_t fd, int ChSiz
125 {
125 {
126 struct termios terminos;
126 struct termios terminos;
127 tcgetattr(fd, &terminos);
127 tcgetattr(fd, &terminos);
128 terminos.c_iflag=0;
129 terminos.c_oflag=0;
130 terminos.c_cflag=0;
131 terminos.c_lflag=0;
128 cfsetispeed(&terminos, rs232cfspeed(BaudeRate));
132 cfsetispeed(&terminos, rs232cfspeed(BaudeRate));
129 cfsetospeed(&terminos, rs232cfspeed(BaudeRate));
133 cfsetospeed(&terminos, rs232cfspeed(BaudeRate));
130 terminos.c_cflag |= (CLOCAL | CREAD);
134 terminos.c_cflag |= (CLOCAL | CREAD);
@@ -483,13 +487,16 int rs232saferead(rs232port_t fd,char* d
483 {
487 {
484 int read=0;
488 int read=0;
485 int i=0;
489 int i=0;
486 for(i=0;i<100;i++)
490 for(i=0;i<1000;i++)
487 {
491 {
488 read = rs232read((int)fd,data,count);
492 read = rs232read((int)fd,data,count);
489 count -=read;
493 //printf("read %d bytes\n",read);
494 if(read==-1)read=0;
495 count-=read;
490 data+=read;
496 data+=read;
491 if(count==0)
497 if(count==0)
492 return 0;
498 return 0;
499 usleep(10);
493 }
500 }
494 return -1;
501 return -1;
495 }
502 }
@@ -503,6 +510,8 int rs232safewrite(rs232port_t fd,char*
503 for(i=0;i<1000;i++)
510 for(i=0;i<1000;i++)
504 {
511 {
505 written = rs232write((int)fd,data+written,count);
512 written = rs232write((int)fd,data+written,count);
513 //printf("%d bytes written\n",written);
514 if(written==-1)written=0;
506 count-=written;
515 count-=written;
507 data+=written;
516 data+=written;
508 if(count==0)
517 if(count==0)
General Comments 0
You need to be logged in to leave comments. Login now