Nemis, I took your code and worked on it a bit to make the parameter lookup file driven. It's a hack at the moment, as I was having trouble declaring array variables to be global (been a very long time since I programmed BASIC).
- Code: Select all
REM Code initiated by Nemis
REM thank you colby for start tread on nasioc
REM thank you Visceral for help in programming
REM thank you numbles for find file subaruecu.htm
DEF SEG = 0
REM address of COM port (p)
REM Typical address
REM &H3F8 = COM1
REM &H2F8 = COM2
DIM response(100)
SUB LookupLabel(index, value)
PRINT "In LookupLabel "; index; " " ;value
DIM labels$(100)
k = 0
WHILE NOT EOF(1)
INPUT #1, labels$(k)
REM PRINT "Read: "; labels$(k)
k = k + 1
WEND
CLOSE #1
lindex = 0
WHILE lindex < 8
IF value MOD 2 = 1 THEN
REM PRINT "1"
value = (value-1)/2
ELSE
REM PRINT "0"
value = value/2
END IF
lindex = lindex + 1
WEND
END SUB
PRINT "Begin"
p = &H3F8
dllb = p + 0
dlhb = p + 1
ier = p + 1
fcr = p + 2
lcr = p + 3
mcr = p + 4
lsr = p + 5
REM clear buffers & enable FIFO
OUT fcr, 7
REM cancel interupts
OUT ier, 0
REM set MCR rts low(on logic 1 -v), dtr-high(off logic 0 +V)
OUT mcr, 1
REM set baud rate 4800
PRINT "Changing to 4800 baud"
OUT lcr, (INP(lcr) OR 128)
OUT dllb, &H18
OUT dlhb, 0
OUT lcr, (INP(lcr) AND 127)
REM set 8bit no parity
lcrbits = INP(lcr)
REM set 8 data bits xxxxxx11
lcrbits = lcrbits OR 3
REM set None parity xxxx0xxx
lcrbits = lcrbits AND (255 - 8)
REM set 1 Stop bit xxxxx0xx
lcrbits = lcrbits AND (255 - 4)
REM set 0 (off) Break Enable x0xxxxxx
lcrbits = lcrbits AND (255 - 64)
OUT lcr, lcrbits
PRINT "Clear buffer"
DO
c = INP(lsr) AND 1
DELAY 1
LOOP WHILE c > 0
PRINT "Done"
REM send initialization string
REM 80 10(suby ecu) f0(diagnostic) 01(1 byte data) bf(euc init) 40(chksum)
OUT p, &H80
OUT p, &H10
OUT p, &HF0
OUT p, &H01
OUT p, &HBF
OUT p, &H40
i = 0
ecuid$ = ""
PRINT "Reading response"
DO
c = INP(lsr) AND 1
IF c > 0 THEN
abyte = INP(p)
PRINT HEX$(abyte)
IF (i > 13) AND (i < 19) THEN
ecuid$ = ecuid$ + " " + HEX$(abyte)
END IF
response(i) = abyte
i = i + 1
END IF
REM Increase this value to process more data (when LookupLabel
REM is called in a loop).
LOOP UNTIL i > 21
PRINT "ECU ID:"; ecuid$;
COLOR (9)
IF ecuid$ = " 54 53 52 51 50" THEN
PRINT " OlŠ (r) by Nemis"
ELSEIF ecuid$ = " 16 44 50 3 5" THEN
PRINT " turbo/wrx/gt 99/00 ae800/780"
ELSEIF ecuid$ = " 16 4 69 4 5" THEN
PRINT " STI5/6 99/00 af040"
ELSEIF ecuid$ = " 16 4 96 6 5" THEN
PRINT " P1ag340"
ELSEIF ecuid$ = " 1b 44 58 5 5" THEN
PRINT " wrx 01/02 af531 7555"
ELSEIF ecuid$ = " 29 44 59 41 5" THEN
PRINT " sti uk 01/02 ag820 2591"
ELSEIF ecuid$ = " 18 42 10 7 5" THEN
PRINT " legacy 2.5gx 02"
ELSEIF ecuid$ = " 18 44 10 8 5" THEN
PRINT " legacy 2.0gl 02"
ELSEIF ecuid$ = " d 4 68 8 5" THEN
PRINT " legacy b4 tt"
ELSEIF ecuid$ = " 19 44 58 5 5" THEN
PRINT " forester turbo S/gt00 ag050"
ELSEIF ecuid$ = " 23 44 10 8 5" THEN
PRINT " forester 2.0 gls 02"
ELSEIF ecuid$ = " 1b 14 40 5 5" THEN
PRINT " US wrx 01/02 af423"
ELSEIF ecuid$ = " 1e 12 0 7 5" THEN
PRINT " 2,5 rs af581"
ELSEIF ecuid$ = " 26 54 78 61 5" THEN
PRINT " libetry b4 tt ag850 3382"
ELSEIF ecuid$ = " 36 14 48 61 5" THEN
PRINT " us wrx manual 03 aj030 5692"
ELSEIF ecuid$ = " 29 44 59 61 5" THEN
PRINT " STI uk 01/02 ag820/ag821"
ELSEIF ecuid$ = " 2e 44 59 41 5" THEN
PRINT " STI uk 03 ah990 5512"
ELSEIF ecuid$ = " 23 12 49 51 6" THEN
PRINT " us 2,5 sti 04 aj241"
ELSEIF ecuid$ = " 2f 4 78 52 6" THEN
PRINT " leg jap twins ah111 5646"
ELSEIF ecuid$ = " 2E 12 49 51 6" THEN
PRINT " 2004 USDM WRX STi"
END IF
REM The 19th byte in the ECU response is the first parameter set
REM Calls to LookupLabel will be put in a loop at some future point.
offset = 19
CALL LookupLabel(offset, response(offset))
DO
LOOP UNTIL INKEY$ = CHR$(27)
END
The labels.txt file looks like this. I just entered in the first set as an example.
- Code: Select all
Engine speed
Manifold Absolute Pressure
Air/Fuel Learning #2
Air/Fuel Correction #2
Air/fuel Learning #1
Air Fuel Correction #1
Coolant Temperature
Engine load