![]() |
LambLisp 01 Red Fox Alpha
From AI to Actuator
|
Functions | |
| Sexpr_t | Wire_mop3_setTimeout (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_setPins (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_begin (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_requestFrom (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_setClock (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_beginTransmission (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_available (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_read (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_end (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_onReceive (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_onRequest (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_clearWireTimeoutFlag (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_getWireTimeoutFlag (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_endTransmission (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_mop3_write (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
| Sexpr_t | Wire_install_mop3 (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec) |
Variables | |
| TwoWire * | LL_Wire = 0 |
WiFi and Wire, in case we need to rationalize conflicting implementations. | |
| WiFiClass * | LL_WiFi |
LambLisp I2C (Wire) builtins.
| Sexpr_t Wire_mop3_setTimeout | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Set Wire timeout; no args = 1000 ms default; (timeout reset-on-timeout-flag) form also accepted.
(Wire.setWireTimeout) OR (Wire.setWireTimeout timeout reset-on-timeout-flag)
With no parameters, some generally useful (but as yet unknown) values are used.
| Sexpr_t Wire_mop3_setPins | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Assign SDA and SCL pins before calling Wire.begin.
| Sexpr_t Wire_mop3_begin | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
(begin [ addr ]) If address is provided , it is our slave bus address. If no address is provided, then we are the bus controller.
| Sexpr_t Wire_mop3_requestFrom | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
(Wire.requestFrom addr quantity [ release-bus-after ]) OR (Wire.requestFrom addr quantity)
If not provided, release-bus-after defaults to #t.
| Sexpr_t Wire_mop3_setClock | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Set the I2C clock frequency in Hz.
| Sexpr_t Wire_mop3_beginTransmission | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Begin a transmission to the I2C device at the given address.
| Sexpr_t Wire_mop3_available | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Return the number of bytes available to read from the I2C buffer.
| Sexpr_t Wire_mop3_read | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Read one byte from the I2C receive buffer; returns -1 if none available.
| Sexpr_t Wire_mop3_end | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Release the Wire bus and free resources; returns #t on success.
| Sexpr_t Wire_mop3_onReceive | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Register a receive callback for slave mode (stub).
| Sexpr_t Wire_mop3_onRequest | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Register a request callback for slave mode (stub).
| Sexpr_t Wire_mop3_clearWireTimeoutFlag | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Clear the Wire timeout flag (stub).
| Sexpr_t Wire_mop3_getWireTimeoutFlag | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Return the Wire timeout flag (stub).
| Sexpr_t Wire_mop3_endTransmission | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
End the current transmission; optional stop arg; returns #f on success or error string.
s + ascii.dec(), never d, for an LL_int32: the type names a WIDTH, not a C spelling, and int32_t is int on x86-64 but long on the xtensa toolchain – so no fixed conversion specifier is right on every target and the wrong one is UB.
| Sexpr_t Wire_mop3_write | ( | Lamb & | lamb, |
| Sexpr_t | sexpr, | ||
| Sexpr_t | env_exec ) |
Write a byte, character, string, or bytevector to the I2C transmit buffer; returns bytes written.
WRITE THE STRING AS AN EXPLICIT (bytes, length) PAIR. This was LL_Wire->write(sexpr->any_str_get_chars()), which was CORRECT on Arduino 2.x and does not compile on 3.x: TwoWire in 2.0.17 declared its own convenience overloads – inline size_t write(const char <em>s) { return write((uint8_t *) s, strlen(s)); } (Wire.h:136) plus write(long) / write(unsigned int) / etc. – and Arduino 3.x DELETED all of them, leaving only write(uint8_t) and write(const uint8_t *, size_t). With the char overload gone the call binds to write(uint8_t) and fails as invalid conversion from 'char*' to 'uint8_t' [-fpermissive] The [-fpermissive] tag makes this look like mere compiler tightening, and it is NOT: the overload it needed genuinely no longer exists. Behaviour on 2.x was right, so this rewrite is behaviour-preserving there (identical strlen-based call) and merely explicit. Passing the pair directly is correct on BOTH cores and does not depend on convenience overloads that a future core may drop again.
|
extern |
POINT THIS AT THE ARDUINO GLOBAL. It was declared and NEVER ASSIGNED anywhere in the repo – so it was a NULL pointer, and every one of the ~40 LL_WiFi-> call sites below dereferenced null. It did not look like that from the crash: Guru Meditation Error: Core 1 panic'ed (LoadProhibited), EXCVADDR 0x00000008 NetworkInterface::getStatusBits() NetworkInterface.cpp:231 WiFiSTAClass::isConnected() WiFiSTA.cpp:222 which reads as an Arduino 3.x defect – a "null netif in the new NetworkInterface layer" – and was first diagnosed that way. It is ours. STAClass STA is a MEMBER of WiFiSTAClass, so with this == nullptr the call reaches _interface_event_group at offset 8 of a null object: that IS the 0x00000008 in the report. getStatusBits() already null-checks its event group, so a real object cannot panic there. WHY IT SURVIVED ARDUINO 2.0.17: isConnected() there read a global and touched no member, so calling it through a null this was undefined but harmless in practice. Arduino 3.x moved status behind a member, and the latent null became a reboot. So this is a migration TRIGGER, not a migration regression – the defect predates it. Constant-initialised: &WiFi is a link-time address, so this does not depend on WiFi's constructor having run (no static-init-order hazard); the calls all happen after setup(). Fixing it HERE fixes all ~40 sites at once, which per-site readiness guards would not.