beautypg.com

Rs-232, Programming example, Appendix b – AMETEK SLM-1 User Manual

Page 61

background image

APPENDIX B

RS-232

PROGRAMMING EXAMPLE

C Language Interface for DOS Handlers " pd_rs232.c "


#include
#include
#include
#include

#define COMPTR 44

/* command array pointer */

#define QUELEN 1024

/* size of seriel input */

#define SUCCESS 0

/* return value variable for success */

#define OPER_ERR -1

/* operate error */

#define TIME_OUT 1

/* time_out */

int input_index = 0;

/* index of seriel input buffer */

int rd_result = 0;

/* return value variable of pd_rd() */

int timeout = 0;

/* timeout flag */

char queue[QUELEN];

/* seriel input buffer */

int ACE_DATA_REG;

/* ACIA data register */

int ACE_INT_ENB_REG;

/* ACIA interrupt enable register */

int ACE_INT_IDENT_REG;

/* ACIA interrupt identification register*/

int ACE_LINE_CTL_REG;

/* ACIA line control register */

int ACE_MODEM_CTL_REG;

/* ACIA modem control register*/

int ACE_LINE_STAT_REG;

/* ACIA line status register */

int ACE_MODEM_STAT_REG;

/* ACIA modem status register */

int COM_INT_NUM;

/* ACIA communication port interrupt number*/

int IRQ_MASK;

/* IRQ mask for PC IRQ flag */

void pd_loc(void);

/* function of disable interrupt routine */

void pd_rem(void);

/* function of enable interrupt routine */

int pd_init(int);

/* function of initial communication port*/

int pd_wrt(char *,int);

/* function of write to device */

int pd_rd(char *,int);

/* function of read from device */

int read_buf(void);
int pd_meas(char *,char*, int, int);

#define PIC_CTL_REG 0x20

/* 8259A PIC control register */

#define PIC_INT_MASK_REG 0x21 /* 8259A PIC interrupt mask register */
#define NON_SPEC_EOI 0x20

/* non-spacific end of interrupt */

#define CTS 0x10

/* clear to send */

#define DSR 0x20

/* data set ready */

#define RI 0x40

/* ring indicator */

#define DCD 0x80

/* data carrier detect */

#define DCTS 1

/* delta clear to send */

#define DDSR 2

/* delta data set ready */

#define TERI 4

/* trailing edge ring detect */

#define DDCD 8

/* delta data carrier detect */

#define OE 2

/* overrun error */

M540070-01 Rev B

B-1