Skip to content

Commit

Permalink
Added individual error codes to the error reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Threetwosevensixseven committed Dec 25, 2019
1 parent 185c0d8 commit a5b0186
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 50 deletions.
Binary file modified dot/NXTP
Binary file not shown.
65 changes: 34 additions & 31 deletions src/asm/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ SetSpeed:
ld (Return.CPU2), a ; can be restored on exit
nextreg Reg.CPUSpeed, %11 ; Set current desired speed to 14MHz

//scf
//ErrorIfCarry(Errors.ESPComms1) ; Check longest error message

SavedArgs equ $+1: ld hl, SMC ; Restore args
ld a, h ; Check args length
or l
Expand Down Expand Up @@ -103,24 +106,24 @@ MakeCIPStart:
InitialiseESP:
PrintMsg(Messages.InitESP)
ESPSend("ATE0")
ErrorIfCarry(Errors.ESPComms) ; Raise ESP error if no response
ErrorIfCarry(Errors.ESPComms1) ; Raise ESP error if no response
call ESPReceiveWaitOK
ErrorIfCarry(Errors.ESPComms) ; Raise ESP error if no response
ErrorIfCarry(Errors.ESPComms2) ; Raise ESP error if no response
ESPSend("AT+CIPCLOSE") ; Don't raise error on CIPCLOSE
call ESPReceiveWaitOK ; Because it might not be open
//ErrorIfCarry(Errors.ESPComms) ; We never normally want to raise an error after CLOSE
ESPSend("AT+CIPMUX=0")
ErrorIfCarry(Errors.ESPComms) ; Raise ESP error if no response
ErrorIfCarry(Errors.ESPComms3) ; Raise ESP error if no response
call ESPReceiveWaitOK
ErrorIfCarry(Errors.ESPComms) ; Raise ESP error if no response
ErrorIfCarry(Errors.ESPComms4) ; Raise ESP error if no response
Connect:
PrintMsg(Messages.Connect1)
PrintBuffer(HostStart, HostLen)
PrintMsg(Messages.Connect2)
ESPSendBuffer(Buffer) ; This is AT+CIPSTART="TCP","<server>",<port>\r\n
ErrorIfCarry(Errors.ESPConn) ; Raise ESP error if no connection
ErrorIfCarry(Errors.ESPConn1) ; Raise ESP error if no connection
call ESPReceiveWaitOK
ErrorIfCarry(Errors.ESPConn) ; Raise ESP error if no response
ErrorIfCarry(Errors.ESPConn2) ; Raise ESP error if no response
//PrintMsg(Messages.Connected)
PrintAnyZone:
ld hl, (ZoneStart)
Expand Down Expand Up @@ -178,88 +181,88 @@ MakeCIPSend:
SendRequest:
ESPSendBuffer(MsgBuffer)
call ESPReceiveWaitOK
ErrorIfCarry(Errors.ESPComms) ; Raise wifi error if no response
ErrorIfCarry(Errors.ESPComms5) ; Raise wifi error if no response
call ESPReceiveWaitPrompt
ErrorIfCarry(Errors.ESPComms) ; Raise wifi error if no prompt
ErrorIfCarry(Errors.ESPComms6) ; Raise wifi error if no prompt
ESPSendBufferLen(Buffer, RequestLen)
ErrorIfCarry(Errors.ESPConn) ; Raise connection error
ErrorIfCarry(Errors.ESPConn3) ; Raise connection error
ReceiveResponse:
call ESPReceiveBuffer
call ParseIPDPacket
ErrorIfCarry(Errors.ESPConn) ; Raise connection error if no IPD packet
ErrorIfCarry(Errors.ESPConn4) ; Raise connection error if no IPD packet
ValidateResponse:
ld hl, (ResponseStart) ; Start of response
ld a, (hl) ; Read protocol version
cp ProtoVersion
ErrorIfNonZero(Errors.BadResp) ; Raise invalid response error if wrong protocol version
ErrorIfNonZero(Errors.BadResp1) ; Raise invalid response error if wrong protocol version
inc hl
ld a, (hl) ; Read date length
cp ProtoDateLen
ErrorIfNonZero(Errors.BadResp) ; Raise invalid response error if not length of nn/nn/nnnn
ErrorIfNonZero(Errors.BadResp2) ; Raise invalid response error if not length of nn/nn/nnnn
inc hl
ld a, (hl) ; Read time length
cp ProtoTimeLen
ErrorIfNonZero(Errors.BadResp) ; Raise invalid response error if not length of nn:nn:nn
ErrorIfNonZero(Errors.BadResp3) ; Raise invalid response error if not length of nn:nn:nn
ValidateDate:
inc hl
call ReadAndCheckDigit ; Read Date digit 1
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Date digit 1
ErrorIfCarry(Errors.BadResp4) ; Raise invalid response error if not Date digit 1
inc hl
call ReadAndCheckDigit ; Read Date digit 2
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Date digit 2
ErrorIfCarry(Errors.BadResp5) ; Raise invalid response error if not Date digit 2
inc hl
ld a, (hl) ; Read /
cp '/'
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not /
ErrorIfCarry(Errors.BadResp6) ; Raise invalid response error if not /
inc hl
call ReadAndCheckDigit ; Read Month digit 1
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Month digit 1
ErrorIfCarry(Errors.BadResp7) ; Raise invalid response error if not Month digit 1
inc hl
call ReadAndCheckDigit ; Read Month digit 2
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Month digit 2
ErrorIfCarry(Errors.BadResp8) ; Raise invalid response error if not Month digit 2
inc hl
ld a, (hl) ; Read /
cp '/'
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not /
ErrorIfCarry(Errors.BadResp9) ; Raise invalid response error if not /
inc hl
call ReadAndCheckDigit ; Read Year digit 1
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Year digit 1
ErrorIfCarry(Errors.BadResp10) ; Raise invalid response error if not Year digit 1
inc hl
call ReadAndCheckDigit ; Read Year digit 2
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Year digit 2
ErrorIfCarry(Errors.BadResp11) ; Raise invalid response error if not Year digit 2
inc hl
call ReadAndCheckDigit ; Read Year digit 3
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Year digit 3
ErrorIfCarry(Errors.BadResp12) ; Raise invalid response error if not Year digit 3
inc hl
call ReadAndCheckDigit ; Read Year digit 4
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Year digit 4
ErrorIfCarry(Errors.BadResp13) ; Raise invalid response error if not Year digit 4
ValidateTime:
inc hl
call ReadAndCheckDigit ; Read Hours digit 1
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Hours digit 1
ErrorIfCarry(Errors.BadResp14) ; Raise invalid response error if not Hours digit 1
inc hl
call ReadAndCheckDigit ; Read Hours digit 2
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Hours digit 2
ErrorIfCarry(Errors.BadResp15) ; Raise invalid response error if not Hours digit 2
inc hl
ld a, (hl) ; Read :
cp ':'
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not :
ErrorIfCarry(Errors.BadResp16) ; Raise invalid response error if not :
inc hl
call ReadAndCheckDigit ; Read Mins digit 1
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Mins digit 1
ErrorIfCarry(Errors.BadResp17) ; Raise invalid response error if not Mins digit 1
inc hl
call ReadAndCheckDigit ; Read Mins digit 2
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Mins digit 2
ErrorIfCarry(Errors.BadResp18) ; Raise invalid response error if not Mins digit 2
inc hl
ld a, (hl) ; Read :
cp ':'
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not :
ErrorIfCarry(Errors.BadResp19) ; Raise invalid response error if not :
inc hl
call ReadAndCheckDigit ; Read Secs digit 1
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Secs digit 1
ErrorIfCarry(Errors.BadResp20) ; Raise invalid response error if not Secs digit 1
inc hl
call ReadAndCheckDigit ; Read Secs digit 2
ErrorIfCarry(Errors.BadResp) ; Raise invalid response error if not Secs digit 2
ErrorIfCarry(Errors.BadResp21) ; Raise invalid response error if not Secs digit 2
SaveDateTime:
ld hl, (ResponseStart) ; Copy date into a buffer suitable for .date command,
ld bc, 3 ; with enclosing quotes and terminating zero.
Expand Down
46 changes: 37 additions & 9 deletions src/asm/msg.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,44 @@ Messages proc
pend

