Chapter 8 Program Examples - Aktakom ABM-4082 User Manual

5 1/2 digit multimeter
Table of Contents

Advertisement

Chapter 8
Serial Interface Program
The following example is a communication program. It is programmed with C Language and working in
DOS environment. Where the MAIN Function could be extended for communication functions by users and
other sub functions show you how to input and output character strings using serial interfaces.
#define PORT 0
#include "dos.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "string.h"
#include "conio.h"
void port_init( int port,unsigned char code );
int check_stat( int port );
void send_port( int port,char c );
char read_port( int port );
void string_wr( char *ps );
void string_rd( char *ps );
char input[256];
main()
{ port_init( PORT,0xe3 );/* initialize serial port:baud = 9600,no verify,1 bit stop,8 bit data */
string_wr( "trig:sour bus;*trg" );
string_rd( input );
printf( "\n%s",input );
string_wr( "volt:dc:rang 1.0" );
string_wr( "func 'volt:ac' );
}
/* write string to serial port */
void string_wr( char *ps )
{ char c;
int m,n;
while( check_stat(PORT) & 256) read_port(PORT);/* read data until null */
for( ;*ps; )
{ c = 0;
Program Examples
/* read serial port state(16bit) */
/* send a character to serial port */
/* receive a character form serial port */
/* write a string to serial port */
/* read a string from serial port */
/* query receive buffer */
ABM-4082
101

Advertisement

Table of Contents
loading

Table of Contents