From 6a869648dd7026636e895148a5ee4482861b3f9b Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 8 Apr 2021 20:20:03 +0100 Subject: [PATCH] debug build to help see what goes wrong --- README.md | 70 ++++++++++++++++++++++++---------------- example/capture-esp.bas | Bin 0 -> 748 bytes example/verify.bas | Bin 785 -> 1205 bytes example/verify.bas.txt | 51 ++++++++++++++++++----------- example/verify7.bas | Bin 1217 -> 1226 bytes example/verify7.bas.txt | 2 +- http | Bin 5009 -> 5065 bytes http-debug.dot | Bin 5041 -> 5097 bytes src/main.asm | 2 +- src/uart.asm | 7 ++-- src/version.inc.asm | 2 +- src/wifi.asm | 9 ++++-- 12 files changed, 89 insertions(+), 54 deletions(-) create mode 100644 example/capture-esp.bas diff --git a/README.md b/README.md index 42b0565..c42a6a8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A utility for application developers to talk to web servers to exchange blocks of data, such as high scores, game progress. The `.http` dot command can also download and save to files over the web. -Usage: +## Usage ``` ; Send 1024 bytes from bank 22 to http://192.168.1.100:8080/send @@ -70,32 +70,12 @@ I've written a number of [example servers](https://github.com/remy/next-http/tre - I've noticed when using Cspect's emulation, if the host can't be reached, Cspect will hang indefinitely. - When using the `offset` you are constrained to 16K, so if the offset is 8,192, then the max length is also 8,192 (there's no error checking on this currently) -## Not supported / future +## Not supported / potential future +- 7bit / cspect emulated ESP support for file saving isn't working (yet) - http chunked encoding (just make sure your server isn't sending chunked encoding) - Support length on GET - -## Debugging and problems - -This repo also includes a debug build of `http`. The difference is that it will add all the ESP read and write to the second half of the bank you use. This way you can debug from the real hardware and capture exactly what's going on. - -**Important** the debug dot command uses the second half of the bank you use, so ideally test with less than 8K to help debugging. - -If you need to file an issue, this information is extremely valuable for debugging - and if you're not comfortable including the file in [an issue](https://github.com/remy/next-http/issues/new) as an attachment, you can email me directly at remy@remysharp.com. To capture this, run: - -``` -10 ../http-debug.dot -h example.com -u / -b 20 -20 SAVE "http-debug.bin" BANK 20 -``` - -Then include the `http-debug.bin` that was saved on your Next to help debug the issue. - -### Notes on http-debug.dot - -1. Does not erase the bank -2. The contents of the `State` structure (in `state.asm`) are written to the 2nd half of the bank, i.e. the second 8K page -3. After the `State` object, around 519 bytes later, the ESP exchange are stored, including the AT commands and ESP raw response. -4. `Wifi.getPacket` writes to the end of the bank with the `IX` register state as a stack like array - this is to debug the final parsing of the base64 encoded packet +- File POST and offsets in file saving ## Error codes @@ -119,11 +99,39 @@ Then include the `http-debug.bin` that was saved on your Next to help debug the - `I` Filename or bank must be specified (command is missing the `-b` or `-f` argument) - `J` Could not open file for writing -## Development +## Testing + +Assuming that `http` is in your `/dot/` directory, there are two verification programs in the [example](https://github.com/remy/next-http/tree/main/example) folder. Download [verify.bas](https://github.com/remy/next-http/blob/main/example/verify.bas) and run it and if it succeeds you'll see the following screen: + +![](https://user-images.githubusercontent.com/13700/114017829-68f57380-9864-11eb-9590-71cad0e4c4a1.png) + +If any of the sections fail however, there is a debug script available in [capture-esp.bas](https://github.com/remy/next-http/blob/main/example/capture-esp.bas) which uses [`http-debug.dot`](https://github.com/remy/next-http/blob/main/http-debug.dot) in the **same** directory as capture-esp.bas. + +The `capture-esp.bas` will test a simple 4K file and generate `4k-esp-bank.bin` in the same working directory which contains full debug exchange between your machine and the ESP chip uses to send data. If you share that file with me either [via issues](https://github.com/remy/next-http/issues/new) or via [email](mailto:remy@remysharp.com) I can use it to debug. + + +## Debugging and problems + +This repo also includes a debug build of `http`. The difference is that it will add all the ESP read and write to the second half of the bank you use. This way you can debug from the real hardware and capture exactly what's going on. + +**Important** the debug dot command uses the second half of the bank you use, so ideally test with less than 8K to help debugging. + +If you need to file an issue, this information is extremely valuable for debugging - and if you're not comfortable including the file in [an issue](https://github.com/remy/next-http/issues/new) as an attachment, you can email me directly at remy@remysharp.com. To capture this, run: + +``` +10 ../http-debug.dot -h example.com -u / -b 20 +20 SAVE "http-debug.bin" BANK 20 +``` + +Then include the `http-debug.bin` that was saved on your Next to help debug the issue. + +### Notes on http-debug.dot + +1. Does not erase the bank +2. The contents of the `State` structure (in `state.asm`) are written to the 2nd half of the bank, i.e. the second 8K page +3. After the `State` object, around 519 bytes later, the ESP exchange are stored, including the AT commands and ESP raw response. +4. `Wifi.getPacket` writes to the end of the bank with the `IX` register state as a stack like array - this is to debug the final parsing of the base64 encoded packet -- Uses [sjasmplus](https://z00m128.github.io/sjasmplus/documentation.html) from VS Code task -- Follows this [code convention](https://github.com/remy/z80-code-conventions) -- Entry point is main.asm ## With special thanks to @@ -132,6 +140,12 @@ Then include the `http-debug.bin` that was saved on your Next to help debug the - [Peter Ped Helcmanovsky](https://github.com/ped7g/) - via dot commands and answering endless questions on discord - [David Saphier](https://github.com/em00k/) - for starting and inspiring full "save to file" support +## Development + +- Uses [sjasmplus](https://z00m128.github.io/sjasmplus/documentation.html) from VS Code task +- Follows this [code convention](https://github.com/remy/z80-code-conventions) +- Entry point is main.asm + ## License It's in the license link, but all the same: diff --git a/example/capture-esp.bas b/example/capture-esp.bas new file mode 100644 index 0000000000000000000000000000000000000000..7dc5cab96d578e9bda5a5f250675587de91c35b2 GIT binary patch literal 748 zcmcgp&ubGw6n@DD!ITL~ax!8blU)efo$jW^(g_Q#)FM?#Nox^ro6RO!viZSgQrepb z&(_|G_$Tz>U*N%OZ(gOBoQkBELR3`5*-c36Kj6U3<2~NI?|t95_3Zif;(B@eP7FqI z0Py4RO5XoQ$V46jnK^h@46_WtX9D+9@b>Ux#W2EBAuk&W z8vNqpGgIa-EFM0t~j@t4`;HQ&ebQ%aQMI1Gt$nT7F*7R*lpN9$cH;6O#ajzYeB_>iQBbh4otQkVIV{( zBPHok8l1_ZsGF#_t5`H-`CAH@itfG$Y)7D@k_;q4^DIr;@zEfeX%9Y literal 0 HcmV?d00001 diff --git a/example/verify.bas b/example/verify.bas index 38f0c5fe644558ab5d163b0c83134fa2ac16ce42..f67599e26e2ce4560a81778ec9cea37cb23cddf8 100644 GIT binary patch literal 1205 zcmcgrOKTHh6ursBS`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#o*j-iiB+5VH(Iff<@YKE?cte1&yYh0jz diff --git a/src/main.asm b/src/main.asm index 2080c24..760fe11 100644 --- a/src/main.asm +++ b/src/main.asm @@ -2,7 +2,7 @@ SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION OPT reset --zxnext --syntax=abfw - DEFINE TESTING + ; DEFINE TESTING INCLUDE "version.inc.asm" INCLUDE "macros.inc.asm" diff --git a/src/uart.asm b/src/uart.asm index 18628e6..a2b710c 100644 --- a/src/uart.asm +++ b/src/uart.asm @@ -49,12 +49,15 @@ init ret .baudTable: - DW 243,248,256,260,269,278,286,234 + ; IFDEF TESTING + ; DEFW 486,496,512,521,538,556,573,469 ; 56k - slower on the off chance it helps with debug + ; ELSE + DEFW 243,248,256,260,269,278,286,234 ; 115K + ; ENDIF ; A <- result ; Modifies: BC read: - call Border call InitESPTimeout ld bc, UART_GetStatus .wait: diff --git a/src/version.inc.asm b/src/version.inc.asm index 43027b4..cbad7d4 100644 --- a/src/version.inc.asm +++ b/src/version.inc.asm @@ -1,5 +1,5 @@ IFNDEF TESTING - DEFINE VERSION "1.0-18b" + DEFINE VERSION "1.0-19b" ELSE DEFINE VERSION "TEST" ENDIF diff --git a/src/wifi.asm b/src/wifi.asm index 6755615..534b7b9 100644 --- a/src/wifi.asm +++ b/src/wifi.asm @@ -23,16 +23,21 @@ init: call Uart.init EspCmdOkErr "ATE0" jr c, .initError + + EspCmdOkErr "AT+CIPSERVER=0" EspCmdOkErr "AT+CIPCLOSE" ; Close if there some connection was. Don't care about result EspCmdOkErr "AT+CIPMUX=0" ; Single connection mode jr c, .initError + EspCmdOkErr "AT+CIPDINFO=0" ; Disable additional info + jr c, .initError + and a ret .initError call RetartESP jr c, .failed - jr Wifi.init + jp Wifi.init .failed ld hl, Err.wifiInit scf @@ -486,7 +491,7 @@ getPacket: call esxDOS.fWrite pop de pop hl - ld de, (Bank.buffer) + ld de, Bank.buffer .skipWriteToFile ex de, hl ; update the tip of our result buffer