the active energy field is pretty sussy but it's just a 4-byte integer sucked off as 2 2-byte ones, $ printf '%4s\n' $(printf '%s\n' obase=16 58932 60 | bc) | tr ' ' 0 | tac | paste -sd\\0 | bc
399634 and that's what the LCD shows too

sysv message queues? kinda slick with it; world's most insane interface, natch, but
also thanks to @ThePhD's n3030 i can have enum or_we_504_msgtype : long { in c and c++ with -std=c2x, which makes this much less insane

and yes the raw format is 3c 00 0f f5 for 3`994`895 (0x003cf50f), so two LSB u16s pasted together MSBly, which is PDP-11 middle-endian. plus ça change
falling edge trigger feasible if i manage to talk to the GPIO
also lol the integration time on this meter really fucks it, mathematically it comes out to 1mA, i measured 848μA with a jumper

as elucidated by the (entirety of!) OR-WE-504_MODBUS_Registers_list.pdf ive finally managed to dig up. lets see!!!!!
register 6 is what the manual says, register 15 is what it returns the address when reading. save me from this hell


in that you need to broadcast the address change, not just send it, and they explicitly say to send it to the device
hey, guess what doesn't work in modern mbpoll, that i remember glancing through when initially trying to connect…
Some RTU devices need to get initialized to a certain address via the 0x00 broadcast address. But currently RTU_SLAVEADDR_MIN is defined as 1
lol. lmfao.
and i cant "emulate" the meter well enough by just reading from the USB/serial adapter
so i snapshotted the entire pool on my laptop and installed wine32 and mono and ms fonts and deleted my wine config because it wouldnt load
i cannot get it to work regardless of the arcana i do and how i torture it, despite posting the same data as the configger; i think its because of modbus's explicit precise inter-byte (inter-message? both?) sleeps that libmodbus boasts about not having
itll be in Attic/ for posterity but for my usecase i can just set the addresses and serials once manually :v
![$ make clean rm -f ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy $ make -j cc -std=c2x -I/usr/include/modbus -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-modbus.c -o ORNO-OR-WE-504-modbus cc -std=c2x -I/usr/include/modbus -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-gpio.c -o ORNO-OR-WE-505-gpio c++ -std=c++20 -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-snmp.cpp -o ORNO-OR-WE-504-snmp c++ -std=c++20 -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-snmp.cpp -o ORNO-OR-WE-505-snmp cp ORNO-OR-WE-dumpy.sh ORNO-OR-WE-dumpy $ file ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy ORNO-OR-WE-504-modbus: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=a58765009c288441, with debug_info, not stripped ORNO-OR-WE-505-gpio: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=dff6cd7a988f007d, with debug_info, not stripped ORNO-OR-WE-504-snmp: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=1c805d687f14be15, with debug_info, not stripped ORNO-OR-WE-505-snmp: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=42917d88e82d6e4d, with debug_info, not stripped ORNO-OR-WE-dumpy: POSIX shell script, ASCII text executable $ make clean rm -f ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy $ $ CPPFLAGS="-target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access" LDFLAGS=-L. make -j cc -std=c2x -I/usr/include/modbus -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-modbus.c -o ORNO-OR-WE-504-modbus cc -std=c2x -I/usr/include/modbus -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-gpio.c -o ORNO-OR-WE-505-gpio c++ -std=c++20 -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-snmp.cpp -o ORNO-OR-WE-504-snmp c++ -std=c++20 -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-snmp.cpp -o ORNO-OR-WE-505-snmp cp ORNO-OR-WE-dumpy.sh ORNO-OR-WE-dumpy $ file ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy ORNO-OR-WE-504-modbus: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=44fdf79bc38c0196, with debug_info, not stripped ORNO-OR-WE-505-gpio: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=74c95938f997db5b, with debug_info, not stripped ORNO-OR-WE-504-snmp: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=65f435484ede0393, with debug_info, not stripped ORNO-OR-WE-505-snmp: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=e7cf566d96f8f12d, with debug_info, not stripped ORNO-OR-WE-dumpy: POSIX shell script, ASCII text executable $ make clean rm -f ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy $ make -j cc -std=c2x -I/usr/include/modbus -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-modbus.c -o ORNO-OR-WE-504-modbus cc -std=c2x -I/usr/include/modbus -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-gpio.c -o ORNO-OR-WE-505-gpio c++ -std=c++20 -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-snmp.cpp -o ORNO-OR-WE-504-snmp c++ -std=c++20 -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-snmp.cpp -o ORNO-OR-WE-505-snmp cp ORNO-OR-WE-dumpy.sh ORNO-OR-WE-dumpy $ file ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy ORNO-OR-WE-504-modbus: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=a58765009c288441, with debug_info, not stripped ORNO-OR-WE-505-gpio: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=dff6cd7a988f007d, with debug_info, not stripped ORNO-OR-WE-504-snmp: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=1c805d687f14be15, with debug_info, not stripped ORNO-OR-WE-505-snmp: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=42917d88e82d6e4d, with debug_info, not stripped ORNO-OR-WE-dumpy: POSIX shell script, ASCII text executable $ make clean rm -f ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy $ $ CPPFLAGS="-target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access" LDFLAGS=-L. make -j cc -std=c2x -I/usr/include/modbus -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-modbus.c -o ORNO-OR-WE-504-modbus cc -std=c2x -I/usr/include/modbus -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-gpio.c -o ORNO-OR-WE-505-gpio c++ -std=c++20 -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-504-snmp.cpp -o ORNO-OR-WE-504-snmp c++ -std=c++20 -target arm-linux-gnueabi -Wno-atomic-alignment -Wno-unaligned-access -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -g -Wall -Wextra -L. -flto=full -fuse-ld=lld -Wl,--as-needed -lrt -latomic -lmodbus ORNO-OR-WE-505-snmp.cpp -o ORNO-OR-WE-505-snmp cp ORNO-OR-WE-dumpy.sh ORNO-OR-WE-dumpy $ file ORNO-OR-WE-504-modbus ORNO-OR-WE-505-gpio ORNO-OR-WE-504-snmp ORNO-OR-WE-505-snmp ORNO-OR-WE-dumpy ORNO-OR-WE-504-modbus: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=44fdf79bc38c0196, with debug_info, not stripped ORNO-OR-WE-505-gpio: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=74c95938f997db5b, with debug_info, not stripped ORNO-OR-WE-504-snmp: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=65f435484ede0393, with debug_info, not stripped ORNO-OR-WE-505-snmp: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[xxHash]=e7cf566d96f8f12d, with debug_info, not stripped ORNO-OR-WE-dumpy: POSIX shell script, ASCII text executable](https://staging.cohostcdn.org/attachment/92e58c7c-68fa-41e0-ba68-56b32b7c9b6e/a.png?width=675&dpr=1)
(the -L. is for libmodbus, im not installing armel-native packages just for this)
i also dont think i posted the shart link, if you also have some polish leccy meters (though I suspect the impulse driver will be relatively universal):

as in: you just say what you want in GPIO_V2_GET_LINE_IOCTL, that gives you an fd to read, you sleep in read, and it's pre-timestamped. i cannot get over the usability of this
and theres drip mode as well:
(idk how well this comes out, the blinks are short and i have no explicit control over the frame integration time)

i gamed down the golden image rootfs to 324M used too, which is ~acceptable when keeping all modules and firmware i think
/usr/local/lib/udev/rules.d/99-ORNO.rules with SUBSYSTEM=="gpio", TAG+="systemd" does its magic, though, admittedly, this is largely frivolous on a coldplugged device
and i need a resistor Somewhere to trigger the usb host, too bad the raspberry pi is entirely undocumented so i dont have a fucking clue where, if at all, the Special Pin is available
and the only thread in which they're mentioned is [HELP] Raspberry Pi Zero W V1.1 - Test Pads problem; those three mean that there just don't appear to be zero w test pads listed at all, anywhere


they changed it in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bcc76c4014dce4e3834dbd5b7f6593cbcfbfebe0, which, y'know, fair enough, i can just build a dtb w/o otg, but still very annoying to me, personally
where "intermittent" means it just worked for 16h straight, but then it didnt after i rebooted for new device tree and jiggled it around, but then it worked once, and im guessing this shit would
too bad i noticed after i cut off the wires in preparation to solder them to the second, working adapter. turned a 20 second job into a 7-minute one, and instead of the incredible strain relief system™ it will now be a squeeze of cum
$ dtdiff ~/uwu/p16/boot/firmware/bcm2835-rpi-zero-w.dtb{.orig,}
--- /dev/fd/63 2023-02-26 21:57:08.472157491 +0100
+++ /dev/fd/62 2023-02-26 21:57:08.472157491 +0100
@@ -681,10 +681,7 @@
clock-names = "otg";
clocks = <0x16>;
compatible = "brcm,bcm2835-usb";
- dr_mode = "otg";
- g-np-tx-fifo-size = <0x20>;
- g-rx-fifo-size = <0x100>;
- g-tx-fifo-size = <0x100 0x100 0x200 0x200 0x200 0x300 0x300>;
+ dr_mode = "host";
interrupts = <0x01 0x09>;
phy-names = "usb2-phy";
phys = <0x17>;

![#!/bin/sh base=.1.3.6.1.4.1.8072.9999.9999.1 get() { case "${get#$base}" in .0) echo $get echo STRING echo hello world ;; .1) echo $get echo INTEGER echo 8675309 ;; *) echo NONE ;; esac } while :; do read -r op case "$op" in get) read -r get echo "get $get (${get#$base})" | logger get ;; getnext) read -r get echo "getnext $get (${get#$base})" | logger case "${get#$base}" in .0) get=$base.1 get ;; .1) echo NONE ;; *) get=$base.0 get ;; esac ;; set) read -r val echo "set $val" | logger echo not-writable ;; PING) echo PONG ;; *) echo "HUH $op" | logger ;; esac done $ snmpwalk -v1 -c public localhost .1.3.6.1.4.1.8072.9999.9999 NET-SNMP-MIB::netSnmpPlaypen.1.0 = STRING: "hello world" NET-SNMP-MIB::netSnmpPlaypen.1.1 = INTEGER: 8675309 Feb 08 02:50:04 tarta Debian-snmp[2678083]: getnext .1.3.6.1.4.1.8072.9999.9999.1 () Feb 08 02:50:04 tarta Debian-snmp[2678085]: getnext .1.3.6.1.4.1.8072.9999.9999.1.0 (.0) Feb 08 02:50:04 tarta Debian-snmp[2678087]: getnext .1.3.6.1.4.1.8072.9999.9999.1.1 (.1) #!/bin/sh base=.1.3.6.1.4.1.8072.9999.9999.1 get() { case "${get#$base}" in .0) echo $get echo STRING echo hello world ;; .1) echo $get echo INTEGER echo 8675309 ;; *) echo NONE ;; esac } while :; do read -r op case "$op" in get) read -r get echo "get $get (${get#$base})" | logger get ;; getnext) read -r get echo "getnext $get (${get#$base})" | logger case "${get#$base}" in .0) get=$base.1 get ;; .1) echo NONE ;; *) get=$base.0 get ;; esac ;; set) read -r val echo "set $val" | logger echo not-writable ;; PING) echo PONG ;; *) echo "HUH $op" | logger ;; esac done $ snmpwalk -v1 -c public localhost .1.3.6.1.4.1.8072.9999.9999 NET-SNMP-MIB::netSnmpPlaypen.1.0 = STRING: "hello world" NET-SNMP-MIB::netSnmpPlaypen.1.1 = INTEGER: 8675309 Feb 08 02:50:04 tarta Debian-snmp[2678083]: getnext .1.3.6.1.4.1.8072.9999.9999.1 () Feb 08 02:50:04 tarta Debian-snmp[2678085]: getnext .1.3.6.1.4.1.8072.9999.9999.1.0 (.0) Feb 08 02:50:04 tarta Debian-snmp[2678087]: getnext .1.3.6.1.4.1.8072.9999.9999.1.1 (.1)](https://staging.cohostcdn.org/attachment/80c05c02-4672-4d03-9ee9-d99975a89f98/a.png?width=675&dpr=1)







![# ./lsgpio GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines line 0: "ID_SDA" unused [input] line 1: "ID_SCL" unused [input] line 2: "SDA1" unused [input] line 3: "SCL1" unused [input] line 4: "GPIO_GCLK" unused [input] line 5: "GPIO5" unused [input] line 6: "GPIO6" unused [output] line 7: "SPI_CE1_N" unused [input] line 8: "SPI_CE0_N" unused [input] line 9: "SPI_MISO" unused [input] line 10: "SPI_MOSI" unused [input] line 11: "SPI_SCLK" unused [input] line 12: "GPIO12" unused [input] line 13: "GPIO13" unused [input] line 14: "TXD0" unused [input] line 15: "RXD0" unused [input] line 16: "GPIO16" unused [input] line 17: "GPIO17" unused [input] line 18: "GPIO18" unused [input] line 19: "GPIO19" unused [input] line 20: "GPIO20" unused [input] line 21: "GPIO21" unused [input] line 22: "GPIO22" unused [input] line 23: "GPIO23" unused [input] line 24: "GPIO24" unused [input] line 25: "GPIO25" unused [input] line 26: "GPIO26" unused [input] line 27: "GPIO27" unused [input] line 28: "SDA0" unused [input] line 29: "SCL0" unused [input] line 30: "CTS0" unused [input] line 31: "RTS0" unused [input] line 32: "TXD0" unused [input] line 33: "RXD0" unused [input] line 34: "SD1_CLK" unused [input] line 35: "SD1_CMD" unused [input] line 36: "SD1_DATA0" unused [input] line 37: "SD1_DATA1" unused [input] line 38: "SD1_DATA2" unused [input] line 39: "SD1_DATA3" unused [input] line 40: "CAM_GPIO1" unused [output] line 41: "WL_ON" "reset" [used, output, active-low] line 42: "NC" unused [input] line 43: "WIFI_CLK" unused [input] line 44: "CAM_GPIO0" unused [output] line 45: "BT_ON" "shutdown" [used, output] line 46: "HDMI_HPD_N" unused [input] line 47: "STATUS_LED_N" "ACT" [used, output, active-low] line 48: "SD_CLK_R" unused [input] line 49: "SD_CMD_R" unused [input] line 50: "SD_DATA0_R" unused [input] line 51: "SD_DATA1_R" unused [input] line 52: "SD_DATA2_R" unused [input] line 53: "SD_DATA3_R" unused [input] $ cc -target arm-linux-gnueabi -fuse-ld=lld lsgpio.c -std=gnu89 -olsgpio $ scp lsgpio ciastko-malinowe:/tmp/ lsgpio 100% 11KB 887.7KB/s 00:00 # ./lsgpio GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines line 0: "ID_SDA" unused [input] line 1: "ID_SCL" unused [input] line 2: "SDA1" unused [input] line 3: "SCL1" unused [input] line 4: "GPIO_GCLK" unused [input] line 5: "GPIO5" unused [input] line 6: "GPIO6" unused [output] line 7: "SPI_CE1_N" unused [input] line 8: "SPI_CE0_N" unused [input] line 9: "SPI_MISO" unused [input] line 10: "SPI_MOSI" unused [input] line 11: "SPI_SCLK" unused [input] line 12: "GPIO12" unused [input] line 13: "GPIO13" unused [input] line 14: "TXD0" unused [input] line 15: "RXD0" unused [input] line 16: "GPIO16" unused [input] line 17: "GPIO17" unused [input] line 18: "GPIO18" unused [input] line 19: "GPIO19" unused [input] line 20: "GPIO20" unused [input] line 21: "GPIO21" unused [input] line 22: "GPIO22" unused [input] line 23: "GPIO23" unused [input] line 24: "GPIO24" unused [input] line 25: "GPIO25" unused [input] line 26: "GPIO26" unused [input] line 27: "GPIO27" unused [input] line 28: "SDA0" unused [input] line 29: "SCL0" unused [input] line 30: "CTS0" unused [input] line 31: "RTS0" unused [input] line 32: "TXD0" unused [input] line 33: "RXD0" unused [input] line 34: "SD1_CLK" unused [input] line 35: "SD1_CMD" unused [input] line 36: "SD1_DATA0" unused [input] line 37: "SD1_DATA1" unused [input] line 38: "SD1_DATA2" unused [input] line 39: "SD1_DATA3" unused [input] line 40: "CAM_GPIO1" unused [output] line 41: "WL_ON" "reset" [used, output, active-low] line 42: "NC" unused [input] line 43: "WIFI_CLK" unused [input] line 44: "CAM_GPIO0" unused [output] line 45: "BT_ON" "shutdown" [used, output] line 46: "HDMI_HPD_N" unused [input] line 47: "STATUS_LED_N" "ACT" [used, output, active-low] line 48: "SD_CLK_R" unused [input] line 49: "SD_CMD_R" unused [input] line 50: "SD_DATA0_R" unused [input] line 51: "SD_DATA1_R" unused [input] line 52: "SD_DATA2_R" unused [input] line 53: "SD_DATA3_R" unused [input] $ cc -target arm-linux-gnueabi -fuse-ld=lld lsgpio.c -std=gnu89 -olsgpio $ scp lsgpio ciastko-malinowe:/tmp/ lsgpio 100% 11KB 887.7KB/s 00:00](https://staging.cohostcdn.org/attachment/bd792aa4-b6b5-47bd-b9a5-0703434c3d49/a.png?width=675&dpr=1)
![# ls -l /proc/628/fd total 0 lrwx------ 1 root root 64 Feb 13 01:13 0 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 13 01:13 1 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 13 01:13 2 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 13 01:13 3 -> /dev/gpiochip0 lr-x------ 1 root root 64 Feb 13 01:13 4 -> anon_inode:gpio-line # ./lsgpio GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines line 0: "ID_SDA" unused [input] line 1: "ID_SCL" unused [input] line 2: "SDA1" unused [input] line 3: "SCL1" unused [input] line 4: "GPIO_GCLK" unused [input] line 5: "GPIO5" "ORNO-OR-WE-505-gpio.c" [used, input, pull-up, falling-edge] line 6: "GPIO6" "ORNO-OR-WE-505-gpio.c" [used, input, pull-up, falling-edge] line 7: "SPI_CE1_N" unused [input] line 8: "SPI_CE0_N" unused [input] # ls -l /proc/628/fd total 0 lrwx------ 1 root root 64 Feb 13 01:13 0 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 13 01:13 1 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 13 01:13 2 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 13 01:13 3 -> /dev/gpiochip0 lr-x------ 1 root root 64 Feb 13 01:13 4 -> anon_inode:gpio-line # ./lsgpio GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines line 0: "ID_SDA" unused [input] line 1: "ID_SCL" unused [input] line 2: "SDA1" unused [input] line 3: "SCL1" unused [input] line 4: "GPIO_GCLK" unused [input] line 5: "GPIO5" "ORNO-OR-WE-505-gpio.c" [used, input, pull-up, falling-edge] line 6: "GPIO6" "ORNO-OR-WE-505-gpio.c" [used, input, pull-up, falling-edge] line 7: "SPI_CE1_N" unused [input] line 8: "SPI_CE0_N" unused [input]](https://staging.cohostcdn.org/attachment/0847e7c7-35eb-4b9f-8daa-33cbdb32c55e/a.png?width=675&dpr=1)
![8727791207292: RISING, id=5; globl=327; line=250 8727800689236: RISING, id=5; globl=328; line=251 8729787476572: RISING, id=5; globl=329; line=252 8730941790801: FALLING, id=5; globl=330; line=253 8730981647567: RISING, id=5; globl=331; line=254 8736190990070: FALLING, id=5; globl=332; line=255 8736226159864: RISING, id=5; globl=333; line=256 8741373791820: FALLING, id=5; globl=334; line=257 8741411011604: RISING, id=5; globl=335; line=258 8746745687565: FALLING, id=5; globl=336; line=259 8746785222335: RISING, id=5; globl=337; line=260 8752114056428: FALLING, id=5; globl=338; line=261 8752149506222: RISING, id=5; globl=339; line=262 8757472371445: FALLING, id=5; globl=340; line=263 8757508872234: RISING, id=5; globl=341; line=264 8762741961069: FALLING, id=5; globl=342; line=265 8762778444859: RISING, id=5; globl=343; line=266 8767903493404: FALLING, id=5; globl=344; line=267 8767943418175: RISING, id=5; globl=345; line=268 8773150439337: FALLING, id=5; globl=346; line=269 8773187927122: RISING, id=5; globl=347; line=270 8778439499118: FALLING, id=5; globl=348; line=271 8778477556901: RISING, id=5; globl=349; line=272 8783644308468: FALLING, id=5; globl=350; line=273 8783682221253: RISING, id=5; globl=351; line=274 8788846570918: FALLING, id=5; globl=352; line=275 8788881956717: RISING, id=5; globl=353; line=276 8794113482087: FALLING, id=5; globl=354; line=277 8794151590871: RISING, id=5; globl=355; line=278 8799424078095: FALLING, id=5; globl=356; line=279 8799460906888: RISING, id=5; globl=357; line=280 8804655557635: FALLING, id=5; globl=358; line=281 8804695127412: RISING, id=5; globl=359; line=282 8809919810073: FALLING, id=5; globl=360; line=283 8809959774849: RISING, id=5; globl=361; line=284 8815110984004: FALLING, id=5; globl=362; line=285 8815149546788: RISING, id=5; globl=363; line=286 8820410901408: FALLING, id=5; globl=364; line=287 8820449187194: RISING, id=5; globl=365; line=288 8825669579123: FALLING, id=5; globl=366; line=289 8825708522907: RISING, id=5; globl=367; line=290 8830975998655: FALLING, id=5; globl=368; line=291 8831012754451: RISING, id=5; globl=369; line=292 8836162080933: FALLING, id=5; globl=370; line=293 8836197672736: RISING, id=5; globl=371; line=294 8841474862589: FALLING, id=5; globl=372; line=295 8841511900384: RISING, id=5; globl=373; line=296 8846786019333: FALLING, id=5; globl=374; line=297 8846821218139: RISING, id=5; globl=375; line=298 8852041677460: FALLING, id=5; globl=376; line=299 8852080720246: RISING, id=5; globl=377; line=300 ^Z [1]+ Stopped ./ORNO-OR-WE-505-gpio /dupaninka /dev/gpiochip0 nabijaczleweli@ciastko-malinowe:/tmp$ 8727791207292: RISING, id=5; globl=327; line=250 8727800689236: RISING, id=5; globl=328; line=251 8729787476572: RISING, id=5; globl=329; line=252 8730941790801: FALLING, id=5; globl=330; line=253 8730981647567: RISING, id=5; globl=331; line=254 8736190990070: FALLING, id=5; globl=332; line=255 8736226159864: RISING, id=5; globl=333; line=256 8741373791820: FALLING, id=5; globl=334; line=257 8741411011604: RISING, id=5; globl=335; line=258 8746745687565: FALLING, id=5; globl=336; line=259 8746785222335: RISING, id=5; globl=337; line=260 8752114056428: FALLING, id=5; globl=338; line=261 8752149506222: RISING, id=5; globl=339; line=262 8757472371445: FALLING, id=5; globl=340; line=263 8757508872234: RISING, id=5; globl=341; line=264 8762741961069: FALLING, id=5; globl=342; line=265 8762778444859: RISING, id=5; globl=343; line=266 8767903493404: FALLING, id=5; globl=344; line=267 8767943418175: RISING, id=5; globl=345; line=268 8773150439337: FALLING, id=5; globl=346; line=269 8773187927122: RISING, id=5; globl=347; line=270 8778439499118: FALLING, id=5; globl=348; line=271 8778477556901: RISING, id=5; globl=349; line=272 8783644308468: FALLING, id=5; globl=350; line=273 8783682221253: RISING, id=5; globl=351; line=274 8788846570918: FALLING, id=5; globl=352; line=275 8788881956717: RISING, id=5; globl=353; line=276 8794113482087: FALLING, id=5; globl=354; line=277 8794151590871: RISING, id=5; globl=355; line=278 8799424078095: FALLING, id=5; globl=356; line=279 8799460906888: RISING, id=5; globl=357; line=280 8804655557635: FALLING, id=5; globl=358; line=281 8804695127412: RISING, id=5; globl=359; line=282 8809919810073: FALLING, id=5; globl=360; line=283 8809959774849: RISING, id=5; globl=361; line=284 8815110984004: FALLING, id=5; globl=362; line=285 8815149546788: RISING, id=5; globl=363; line=286 8820410901408: FALLING, id=5; globl=364; line=287 8820449187194: RISING, id=5; globl=365; line=288 8825669579123: FALLING, id=5; globl=366; line=289 8825708522907: RISING, id=5; globl=367; line=290 8830975998655: FALLING, id=5; globl=368; line=291 8831012754451: RISING, id=5; globl=369; line=292 8836162080933: FALLING, id=5; globl=370; line=293 8836197672736: RISING, id=5; globl=371; line=294 8841474862589: FALLING, id=5; globl=372; line=295 8841511900384: RISING, id=5; globl=373; line=296 8846786019333: FALLING, id=5; globl=374; line=297 8846821218139: RISING, id=5; globl=375; line=298 8852041677460: FALLING, id=5; globl=376; line=299 8852080720246: RISING, id=5; globl=377; line=300 ^Z [1]+ Stopped ./ORNO-OR-WE-505-gpio /dupaninka /dev/gpiochip0 nabijaczleweli@ciastko-malinowe:/tmp$](https://staging.cohostcdn.org/attachment/19b78b40-ff71-4af8-8114-199c0325705f/a.png?width=675&dpr=1)
![nabijaczleweli@ciastko-malinowe:~$ systemctl status dupa@'5\x206' ORNO-OR-WE-504-modbus@ttyUSB0.service snmpd ● dupa@5\x206.service - 5\x206 test 5 6 Loaded: loaded (/run/systemd/system/dupa@.service; static) Active: active (running) since Mon 2023-02-13 21:22:55 CET; 24h ago Main PID: 3444 (ORNO-OR-WE-505-) Tasks: 1 (limit: 853) Memory: 148.0K CPU: 7.764s CGroup: /system.slice/system-dupa.slice/dupa@5\x206.service └─3444 /usr/local/sbin/ORNO-OR-WE-505-gpio /ORNO505 5 6 Feb 13 21:22:55 ciastko-malinowe systemd[1]: Started 5\x206 test 5 6. Feb 13 21:22:55 ciastko-malinowe sh[3444]: gpiochip0: pinctrl-bcm2835 w/54 lines Feb 13 21:22:55 ciastko-malinowe sh[3444]: meter 0: line 5: GPIO5 Feb 13 21:22:55 ciastko-malinowe sh[3444]: meter 1: line 6: GPIO6 ● ORNO-OR-WE-504-modbus@ttyUSB0.service - Scrape ORNO OR-WE-504 meters over modbus on device ttyUSB0 Loaded: loaded (/usr/local/lib/systemd/system/ORNO-OR-WE-504-modbus@.service; enabled; vendor preset: enabled) Drop-In: /run/systemd/system/ORNO-OR-WE-504-modbus@.service.d └─upa.conf Active: active (running) since Mon 2023-02-13 21:22:55 CET; 24h ago Main PID: 3443 (ORNO-OR-WE-504-) Tasks: 1 (limit: 853) Memory: 96.0K CPU: 13.530s CGroup: /system.slice/system-ORNO\x2dOR\x2dWE\x2d504\x2dmodbus.slice/ORNO-OR-WE-504-modbus@ttyUSB0.service └─3443 /usr/local/sbin/ORNO-OR-WE-504-modbus /dev/ttyUSB0 Feb 13 21:22:55 ciastko-malinowe systemd[1]: Started Scrape ORNO OR-WE-504 meters over modbus on device ttyUSB0. ● snmpd.service - Simple Network Management Protocol (SNMP) Daemon. Loaded: loaded (/lib/systemd/system/snmpd.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/snmpd.service.d └─override.conf Active: active (running) since Mon 2023-02-13 21:22:55 CET; 24h ago Process: 3445 ExecStartPre=/bin/mkdir -p /var/run/agentx (code=exited, status=0/SUCCESS) Main PID: 3448 (snmpd) Tasks: 3 (limit: 853) Memory: 1.4M CPU: 3min 5.084s CGroup: /system.slice/snmpd.service ├─3448 /usr/sbin/snmpd -LOw -u Debian-snmp -g Debian-snmp -I system_mib snmp_mib hr_system hw_sensors pass_persist extend -f -p /run/snmpd.pid ├─3449 /usr/local/libexec/ORNO-OR-WE-505-snmp /ORNO505 └─3453 /usr/local/libexec/ORNO-OR-WE-504-snmp /dev/ttyUSB0 Feb 13 21:22:55 ciastko-malinowe systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon.... Feb 13 21:22:55 ciastko-malinowe systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon.. Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: Cannot rename /var/lib/snmp/snmpd.conf to /var/lib/snmp/snmpd.0.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: Cannot unlink /var/lib/snmp/snmpd.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: read_config_store open failure on /var/lib/snmp/snmpd.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: read_config_store open failure on /var/lib/snmp/snmpd.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: read_config_store open failure on /var/lib/snmp/snmpd.conf nabijaczleweli@ciastko-malinowe:~$ systemctl status dupa@'5\x206' ORNO-OR-WE-504-modbus@ttyUSB0.service snmpd ● dupa@5\x206.service - 5\x206 test 5 6 Loaded: loaded (/run/systemd/system/dupa@.service; static) Active: active (running) since Mon 2023-02-13 21:22:55 CET; 24h ago Main PID: 3444 (ORNO-OR-WE-505-) Tasks: 1 (limit: 853) Memory: 148.0K CPU: 7.764s CGroup: /system.slice/system-dupa.slice/dupa@5\x206.service └─3444 /usr/local/sbin/ORNO-OR-WE-505-gpio /ORNO505 5 6 Feb 13 21:22:55 ciastko-malinowe systemd[1]: Started 5\x206 test 5 6. Feb 13 21:22:55 ciastko-malinowe sh[3444]: gpiochip0: pinctrl-bcm2835 w/54 lines Feb 13 21:22:55 ciastko-malinowe sh[3444]: meter 0: line 5: GPIO5 Feb 13 21:22:55 ciastko-malinowe sh[3444]: meter 1: line 6: GPIO6 ● ORNO-OR-WE-504-modbus@ttyUSB0.service - Scrape ORNO OR-WE-504 meters over modbus on device ttyUSB0 Loaded: loaded (/usr/local/lib/systemd/system/ORNO-OR-WE-504-modbus@.service; enabled; vendor preset: enabled) Drop-In: /run/systemd/system/ORNO-OR-WE-504-modbus@.service.d └─upa.conf Active: active (running) since Mon 2023-02-13 21:22:55 CET; 24h ago Main PID: 3443 (ORNO-OR-WE-504-) Tasks: 1 (limit: 853) Memory: 96.0K CPU: 13.530s CGroup: /system.slice/system-ORNO\x2dOR\x2dWE\x2d504\x2dmodbus.slice/ORNO-OR-WE-504-modbus@ttyUSB0.service └─3443 /usr/local/sbin/ORNO-OR-WE-504-modbus /dev/ttyUSB0 Feb 13 21:22:55 ciastko-malinowe systemd[1]: Started Scrape ORNO OR-WE-504 meters over modbus on device ttyUSB0. ● snmpd.service - Simple Network Management Protocol (SNMP) Daemon. Loaded: loaded (/lib/systemd/system/snmpd.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/snmpd.service.d └─override.conf Active: active (running) since Mon 2023-02-13 21:22:55 CET; 24h ago Process: 3445 ExecStartPre=/bin/mkdir -p /var/run/agentx (code=exited, status=0/SUCCESS) Main PID: 3448 (snmpd) Tasks: 3 (limit: 853) Memory: 1.4M CPU: 3min 5.084s CGroup: /system.slice/snmpd.service ├─3448 /usr/sbin/snmpd -LOw -u Debian-snmp -g Debian-snmp -I system_mib snmp_mib hr_system hw_sensors pass_persist extend -f -p /run/snmpd.pid ├─3449 /usr/local/libexec/ORNO-OR-WE-505-snmp /ORNO505 └─3453 /usr/local/libexec/ORNO-OR-WE-504-snmp /dev/ttyUSB0 Feb 13 21:22:55 ciastko-malinowe systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon.... Feb 13 21:22:55 ciastko-malinowe systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon.. Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: Cannot rename /var/lib/snmp/snmpd.conf to /var/lib/snmp/snmpd.0.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: Cannot unlink /var/lib/snmp/snmpd.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: read_config_store open failure on /var/lib/snmp/snmpd.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: read_config_store open failure on /var/lib/snmp/snmpd.conf Feb 13 21:22:56 ciastko-malinowe snmpd[3448]: read_config_store open failure on /var/lib/snmp/snmpd.conf](https://staging.cohostcdn.org/attachment/8d072d13-25e7-4c8d-9022-8e2af6d5b777/a.png?width=675&dpr=1)



![$ systemctl status dev-gpiochip0.device ● dev-gpiochip0.device - /dev/gpiochip0 Loaded: loaded Active: inactive (dead) Feb 23 23:20:11 ciastko-malinowe systemd[1]: dev-gpiochip0.device: Job dev-gpiochip0.device/start timed out. Feb 23 23:20:11 ciastko-malinowe systemd[1]: Timed out waiting for device /dev/gpiochip0. Feb 23 23:20:11 ciastko-malinowe systemd[1]: dev-gpiochip0.device: Job dev-gpiochip0.device/start failed with result 'timeout'. $ ls -l /dev/gpiochip0 crw------- 1 root root 254, 0 Aug 7 2022 /dev/gpiochip0 $ udevadm info /dev/gpiochip0 P: /devices/platform/soc/20200000.gpio/gpiochip0 N: gpiochip0 L: 0 E: DEVPATH=/devices/platform/soc/20200000.gpio/gpiochip0 E: DEVNAME=/dev/gpiochip0 E: OF_NAME=gpio E: OF_FULLNAME=/soc/gpio@7e200000 E: OF_COMPATIBLE_0=brcm,bcm2835-gpio E: OF_COMPATIBLE_N=1 E: MAJOR=254 E: MINOR=0 E: SUBSYSTEM=gpio $ systemctl list-dependencies --reverse dev-gpiochip0.device dev-gpiochip0.device ● └─ORNO-OR-WE-505-gpio@5\x206.service $ systemctl status dev-gpiochip0.device ● dev-gpiochip0.device - /dev/gpiochip0 Loaded: loaded Active: inactive (dead) Feb 23 23:20:11 ciastko-malinowe systemd[1]: dev-gpiochip0.device: Job dev-gpiochip0.device/start timed out. Feb 23 23:20:11 ciastko-malinowe systemd[1]: Timed out waiting for device /dev/gpiochip0. Feb 23 23:20:11 ciastko-malinowe systemd[1]: dev-gpiochip0.device: Job dev-gpiochip0.device/start failed with result 'timeout'. $ ls -l /dev/gpiochip0 crw------- 1 root root 254, 0 Aug 7 2022 /dev/gpiochip0 $ udevadm info /dev/gpiochip0 P: /devices/platform/soc/20200000.gpio/gpiochip0 N: gpiochip0 L: 0 E: DEVPATH=/devices/platform/soc/20200000.gpio/gpiochip0 E: DEVNAME=/dev/gpiochip0 E: OF_NAME=gpio E: OF_FULLNAME=/soc/gpio@7e200000 E: OF_COMPATIBLE_0=brcm,bcm2835-gpio E: OF_COMPATIBLE_N=1 E: MAJOR=254 E: MINOR=0 E: SUBSYSTEM=gpio $ systemctl list-dependencies --reverse dev-gpiochip0.device dev-gpiochip0.device ● └─ORNO-OR-WE-505-gpio@5\x206.service](https://staging.cohostcdn.org/attachment/a8b9094e-8249-4945-b87c-0927bd14c9d1/a.png?width=675&dpr=1)





![$ cat ss.4091973 pipe2([5, 6], O_CLOEXEC) = 0 fcntl(5, F_GETFL) = 0 (flags O_RDONLY) vfork() = 4091974 close(6) = 0 dup2(4, 1) = 1 read(4, "GET /metrics HTTP/1.1\r\nHost: loc"..., 4096) = 246 fstat(1, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0 fstat(5, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 read(5, "ORNO-MIB::ornoOrWe504DeviceIndex"..., 4096) = 1859 write(1, "HTTP/1.1 200 OK\r\nContent-Type: a"..., 4096) = 4096 read(5, "", 4096) = 0 write(1, "ornoOrWe505Energy counter\n# HELP"..., 269) = 269 exit_group(0) = ? +++ exited with 0 +++ $ cat ss.4091973 pipe2([5, 6], O_CLOEXEC) = 0 fcntl(5, F_GETFL) = 0 (flags O_RDONLY) vfork() = 4091974 close(6) = 0 dup2(4, 1) = 1 read(4, "GET /metrics HTTP/1.1\r\nHost: loc"..., 4096) = 246 fstat(1, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0 fstat(5, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 read(5, "ORNO-MIB::ornoOrWe504DeviceIndex"..., 4096) = 1859 write(1, "HTTP/1.1 200 OK\r\nContent-Type: a"..., 4096) = 4096 read(5, "", 4096) = 0 write(1, "ornoOrWe505Energy counter\n# HELP"..., 269) = 269 exit_group(0) = ? +++ exited with 0 +++](https://staging.cohostcdn.org/attachment/e7edc758-bbb0-4c8d-8176-8e3ab2aa3d40/a.png?width=675&dpr=1)

