/* fossil driver header file fossil start je met bnu /F */ #include #include #include #include #include extern myport; #define doint int86(0x14, fosin, fosout) union REGS *fosin; union REGS *fosout; void crlf(void); void send_w(register int); void recvs(char *s, int); int recv(void); /* Fossil init */ int fosinit() { char tmp[10]; /* init register structs */ fosin = (union REGS *) malloc(sizeof(union REGS)); fosout = (union REGS *) malloc(sizeof(union REGS)); fosin->h.ah = 0x04; fosin->x.dx = myport; fosin->x.bx = 0x4f50; doint; sprintf(tmp, "%x", fosout->x.ax); if (strcmp(tmp, "1954")) { printf("\n error: Fossil not active"); return 1; } else printf("\n"); return 0; } void watchdog(int mode) { /* 1 enable; 0 disable */ fosin->h.ah = 0x14; fosin->h.al = mode; fosin->x.dx = myport; doint; } /* Check Carrier */ check_carrier() { fosin->h.ah = 0x03; fosin->x.dx = myport; doint; return ((fosout->x.ax & 128) == 128); } /* send a line */ void sendline(char *line, int mode) { /* mode 0: no crlf, 1: crlf after line, 2: crlf before line, 3: both */ /* 4: 2 crlfs before, no after */ if (mode >1) crlf(); if (mode >3) crlf(); while (*line) { fosin->h.ah = 0x01; fosin->h.al = *(line++); fosin->x.dx = myport; doint; } if (mode == 1 || mode == 3) crlf(); } void crlf(void) { send_w(0x0d); send_w(0x0a); } /* send and wait for ready buffer */ void send_w(register int c) { fosin->h.ah = 0x01; fosin->h.al = c; fosin->x.dx = myport; doint; } /* test for incoming char's "PEEK AHEAD" */ int recvscan(void) { fosin->h.ah = 0x0c; fosin->x.dx = myport; doint; return (fosout->x.ax != 0xffff); } /* wait for input char */ int recv(void) { fosin->h.ah = 0x02; fosin->x.dx = myport; doint; return fosout->h.al; } /* get n chars in s */ void recvs(char *s, int n) { register int i, c; for (i=0;i0) i--; } *(s+i) = '\0'; } /* get line in s */ void getline(char *s) { register int i=0, c=0; while(c!=13) { if ((c = recv()) != 8) /* bs */ { *s++ = c; send_w(c); i++; } else { send_w(0x08); *s--; i--; } } *(s+i) = '\0'; } /* set baudrate */ void setbaud(unsigned int rate) { unsigned basic =3; fosin->h.ah = 0x00; /* AL: 3 = 8/n/1 * lowest bits (decimal)* * drie high bits * 160 = 2400 } 192 = 4800 } 224 = 9600 } optellen met 3 dus. 32 = 38400 } */ switch(rate) { case 9600: fosin->h.al = basic +224; break; case 4800: fosin->h.al = basic +192; break; case 2400: fosin->h.al = basic +160; break; case 19200: fosin->h.al = basic;