Errors proc
HostLen: db "HOSTNAME too lon", 'g'|128
ESPComms: db "WiFi communication erro", 'r'|128
ESPConn: db "Server connection erro", 'r'|128
ZoneLen: db "ZONE too lon", 'g'|128
NotNext: db "Next require", 'd'|128
ESPTimeout: db "WiFi or server timeou", 't'|128
HostLen: db "1 HOSTNAME too lon", 'g'|128
ESPComms1: db "2 WiFi communication erro", 'r'|128
ESPComms2: db "3 WiFi communication erro", 'r'|128
ESPComms3: db "4 WiFi communication erro", 'r'|128
ESPComms4: db "5 WiFi communication erro", 'r'|128
ESPComms5: db "6 WiFi communication erro", 'r'|128
ESPComms6: db "7 WiFi communication erro", 'r'|128
ESPConn1: db "8 Server connection erro", 'r'|128
ESPConn2: db "9 Server connection erro", 'r'|128
ESPConn3: db "A Server connection erro", 'r'|128
ESPConn4: db "B Server connection erro", 'r'|128
ZoneLen: db "C ZONE too lon", 'g'|128
Break: db "D BREAK - CONT repeat", 's'|128
BadResp: db "Invalid server respons", 'e'|128
DateNFF: db "Missing .date dot comman", 'd'|128
TimeNFF: db "Missing .time dot comman", 'd'|128
NotNext: db "E Next require", 'd'|128
ESPTimeout: db "F WiFi or server timeou", 't'|128
DateNFF: db "G Missing .date comman", 'd'|128
TimeNFF: db "H Missing .time comman", 'd'|128
BadResp1: db "I Invalid server respons", 'e'|128
BadResp2: db "J Invalid server respons", 'e'|128
BadResp3: db "K Invalid server respons", 'e'|128
BadResp4: db "L Invalid server respons", 'e'|128
BadResp5: db "M Invalid server respons", 'e'|128
BadResp6: db "N Invalid server respons", 'e'|128
BadResp7: db "O Invalid server respons", 'e'|128
BadResp8: db "P Invalid server respons", 'e'|128
BadResp9: db "Q Invalid server respons", 'e'|128
BadResp10: db "R Invalid server respons", 'e'|128
BadResp11: db "S Invalid server respons", 'e'|128
BadResp12: db "T Invalid server respons", 'e'|128
BadResp13: db "U Invalid server respons", 'e'|128
BadResp14: db "V Invalid server respons", 'e'|128
BadResp15: db "W Invalid server respons", 'e'|128
BadResp16: db "X Invalid server respons", 'e'|128
BadResp17: db "Y Invalid server respons", 'e'|128
BadResp18: db "Z Invalid server respons", 'e'|128
BadResp19: db "a Invalid server respons", 'e'|128
BadResp20: db "b Invalid server respons", 'e'|128
BadResp21: db "c Invalid server respons", 'e'|128
pend

