Rs-232 Operation Using Turbo C - HP 34401A User Manual

Hide thumbs Also See for 34401A:
Table of Contents

Advertisement

Chapter 6 Application Programs

RS-232 Operation Using Turbo C

RS-232 Operation Using Turbo C (continued)
printf("\nEnter command string:\n");
gets(command); strcat(command,"\n");
if(command[0] == 0x19) send_ctlc();
else if(command[0] != 'q') {
for(i=0; i<strlen(command); i++) {
/* Wait for DSR and transmitter hold register empty */
while(!(inportb(LSR) & inportb(MSR) & 0x20)) ;
outportb(THR,command[i]);
}
}
if(strpbrk(command,"?")) {
c = 0;
do {
while(int_buf_count && !kbhit()) {
putch(c = *int_buf_out++); int_buf_count--;
if(int_buf_out >= int_buf + INT_BUF_size) int_buf_out = int_buf;
}
if(kbhit()) {
if(getch() == 0x19) send_ctlc();
c = 0xa;
}
}
while(c != 0xa);
}
/* End if */
}
while(command[0] != 'q');
outportb(IER,inportb(IER) & 0xfe);
outportb(MCR,0x1);
/* Disable IRQ4 in 8259 interrupt controller register */
outportb(INT_controller+1,inportb(INT_controller+1) | ~IRQ4_enab);
setvect(IRQ4_int,oldvect);
return(0);
}
Continued on next page ’
/* SCPI requires line feed */
/* If ^Y then send ^C */
/* Send character */
/* If query then get response */
/* if ^Y then send ^C */
/* Terminate loop */
/* 'q' to quit program */
/* Disable UART interrupt */
/* Disable IRQ buffer, DTR = 1 */
/* Restore old interrupt vector */
6
195

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents