Category : Files from Magazines
Archive   : CGAZ3-1.ZIP
Filename : SERIAL.C

 
Output of file : SERIAL.C contained in archive : CGAZ3-1.ZIP
/*********************************************************************
* File: serial.c (part of TTYTALK)
* Author: Victor Volkman
* Date: June, 1988
********************************************************************/
#include "tty.h"

extern struct serial_def serial;

int iobase;
int r_errs;
int q_errs;
QUEUE inq;


void comm_setup()
{
union REGS r;

r.h.ah = 0; /* Set comm parameters */
r.h.al = (serial.ibaud_rate<<5) + (serial.parity<<3) +
(serial.stopbits<<2) + (serial.data);
r.x.dx = serial.adapter;
intsoff();
int86(RS232_INT, &r, &r); /* BIOS communications */
intson();
}


int rcv_char()
{
r_errs += (inp(iobase+LINE_STATUS) & RCV_ERRS) != 0;
return (int) inp(iobase+RCV_DATA);
}


int chk_xmt()
{
return (int) inp(iobase+LINE_STATUS) & XMT_RDY;
}


void xmt_char(chr)
int chr;
{
outp(iobase+XMT_DATA,chr);
}


void send_char(chr)
int chr;
{
while (!chk_xmt());
xmt_char(chr);
}


void send_dial_string(str)
char *str;
{
while (*str != '\0') {
if (*str=='|') /* xlate as CR */
send_char(CHAR_CR);
else if (*str == '^') { /* xlate ctrl char */
send_char(toupper(str[1]) - 'A' + 1);
str++;
}
else if (*str == '~') /* wait 1 second */
wait_tick(18);
else /* actual char */
send_char(*str);
str++;
}
}


void xmt_brk()
{
int ctl;

ctl = inp(iobase+LINE_CTRL) | SET_BRK_BIT;
outp(iobase+LINE_CTRL, ctl);
}


void end_brk()
{
int ctl;

ctl = inp(iobase+LINE_CTRL) & (~SET_BRK_BIT);
outp(iobase+LINE_CTRL, ctl);
}


void send_brk(ticks)
int ticks;
{
xmt_brk(); /* set BREAK bit */
wait_tick(ticks);
end_brk(); /* clear BREAK bit */
}


void wait_tick(clocks) /* wait for specified number of ticks */
int clocks;
{
union REGS r;
long now, end;

r.h.ah = 0; /* Read time of day */
int86(TICK_INT, &r, &r); /* BIOS time of day */
now = r.x.cx<<16 + r.x.dx; /* compute ticks since midnight */
end = now + clocks;
while (now < end) {
r.h.ah = 0;
int86(TICK_INT, &r, &r); /* BIOS time of day */
now = r.x.cx<<16 + r.x.dx;
if (r.h.al) now += 1573040L; /* Rollover clock after midnight*/
}
}


  3 Responses to “Category : Files from Magazines
Archive   : CGAZ3-1.ZIP
Filename : SERIAL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/