Commands proc
Expand Down
20 changes: 10 additions & 10 deletions src/asm/version.asm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
; version.asm
;
; Auto-generated by ZXVersion.exe
; On 25 Dec 2019 at 15:40
; On 25 Dec 2019 at 17:17

BuildNo macro()
db "40"
db "41"
mend

BuildNoValue equ "40"
BuildNoWidth equ 0 + FW4 + FW0
BuildNoValue equ "41"
BuildNoWidth equ 0 + FW4 + FW1



Expand All @@ -22,17 +22,17 @@ BuildDateWidth equ 0 + FW2 + FW5 + FWSpace + FWD + FWe + FWc + FWSpace


BuildTime macro()
db "15:40"
db "17:17"
mend

BuildTimeValue equ "15:40"
BuildTimeWidth equ 0 + FW1 + FW5 + FWColon + FW4 + FW0
BuildTimeValue equ "17:17"
BuildTimeWidth equ 0 + FW1 + FW7 + FWColon + FW1 + FW7



BuildTimeSecs macro()
db "15:40:16"
db "17:17:59"
mend

BuildTimeSecsValue equ "15:40:16"
BuildTimeSecsWidth equ 0 + FW1 + FW5 + FWColon + FW4 + FW0 + FWColon + FW1 + FW6
BuildTimeSecsValue equ "17:17:59"
BuildTimeSecsWidth equ 0 + FW1 + FW7 + FWColon + FW1 + FW7 + FWColon + FW5 + FW9

0 comments on commit a5b0186

Please sign in to comment.