I was asked to write a program which can receive data from the
mentioned device.
I've written such program in BASIC but won't run on any of the BASIC
for Windows compilers I've tried (liberty BASIC, BCC BASIC and others)
- I was specifically asked to write the utillity in BASIC.
I have two questions:
1. Does anyone know where to attain such a utilly (with or without the
source code) that is able to receive data from this device?
2. Can anyone (I realize BASIC is a dying language) try to compile
this and tell why my compilers won't? It been long since I've written
in BASIC but my syntax appears correct to me.
The compilers I've tried only claim for syntax error in many lines
that seem correct to me, also I've checked the language documentation
and it agrees with me - the compilers won't specify why it's a syntax
error which I find especially annoying!!!
Receving the data using ACK-NAK Protocol
10 AK$=CHR$(&H6)+CHR$(&HD)+CHR$(&HA) ' AK$=ACK CR LF - compiler
claims this line to be a syntax error and does specify why..
20 NK$=CHR$(&H15)+CHR$(&HD)+CHR$(&HA)
30 I=1
40 OPEN "c:\data.txt" FOR OUTPUT as #2
50 FIELD #2, 132 AS R$
60 OPEN "COM2:9600,N,8,2,CS0,DS0" FOR INPUT AS #1
70 PRINT #1,CHR$(&H5);CHR$(&HD);CHR$(&HA)
80 LINE INPUT #1,A$
90 IF LEFT$(A$,1)<>CHR$(&H6) THEN 70
100 LINE INPUT #1,RE$
110 IF INSTR(RE$,CHR$(&H4))<>0 THEN 200 - again syntax error
120 RE$=MID$(RE$,INSTR(RE$,CHR$(&H2))+1,INSTR(RE$,CHR$(&H3))-INSTR(RE$,CHR$(&H2))-1)
130 PRINT RE$
140 GOSUB 300
150 IF BC$<>RIGHT$(RE$,3) THEN PRINT #1,NK$; :GOTO 100
160 LSET R$=RE$
170 PUT #2,I
180 I=I+1
190 PRINT #1,AK$; :GOTO 100
200 LSET R$="EOF"
210 PUT #2,I
220 CLOSE #1,#2
230 END
300 'BCC CALC
310 P=LEN(RE$)-3
320 BCC=0
330 FOR J=1 TO P
340 BCC=BCC XOR ASC(MID$(RE$,J,1))
350 NEXT J
360 BC$=RIGHT$("000"+RIGHT$(STR$(BCC),LEN(STR$(BCC))-1),3)
370 RETURN
Many thanks to anyone who tries to help :)
You can also reply to my mailbox je...@cables.org.il