*** h8write.c.orig Sun Jan 19 00:00:00 2003 --- h8write.c Sat Nov 6 21:11:22 2021 *************** *** 1,4 **** ! #define LINUX #undef Solaris #undef FreeBSD #undef Win32 --- 1,5 ---- ! #define OpenBSD ! #undef LINUX #undef Solaris #undef FreeBSD #undef Win32 *************** *** 16,21 **** --- 17,23 ---- #include #include #include + #include #endif #define VER "1.0.0" *************** *** 47,52 **** --- 49,57 ---- #ifdef Solaris #define RSLINE "/dev/cua/b" #endif + #ifdef OpenBSD + #define RSLINE "/dev/tty00" + #endif /* Wait timinig for each char send. In milli second. *************** *** 811,816 **** --- 816,839 ---- } while(s < 1); return (unsigned char)buf[0]; } + + void wait_for_stable(void) { + char buf[2]; + int i; + + for(i = 0; i < 10;) { + if(read(TheFd, buf, 1) == -1) { + if(errno == EAGAIN) { + usleep(100); + i++; + } else { + error_print(FATAL,ERR_READLINE,NULL); + } + } else { + i = 0; + } + } + } #endif void putbyte(int c) { *************** *** 869,875 **** snprintf(buf,sizeof(buf),"Try to set speed : %d [bps]\n",rate); error_print(FATAL,ERR_LINESPEED,buf); } ! if((TheFd=open( sPort , O_RDWR)) == -1){ error_print(FATAL,ERR_OPENLINE,sPort); } tcsetpgrp(TheFd, getpgrp()); --- 892,898 ---- snprintf(buf,sizeof(buf),"Try to set speed : %d [bps]\n",rate); error_print(FATAL,ERR_LINESPEED,buf); } ! if((TheFd=open( sPort , O_RDWR|O_NDELAY)) < 0){ error_print(FATAL,ERR_OPENLINE,sPort); } tcsetpgrp(TheFd, getpgrp()); *************** *** 929,934 **** --- 952,962 ---- TheTty.c_cflag |= HUPCL | CLOCAL ; if(tcsetattr(TheFd, TCSANOW, &TheTty ) == -1){ error_print(FATAL,ERR_INITLINE,NULL); + } + + wait_for_stable(); + if((TheFd=open( sPort , O_RDWR)) < 0){ + error_print(FATAL,ERR_OPENLINE,sPort); } #endif }