Guest_imported
New member
- Jan 1, 1970
- 0
A programer wrote the following program which reads the weight from the scales. He graduated from school & left. We now want to add a second scale, but the data stream is different and takes forever to read. Our foxpro programmer does not know C. I need to know what program to use & what to change to read data stream correctly.
#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;
register int c = 0, inpstat;
register int a[340];
outportb(portbase + IER, 0);
outportb(portbase + MCR, DTR : RTS);
handle = fopen("SAMPLE.DAT","w"
for(i=OL;i<17*7500;i++)
{
if(j >= 340) break;
inpstat = inportb(portbase + LSR);
if(inpstat & RCVRDY)
{
c = inportb(portbase + RX);
if(inpstat & (OVRERR : PRTYERR : FRMERR))
{
printf("\b"
c = -1;
}
}
else
{
c = -1;
}
if( c != -1)
{
a[j] = c;
j++;
}
}
for(i=OL;i<j;i++)
{
fputc(a,handle);
}
fclose(handle);
}
The output for this program in the sample.dat file looks like this
[][]* 0042 0000
The new scales output looks like this
[] 000042LG
[] 000042LG (there are 19 of the [] 000042LG)
[]
Any help appreciated!
#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;
register int c = 0, inpstat;
register int a[340];
outportb(portbase + IER, 0);
outportb(portbase + MCR, DTR : RTS);
handle = fopen("SAMPLE.DAT","w"
for(i=OL;i<17*7500;i++)
{
if(j >= 340) break;
inpstat = inportb(portbase + LSR);
if(inpstat & RCVRDY)
{
c = inportb(portbase + RX);
if(inpstat & (OVRERR : PRTYERR : FRMERR))
{
printf("\b"
c = -1;
}
}
else
{
c = -1;
}
if( c != -1)
{
a[j] = c;
j++;
}
}
for(i=OL;i<j;i++)
{
fputc(a,handle);
}
fclose(handle);
}
The output for this program in the sample.dat file looks like this
[][]* 0042 0000
The new scales output looks like this
[] 000042LG
[] 000042LG (there are 19 of the [] 000042LG)
[]
Any help appreciated!