B&B Electronics ADAM-4521 - Manual User Manual
Page 7

void send()
{
static int i,flag;
i=strlen(cmd);
cmd[i]=0x0a; /* HP-34401A uses LF(0x0a) as the end of an incoming command. */
cmd[i+1]=0x0d;
i=0;
flag=1;
while (flag)
{
outportb(base0,cmd[i]); /* Send data */
while((inportb(base0+5)& 0x40)!=0x40);
if(cmd[i] == 0x0d)
flag=0;
i++;
}
while( (inportb(base0+5)&0x40)
!=0x40);
}
void receive(void)
{
int i,flag;
long int timeout;
i=0;
flag=1;
timeout=TIME_OUT;
while (flag)
{
/* Check receiver data */
if ((inportb(base0+5) & 1) !=0)
{
rec[i]=inportb(base0); /* Receive data */
if(rec[i] == 0x0a)/* HP34401A uses 0x0a as the end of an outgoing command. */
rec[i+1]='\0';
flag=0;
printf("\nReceived data : %s",rec);
}
i++;
}
else
{
/* Check timeout */
timeout--;
if (timeout == 0)
{
flag = 0;
printf("\nTimeout error\n");
}
}
}
}
O u t p u t
Input string:
Timeout error
Input string:
Received data:
Input string:
Received data:
Input string:
Received data:
{02:SYST:REM
(Put the multimeter into remote operation mode.)
{02*IDN?
(Read the multimeter ID.)
HEWLETT-PACKARD,34401A,0,3-1-1
{02:SYST:VERS?
(Ask what version of SCPI the multimeter conforms to.)
1991.0
{02:READ?
+6.91849000E-04
(Trigger the readings, and read the results.)
ADAM-4521 User's Manual