133
of 148
EOT$ = CHR$(4)
ACK$ = CHR$(6)
NAK$ = CHR$(21)
LF$ = CHR$(10)
PRINT #3, EOT$
‘Switch device to master mode
StartEmpfang:
ant$ = " "
‘Delete response string
stri$ = " "
‘Delete measurement-value string
ant$ = INPUT$(1, #3)
WHILE (ant$ <> ETX$) AND (ant$ <> EOT$) ‘While ETX or EOT is not received
IF ant$ >= CHR$(32) THEN ‘If no special characters are present
stri$ = stri$ + ant$ ‘Form Status String
END IF
ant$ = INPUT$(1, #3
‘Read in character from RS232
WEND
IF (ant$ = EOT$) THEN
‘If EOT is received
EXIT SUB
‘End Sub
ELSE
antwort$ = stri$
‘Save response
PRINT #3, ACK$
‘Acknowledge
GOTO StartEmpfang
‘Read in again until EOT is received
END IF
END SUB
FUNCTION CmdSenden (cmd$)
‘****************************************************************************************************************************************
‘Send command to 2329
‘****************************************************************************************************************************************
DIM ant$(100)
DIM msg$(100)
REM
Special characters are defined here
STX$ = CHR$(2)
ETX$ = CHR$(3)
EOT$ = CHR$(4)
ACK$ = CHR$(6)
NAK$ = CHR$(21)
LF$ =
CHR$(10)
msg$ = STX$ + cmd$ + LF$ + ETX$ ‘Formulate command
PRINT #3, msg$
‘Send command
‘Wait for acknowledgement
ant$ = " "
‘Delete response string
ant$ = INPUT$(1, #3)
‘Read in response
IF (ant$ <> ACK$) THEN
‘If not ACK
PRINT "Gerät antwortet mit NAK "
‘Display error message
CmdSenden = 0
‘Error during transmission
ELSE
CmdSenden = 1
‘Transmission OK
END IF
‘End of If statement
END FUNCTION