
Batch File Operation
Batch File OperationBatch File Operation
Batch File Operation
Manual and batch file control function and synta is identical.
There are three important considerations when using batch files:
1.
The switch doesn’t react instantly to commands. It
takes appro imately 1/20
th
of a second for the
crosspoint switch to complete a switching command.
To compensate for this, either use a delay command or
send a few null characters. Nulls are normally ignored
by RS-232 devices. At 9600 baud, 40 nulls are required.
Be sure to insert a delay between the ~ attention
characters to enable the switch. You can disable this
delay to simplify your batch file and speed up
switching. Do this only if you’re certain the two
attention characters will not be inadvertently sent in the
data stream.
2.
The e act synta of a command is important. For
e ample, “Echo ~>COM1” and “ECHO ~ >COM1”
opened as a stream I/O device using stdio:
details. Once a port is set up, a com port can be
Type mode /? in at command line prompt for full
stop 1" )
system( "mode com1: baud 9600 parity n data 8
command in a system() function call:
he mode
In Windows, you can configure a serial port using t
Pro rams
Pro ramsPro rams
Communicatin from Pro rams
Communicatin from Communicatin from
Communicatin from
transmit simultaneously to multiple ports.
ay
Again, only one port can “listen” at a time. You m
3.
output string.
the
strlen(str)) instead of fprintf() which will buffer
, str,
program, it’s sometimes desirable to use write(port
n a
0 20 after the ~ in the second e ample. From withi
er
are different. Windows will send the space charact
evfs.html
http://www.atnf.csiro.au/people/rgooch/linu /docs/d
For Linu serial communications, try:
-us/dnfiles/html/msdn_serial.asp
library/en
http://msdn.microsoft.com/library/default.asp?url=/
information on W32 serial communications, see:
For
simpler stdio function works for many applications.
ut the
comprehensive low level functions for serial I/O, b
s
You can also use C++ fstream I/O. The Win32 API ha
printf( menuresponse ) ;
/* you’re in to the menu, send commands next */
fgets( menuresponse, sizeof( response ), portfp ) ;
fprintf( portfp, "~" ) ; /*send second tilde */
Delay (500); /* wait 500ms */
fprintf( portfp, "~" ) ; /*send tilde */
FILE* portfp fopen( "com1:", "w+" ) ;
char menuresponse[128] ;