S p e z i a l e l e k t r o n i k G m b H
iseg Spezialelektronik GmbH
Email: [email protected]
Phone ++ 49 351 / 26 996 - 0
Bautzner Landstr. 23
http://www.iseg-hv.com
Fax
++ 49 351 / 26 996 - 21
D - 01454 Radeberg / Rossendorf
Germany
9
7. Program example
/***************************************************************************************************/
/*
*/
/*
ehq.cpp
*/
/*
*/
/*
example program for iseg ehq hv boards, written by Jens Römer, 27.2.97
*/
/*
*/
/*
this code was compiled under BC, please contact iseg for the source file */
/*
*/
/***************************************************************************************************/
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include "int14.h"
// COM2 handling
const
etx= 0x03;
const
f = 0x0a;
const
cr = 0x0d;
unsigned
char readU[]={'U','1',cr,lf,etx};
//read voltage
unsigned
char sendU[]={'D','1','=','1','0',cr,lf,etx};
//set voltage to 10V
unsigned
char *ptr;
unsigned
char rby;
int
i, cnt;
boolean ok;
void main(void)
{
clrscr();
COM2_init();
COM2_set(9600);
// COM2:
9600 baud, 8 databits, no parity, 1 stopbit
ok=True_;
ptr=readU;
for (;;)
{
if (*ptr==etx) break;
COM2_send(*ptr);
//send one byte
rby=COM2_read();
//read one byte
if (rby!=*(ptr++)) ok=False_;
//compare sent with read data
else switch (rby)
{
case lf : printf("%c",lf); break;
case cr : printf("%c",cr); break;
default : printf("%c",rby); break;
}
if (ok==False_)
{
printf("No coincident read data found!");
exit(1);
}
}
cnt=8;
do
{
rby=COM2_read();
//read voltage data
switch (rby)
{
case lf : printf("%c",lf); break;
case cr : printf("%c",cr); break;
default : printf("%c",rby); break;
}
cnt--;
} while (cnt>=1);
}