~nabijaczleweli/TAURON-G13-gpio

Enable GPIO only in the TAURON G13 "Pozostałe godziny doby" tariff, with SNMP inspexion and overrides.
tm_wday %= 7 for asctime() to prevent "???" week-day cross-sunday
kenner moment
Fix EINVAL due to comment fuckup

refs

trunk
browse  log 

clone

read-only
https://git.sr.ht/~nabijaczleweli/TAURON-G13-gpio
read/write
git@git.sr.ht:~nabijaczleweli/TAURON-G13-gpio

You can also use your local clone with git send-email.

#TAURON-G13-gpio builds.sr.ht build status Licence

Enable GPIO only in the TAURON G13 "Pozostałe godziny doby" tariff, with SNMP inspexion and overrides.

https://cohost.org/nabijaczleweli/post/1255159-if-you-re-keeping-sc https://cohost.org/nabijaczleweli/post/1305830-oh-thats-my-gay-ass

You probably want make installmib on clients.

Set CPPFLAGS=-DFAUX in the environment to build a driver that doesn't do any GPIO ops.

$ systemctl status TAURON-G13-gpio@16.service
● TAURON-G13-gpio@16.service - Toggle GPIO 16 in tune with TAURON G13 tariff
     Loaded: loaded (/run/systemd/system/TAURON-G13-gpio@.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-03-07 15:24:38 CET; 1h 23min ago
   Main PID: 1536 (TAURON-G13-gpio)
      Tasks: 1 (limit: 853)
     Memory: 92.0K
        CPU: 99ms
     CGroup: /system.slice/system-TAURON\x2dG13\x2dgpio.slice/TAURON-G13-gpio@16.service
             └─1536 /usr/local/libexec/TAURON-G13-gpio 16

Mar 07 15:24:38 ciastko-malinowe systemd[1]: Started Toggle GPIO 16 in tune with TAURON G13 tariff.
Mar 07 15:24:38 ciastko-malinowe TAURON-G13-gpio[1536]: Going UP
Mar 07 15:24:38 ciastko-malinowe TAURON-G13-gpio[1536]: gpiochip0: pinctrl-bcm2835 w/54 lines
Mar 07 15:24:38 ciastko-malinowe TAURON-G13-gpio[1536]: line 16: GPIO16
Mar 07 15:24:38 ciastko-malinowe TAURON-G13-gpio[1536]: Next: Tue Mar  7 16:00:01 2023
Mar 07 16:00:01 ciastko-malinowe TAURON-G13-gpio[1536]: Going DOWN
Mar 07 16:00:01 ciastko-malinowe TAURON-G13-gpio[1536]: Next: Tue Mar  7 21:00:01 2023
$ lsgpio | grep -e ^GPIO -e TAURON
GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines
        line 16: "GPIO16" "TAURON-G13-gpio.c" [used, input, pull-down]
$ journalctl -u TAURON-G13-gpio@16.service -qn2
Mar 07 21:00:01 ciastko-malinowe TAURON-G13-gpio[1536]: Going UP
Mar 07 21:00:01 ciastko-malinowe TAURON-G13-gpio[1536]: Next: Wed Mar  8 07:00:01 2023
$ lsgpio | grep -e ^GPIO -e TAURON
GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines
        line 16: "GPIO16" "TAURON-G13-gpio.c" [used, input, pull-up]

(After 6 days, the CPU time reached 111ms.)

#SNMP MIB
$ snmptranslate .iso.org.dod.internet.private.tauronG13 -Tp
+--tauronG13(1850159411)
   |
   +--tauronG13MIB(0)
   |
   +--tauronG13GpioTable(1)
      |
      +--tauronG13GpioProcess(0)
         |  Index: tauronG13GpioLine
         |
         +-- -R-- Integer32 tauronG13GpioLine(0)
         |        Range: 0..63
         +-- -R-- Integer32 tauronG13GpioPid(1)
         +-- -R-- EnumVal   tauronG13GpioStatus(2)
         |        Values: down(0), up(1)
         +-- -RW- EnumVal   tauronG13GpioOverride(3)
                  Values: none(0), down(1), up(2), perm-down(3), perm-up(4)
$ snmpbulkwalk -Cc ciastko-malinowe tauronG13
TAURON-G13-MIB::tauronG13GpioLine.16 = INTEGER: 16
TAURON-G13-MIB::tauronG13GpioPid.16 = INTEGER: 11618
TAURON-G13-MIB::tauronG13GpioStatus.16 = INTEGER: up(1)
TAURON-G13-MIB::tauronG13GpioOverridden.16 = INTEGER: none(0)
TAURON-G13-MIB::tauronG13GpioNext.16 = STRING: "Tue Mar 14 07:00:01 2023"

snmpd.conf:

pass .1.3.6.1.4.1850159411.1.0 /usr/local/libexec/TAURON-G13-snmp

and then snmpset ciastko-malinowe TAURON-G13-MIB::tauronG13GpioOverridden.16 = up should work.

#PHY
GPIO16 connected to n-channel MOSFET gate; source connected to ground, drain to 5V through a relay coil
#IPC

All the interesting data is in a mapping in /run/TAURON-G13-gpio/{line}/{pid}.

Setting an override happens by sigqueue(SIGURG)ing with a 0-5 integer to {pid}.

#KENNER REL-2P datasheet

The only extant digital version, it'd appear.

Datasheet for kenner's "Przekaźnik elektromagnetyczny REL-2P"