technoblogy / ulisp-esp

A version of the Lisp programming language for ESP32-based boards.
MIT License
110 stars 37 forks source link

`(with-i2c (str 0) nothing)` panics #52

Closed tko closed 3 years ago

tko commented 3 years ago
7999> (with-i2c (str 0) nothing)
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d645e  PS      : 0x00060530  A0      : 0x800d5430  A1      : 0x3ffb1ef0
A2      : 0x3ffc15b4  A3      : 0x00000000  A4      : 0x3ffc15ac  A5      : 0x00000000
A6      : 0x3ffc1594  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffb1ed0
A10     : 0x00000000  A11     : 0x3ffc15a4  A12     : 0x00000006  A13     : 0x00000000
A14     : 0x0000000a  A15     : 0x3ffb8058  SAR     : 0x0000001b  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004  LBEG    : 0x4000c28c  LEND    : 0x4000c296  LCOUNT  : 0x00000000

Backtrace: 0x400d645e:0x3ffb1ef0 0x400d542d:0x3ffb1f20 0x400d6ecd:0x3ffb1f60 0x400d71b6:0x3ffb1f80 0x400daab9:0x3ffb1fb0 0x40089799:0x3ffb1fd0

Seems the 0 is invalid argument, works with 1, which is rather unfortunate as the examples do (dotimes (p 127) (with-i2c (str p) ...)) which then panics on the first round.

technoblogy commented 3 years ago

I see what you mean. If the second parameter is 0 or 1 it assumes it's the optional port, but it then fails to check that the address is missing.

The workaround is to change the scan program to explicitly give the port number:

(dotimes (p 127) (with-i2c (str 0 p) ...))

Thanks for reporting this.