home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
382.lha
/
ST
/
st.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-05
|
2KB
|
99 lines
/* ST.c : Serial Test */
/* Created by John Schultz, 4/16/90 */
/* Interrupt driven serial I/O testbed */
#include <stdio.h>
#include <dos.h>
#include "input.h"
#define CLOCK 3579545
#define MINBAUD 300 /* Change these at will */
#define MAXBAUD 230000
#define BUFFSIZE 80
#define ESCAPE 69
extern void openserial(void);
extern void __asm sendser(register __d0 char c);
extern void __asm sendsernobuff(register __d0 char c);
extern char __asm readser(void);
extern short __asm checkser(void);
extern char __asm rawtoascii(register __d0 char c);
extern short far baudper;
void main(int argc,char ** argv) {
short i = 0;
long console;
long baud;
char traw;
short notquit = 1;
char buffer[BUFFSIZE];
if (argc != 2) {
printf("USAGE: st <baud>\n");
exit(0);
}
baud = atoi(argv[1]);
if (baud < MINBAUD)
baud = MINBAUD;
else if (baud > MAXBAUD)
baud = MAXBAUD;
printf("Setting baud to %d. Press ESC to quit.\n",baud);
baudper = (CLOCK / baud)-1;
console = _dopen("*",MODE_OLDFILE);
if (console == -1) {
printf("Couldn't open console.\n");
exit(0);
}
if (createti()) {
openserial();
traw = 0;
raw = 0;
while (notquit) {
if (raw) {
traw = raw;
raw = 0;
if (traw == ESCAPE) notquit = 0; /* ESC */
traw = rawtoascii(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
sendser(traw);
}
if (checkser())
for (i = 0;
(i < BUFFSIZE) && (checkser());
buffer[i++] = readser());
if (i > 0) _dwrite(console,buffer,i);
i = 0;
} /* while notquit */
closeserial();
deleteti();
} /* if createti */
printf("\n");
} /* END ST.c */