@@ -27,7 +27,7 rs232port_t rs232open(char* psPortName) | |||
|
27 | 27 | { |
|
28 | 28 |
|
|
29 | 29 |
|
|
30 |
|
|
|
30 | fcntl((int)fd, F_SETFL, FNDELAY); | |
|
31 | 31 |
|
|
32 | 32 |
|
|
33 | 33 |
|
@@ -125,6 +125,10 int rs232setup(rs232port_t fd, int ChSiz | |||
|
125 | 125 | { |
|
126 | 126 | struct termios terminos; |
|
127 | 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 | 132 | cfsetispeed(&terminos, rs232cfspeed(BaudeRate)); |
|
129 | 133 | cfsetospeed(&terminos, rs232cfspeed(BaudeRate)); |
|
130 | 134 | terminos.c_cflag |= (CLOCAL | CREAD); |
@@ -483,13 +487,16 int rs232saferead(rs232port_t fd,char* d | |||
|
483 | 487 | { |
|
484 | 488 | int read=0; |
|
485 | 489 | int i=0; |
|
486 | for(i=0;i<100;i++) | |
|
490 | for(i=0;i<1000;i++) | |
|
487 | 491 | { |
|
488 | 492 | read = rs232read((int)fd,data,count); |
|
493 | //printf("read %d bytes\n",read); | |
|
494 | if(read==-1)read=0; | |
|
489 | 495 |
count |
|
490 | 496 | data+=read; |
|
491 | 497 | if(count==0) |
|
492 | 498 | return 0; |
|
499 | usleep(10); | |
|
493 | 500 | } |
|
494 | 501 | return -1; |
|
495 | 502 | } |
@@ -503,6 +510,8 int rs232safewrite(rs232port_t fd,char* | |||
|
503 | 510 | for(i=0;i<1000;i++) |
|
504 | 511 | { |
|
505 | 512 | written = rs232write((int)fd,data+written,count); |
|
513 | //printf("%d bytes written\n",written); | |
|
514 | if(written==-1)written=0; | |
|
506 | 515 | count-=written; |
|
507 | 516 | data+=written; |
|
508 | 517 | if(count==0) |
General Comments 0
You need to be logged in to leave comments.
Login now