Section 5
Page 5 - 54
HA243821
Issue 5 Mar 98
MODEL 346 INSTALLATION AND OPERATION MANUAL
5.7.9 C PROGRAM LISTING (Cont.)
/**************************************************************************
FUNCTION
:
SEND ADDRESS
DESCRIPTION
:
This routine sends the EOT character followed by group and unit
addresses to “port”. It is assumed that
addr contains GGUU in four
characters.
ARGUMENTS
:
port
= port offset.
addr
= pointer to address buffer.
RETURNS
:
Void
NOTES
:
**************************************************************************/
void send_address( int port, char *addr )
{
int i;
send_byte(port,EOT);
for(i=0;i<4;i++)
send_byte( port, *addr++ );
}
/**************************************************************************
FUNCTION
:
SELECT CMD
DESCRIPTION
:
This routine selects the 34X instrument
ARGUMENTS
:
port
= port offset.
addr
= pointer to instrument address (GGUU)
cmd
= pointer to command to be used
chan
= pointer to channel character
reply
= pointer to reply buffer
RETURNS
:
Should return ACK, but also NUL, ETX, EOT or NAK NOTES
**************************************************************************/
char select_cmd( int port, char *addr, char *cmd, char *chan, char *reply )
{
char bcc;
send_address(port,addr);
send_byte(port,STX);
send_byte(port,*chan);
bcc= *chan;
/*Initialises BCC*/
bcc ^= *cmd; /*XORs with first character*/
while( *cmd != NUL )
{
send_byte( port, *cmd++ );
/*XOR with subsequent characters*/
bcc ^= *cmd;
}
bcc ^=ETX;
/*XOR with ETX*/
send_byte(port,ETX);
/*Send ETX*/
send_byte(port,bcc);
/*Send BCC*/
return( get_reply( port, reply ));
/* return ACK or NAK */
}