I have an old program that needs to be updated, but I need to know what it is doing in the first place. Bought book The C programming language by Kernighan & Ritchie, but still need help. Here is the program:
#include<dos.h>
#include<stdio.h>
#define IER 1
#define MCR 4
#define DTR 1
#define RTS 2
#define LSR 5
#define RCVRDY 1
#define RX 0
#define OVRERR 2
#define PRTYERR 4
#define FRMERR 8
int portbase = 0x2f8
main()
{
FILE *handle;
register unsigned long i, j = OL;
/* I do not understand the j = OL */
register int c = 0, inpstat;
register int a[340];
outportb(portbase + IER, 0};
outportb(portbase + MCR, DTR | RTS;
/* I need help on both the above lines examples? */
handle = fopen("SAMPLE.DAT","w"
for(i=OL;i<17*7500;i++)
(
if(j >= 340) break;
instat = inportb(portbase + LSR);
if(inpstat & RCVRDY)
/*The bitwise & is confusing, help */
{
c = inportb(portbase + RX);
if(inpstat & (OVRERR | PRTYERR | FRMERR))
/*This line with & and | looses me totally */
{
printf("\b"
c = -1;
}
}
else
{
c = -1;
}
if( c != -1)
{
a[j] = c;
j++;
}
}
for(i=OL;i<j;i++)
/* What is the i=OL and does it have a value? */
{
fputc(a, handle);
}
fclose(handle);
}
The data comes into this program on com2 9600 baud, even parity, 7 data bits, 2 stop bits, if you could give an example of what is happening, I would greatly appreciate.
A stream of data from breakout (black box) looks like this
(02)* 0025 0000(0D)(00)
Thanks!
#include<dos.h>
#include<stdio.h>
#define IER 1
#define MCR 4
#define DTR 1
#define RTS 2
#define LSR 5
#define RCVRDY 1
#define RX 0
#define OVRERR 2
#define PRTYERR 4
#define FRMERR 8
int portbase = 0x2f8
main()
{
FILE *handle;
register unsigned long i, j = OL;
/* I do not understand the j = OL */
register int c = 0, inpstat;
register int a[340];
outportb(portbase + IER, 0};
outportb(portbase + MCR, DTR | RTS;
/* I need help on both the above lines examples? */
handle = fopen("SAMPLE.DAT","w"
for(i=OL;i<17*7500;i++)
(
if(j >= 340) break;
instat = inportb(portbase + LSR);
if(inpstat & RCVRDY)
/*The bitwise & is confusing, help */
{
c = inportb(portbase + RX);
if(inpstat & (OVRERR | PRTYERR | FRMERR))
/*This line with & and | looses me totally */
{
printf("\b"
c = -1;
}
}
else
{
c = -1;
}
if( c != -1)
{
a[j] = c;
j++;
}
}
for(i=OL;i<j;i++)
/* What is the i=OL and does it have a value? */
{
fputc(a, handle);
}
fclose(handle);
}
The data comes into this program on com2 9600 baud, even parity, 7 data bits, 2 stop bits, if you could give an example of what is happening, I would greatly appreciate.
A stream of data from breakout (black box) looks like this
(02)* 0025 0000(0D)(00)
Thanks!