48 | 8 4
8)
Once the host generates the query, please ensure that all query results are read (once NL is
received, meaning end) to avoid the conflict between the query and the loopback; similarly, the
host should also read all loopback characters before reading the query result.
9)
For some bus commands that take a long time to complete, such as offset, the host should
actively wait for, or respond to the user's keyboard input confirmation to synchronize the
execution of the previous command, to avoid the next command being ignored or errored
during command execution.
10)
Communication software programmed with DOS application software should run under the
pure DOS environment supporting serial port. If it is running under WINDOWS, it may cause
errors due to different management methods of serial port.
Serial Interface Program Example
The below example is a communication program written in C language and running in a pure DOS
environment,
the main function can be used by the user to expand the communication function
arbitrarily, while other sub-functions illustrate how to use the serial port for input and output of the
string.
#define PORT 0
#include "dos.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "conio.h"
void port_init( int port,unsigned char code );
int check_stat( int port ); /* read serial port state(16bit) */
void send_port( int port,char c ); /* send a character to serial port */
char read_port( int port ); /* recive a character form serial port */
void string_wr( char *ps ); /* write a string to serial port */
void string_rd( char *ps ); /* read a string from serial port */
char input[256];
/*
quary recieve bufer */
main()
{ port_init( PORT,0xe3 );/* initilize 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( "freq 10khz" );
string_wr( "func:imp:type rx;:func:smon on" );
string_wr( "voltage:level 500mv" );
}
/* write string to serial port */
void string_wr( char *ps )