Agilent Technologies 34401A Camera Accessories User Manual


 
RS-232 Operation Using Turbo C
The following example shows how to program an AT personal computer
for interrupt-driven
COM port communications. SCPI commands can be
sent to the Agilent 34401A and responses received for commands that
query information. The following program is written in Turbo C and can
be easily modified for use with Microsoft
â
Quick C.
#include <bios.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#define EVEN_7 (0x18 | 0x02 | 0x04) /* Even parity, 7 data, 2 stop */
#define ODD_7 (0x08 | 0x02 | 0x04) /* Odd parity, 7 data, 2 stop */
#define NONE_8 (0x00 | 0x03 | 0x04) /* None parity, 8 data, 2 stop */
#define BAUD300 0x40
#define BAUD600 0x60
#define BAUD1200 0x80
#define BAUD2400 0xA0
#define BAUD4800 0xC0
#define BAUD9600 0xE0
/* 8250 UART Registers */
#define COM 0x3F8 /* COM1 base port address */
#define THR COM+0 /* LCR bit 7 = 0 */
#define RDR COM+0 /* LCR bit 7 = 0 */
#define IER COM+1 /* LCR bit 7 = 0 */
#define IIR COM+2 /* The rest are don’t care for bit 7 */
#define LCR COM+3
#define MCR COM+4
#define LSR COM+5
#define MSR COM+6
RS-232 Operation Using Turbo C
Microsoft is a U.S. registered trademark of Microsoft Corporation.
Continued on next page >
6
Chapter 6 Application Programs
RS-232 Operation Using Turbo C
193