Tom-Hirschberger / MMM-GPIO-Notifications

Magic Mirror² Module which sends custom notifications based on GPIO events
MIT License
13 stars 3 forks source link

Getting an errno: -22, 0|mm | syscall: 'write', 0|mm | code: 'EINVAL' error at MM start up and not detecting input #21

Closed bayfacalendar closed 6 months ago

bayfacalendar commented 6 months ago

at exportGpio (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_modules/onoff/onoff.js:18:8) 0|mm | at new Gpio (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_modules/onoff/onoff.js:172:36) 0|mm | at Class.registerSinglePin (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_helper.js:296:30) 0|mm | at Class.socketNotificationReceived (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_helper.js:457:10) 0|mm | at Socket. (/home/Admin/MagicMirror/js/node_helper.js:104:11) 0|mm | at Socket.emit (node:events:514:28) 0|mm | at Socket.emitUntyped (/home/Admin/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22) 0|mm | at /home/Admin/MagicMirror/node_modules/socket.io/dist/socket.js:704:39 0|mm | at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { 0|mm | errno: -22, 0|mm | syscall: 'write', 0|mm | code: 'EINVAL' 0|mm | }

Tom-Hirschberger commented 6 months ago

Hi,

It looks like there is a general issue with the onoff library I am using and current installations of Bookworm. There is a open similar issue. I currently do not have solution and not much time to debug. Maybe it is a kernel bug and will be fixed shortly.

18.03.2024 18:18:00 bayfacalendar @.***>:

at exportGpio (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_modules/onoff/onoff.js:18:8) 0|mm | at new Gpio (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_modules/onoff/onoff.js:172:36) 0|mm | at Class.registerSinglePin (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_helper.js:296:30) 0|mm | at Class.socketNotificationReceived (/home/Admin/MagicMirror/modules/MMM-GPIO-Notifications/node_helper.js:457:10) 0|mm | at Socket. (/home/Admin/MagicMirror/js/node_helper.js:104:11) 0|mm | at Socket.emit (node:events:514:28) 0|mm | at Socket.emitUntyped (/home/Admin/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22) 0|mm | at /home/Admin/MagicMirror/node_modules/socket.io/dist/socket.js:704:39 0|mm | at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { 0|mm | errno: -22, 0|mm | syscall: 'write', 0|mm | code: 'EINVAL' 0|mm | }

— Reply to this email directly, view it on GitHub[https://github.com/Tom-Hirschberger/MMM-GPIO-Notifications/issues/21], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ALMFULCSKC4E27BMMVFDKQ3YY4OUNAVCNFSM6AAAAABE4AHYPGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE4TEOBRHE2DCMA]. You are receiving this because you are subscribed to this thread. [Verfolgungsbild][https://github.com/notifications/beacon/ALMFULD5A4TRUF6KFTMOBWTYY4OUNA5CNFSM6AAAAABE4AHYPGWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHIFM6E2I.gif]

bayfacalendar commented 6 months ago

Thank you! was going crazy trying to figure this out!

Tom-Hirschberger commented 6 months ago

Looks like there is a problem with kernel 6.6 that has been released last month. A lot of libraries are broken a the moment (Python and Javascript) some of them will never be fixed.

https://github.com/raspberrypi/linux/issues/6037

I followed this guide https://www.markjunghanns.de/de_DE/index.php/2017/12/27/raspberry-pi-kernel-upgraden-downgraden/ and downgraded my kernel to the previous 6.1 version with

sudo rpi-update 5fc4f643d2e9c5aa972828705a902d184527ae3f

After this everything is working on my Bookworm system. My fully updated Bullseye system still uses 6.1 kernel so no problem there.

Tom-Hirschberger commented 6 months ago

released version 0.2.0 of the module which uses a different library and should work with all raspberry versions without any hacks or downgrade of the kernel.

The new library uses the state of the art libgpiod bindings instead of the deprecated /sys/class/gpio sysfs. Should be fine for future releases, too.

Some tools and the libgpiod-dev package are required to be installed to get the module work. But if you do a npm install after the update they will be installed automatically.

Tom-Hirschberger commented 6 months ago

released version 0.2.0 of the module which uses a different library and should work with all raspberry versions without any hacks or downgrade of the kernel.

The new library uses the state of the art libgpiod bindings instead of the deprecated /sys/class/gpio sysfs. Should be fine for future releases, too.

Some tools and the libgpiod-dev package are required to be installed to get the module work. But if you do a npm install after the update they will be installed automatically

bayfacalendar commented 6 months ago

I'll do an update today and let you know!

Thanks

On Fri, Mar 22, 2024 at 8:34 AM Thomas Hirschberger < @.***> wrote:

released version 0.2.0 of the module which uses a different library and should work with all raspberry versions without any hacks or downgrade of the kernel.

The new library uses the state of the art libgpiod bindings instead of the deprecated /sys/class/gpio sysfs. Should be fine for future releases, too.

Some tools and the libgpiod-dev package are required to be installed to get the module work. But if you do a npm install after the update they will be installed automatically

— Reply to this email directly, view it on GitHub https://github.com/Tom-Hirschberger/MMM-GPIO-Notifications/issues/21#issuecomment-2015110414, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGMXSVYJDARR66Z6H54KROLYZQXN7AVCNFSM6AAAAABE4AHYPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVGEYTANBRGQ . You are receiving this because you authored the thread.Message ID: @.***>

bayfacalendar commented 6 months ago

Hey Tom I upgraded to version 0.2.0, but nothing happens.

in my pm2 logs i see 0|mm | [23.03.2024 14:55.51.016] [LOG] MMM-GPIO-Notifications: Registering pin: 14.

But its not working when I press the button, and gpioinfo shows the pin as unused.

Any Ideas?

Tom-Hirschberger commented 6 months ago

Hi,

do you see any other pins used by opengpio in gpioinfo while MagicMirror is running? Maybe my mapping file is garbage.

Do you see any errors in the error log file (not the output log file)?

23.03.2024 20:57:10 bayfacalendar @.***>:

Hey Tom I upgraded to version 0.2.0, but nothing happens.

in my pm2 logs i see 0|mm | [23.03.2024 14:55.51.016] [LOG] MMM-GPIO-Notifications: Registering pin: 14.

But its not working when I press the button, and gpioinfo shows the pin as unused.

Any Ideas?

— Reply to this email directly, view it on GitHub[https://github.com/Tom-Hirschberger/MMM-GPIO-Notifications/issues/21#issuecomment-2016588340], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ALMFULCA6RTMNK3ZUHIL3NTYZXNBLAVCNFSM6AAAAABE4AHYPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWGU4DQMZUGA]. You are receiving this because you commented. [Verfolgungsbild][https://github.com/notifications/beacon/ALMFULDQFLPBFGBDCFRRR5LYZXNBLA5CNFSM6AAAAABE4AHYPGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYGKZDI.gif]

bayfacalendar commented 6 months ago

I see pin3 which i have setup as a power button. line 3: "SCL1" "shutdown" input active-low [used]

no other errors in the pm2 logs, or in the syslog / journal.

Tom-Hirschberger commented 6 months ago

Can you post the content of your gpioinfo.json file please?

23.03.2024 21:09:44 bayfacalendar @.***>:

I see pin3 which i have setup as a power button. line 3: "SCL1" "shutdown" input active-low [used]

no other errors in the pm2 logs, or in the syslog / journal.

— Reply to this email directly, view it on GitHub[https://github.com/Tom-Hirschberger/MMM-GPIO-Notifications/issues/21#issuecomment-2016591174], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ALMFULARYWKNO3OOHE7TZOTYZXOQNAVCNFSM6AAAAABE4AHYPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWGU4TCMJXGQ]. You are receiving this because you commented. [Verfolgungsbild][https://github.com/notifications/beacon/ALMFULG352WP7HSHEOY62EDYZXOQNA5CNFSM6AAAAABE4AHYPGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYGK6UM.gif]

bayfacalendar commented 6 months ago

{ "gpios": { "ID_SDA": [ 0, 0 ], "ID_SCL": [ 0, 1 ], "SDA1": [ 0, 2 ], "SCL1": [ 0, 3 ], "GPIO_GCLK": [ 0, 4 ], "GPIO5": [ 0, 5 ], "GPIO6": [ 0, 6 ], "SPI_CE1_N": [ 0, 7 ], "SPI_CE0_N": [ 0, 8 ], "SPI_MISO": [ 0, 9 ], "SPI_MOSI": [ 0, 10 ], "SPI_SCLK": [ 0, 11 ], "GPIO12": [ 0, 12 ], "GPIO13": [ 0, 13 ], "TXD1": [ 0, 14 ], "RXD1": [ 0, 15 ], "GPIO16": [ 0, 16 ], "GPIO17": [ 0, 17 ], "GPIO18": [ 0, 18 ], "GPIO19": [ 0, 19 ], "GPIO20": [ 0, 20 ], "GPIO21": [ 0, 21 ], "GPIO22": [ 0, 22 ], "GPIO23": [ 0, 23 ], "GPIO24": [ 0, 24 ], "GPIO25": [ 0, 25 ], "GPIO26": [ 0, 26 ], "GPIO27": [ 0, 27 ], "RGMII_MDIO": [ 0, 28 ], "RGMIO_MDC": [ 0, 29 ], "CTS0": [ 0, 30 ], "RTS0": [ 0, 31 ], "TXD0": [ 0, 32 ], "RXD0": [ 0, 33 ], "SD1_CLK": [ 0, 34 ], "SD1_CMD": [ 0, 35 ], "SD1_DATA0": [ 0, 36 ], "SD1_DATA1": [ 0, 37 ], "SD1_DATA2": [ 0, 38 ], "SD1_DATA3": [ 0, 39 ], "PWM0_MISO": [ 0, 40 ], "PWM1_MOSI": [ 0, 41 ], "STATUS_LED_G_CLK": [ 0, 42 ], "SPIFLASH_CE_N": [ 0, 43 ], "SDA0": [ 0, 44 ], "SCL0": [ 0, 45 ], "RGMII_RXCLK": [ 0, 46 ], "RGMII_RXCTL": [ 0, 47 ], "RGMII_RXD0": [ 0, 48 ], "RGMII_RXD1": [ 0, 49 ], "RGMII_RXD2": [ 0, 50 ], "RGMII_RXD3": [ 0, 51 ], "RGMII_TXCLK": [ 0, 52 ], "RGMII_TXCTL": [ 0, 53 ], "RGMII_TXD0": [ 0, 54 ], "RGMII_TXD1": [ 0, 55 ], "RGMII_TXD2": [ 0, 56 ], "RGMII_TXD3": [ 0, 57 ], "BT_ON": [ 1, 0 ], "WL_ON": [ 1, 1 ], "PWR_LED_OFF": [ 1, 2 ], "GLOBAL_RESET": [ 1, 3 ], "VDD_SD_IO_SEL": [ 1, 4 ], "CAM_GPIO": [ 1, 5 ], "SD_PWR_ON": [ 1, 6 ], "SD_OC_N": [ 1, 7 ] }, "chips": { "gpiochip0": { "ID_SDA": 0, "ID_SCL": 1, "SDA1": 2, "SCL1": 3, "GPIO_GCLK": 4, "GPIO5": 5, "GPIO6": 6, "SPI_CE1_N": 7, "SPI_CE0_N": 8, "SPI_MISO": 9, "SPI_MOSI": 10, "SPI_SCLK": 11, "GPIO12": 12, "GPIO13": 13, "TXD1": 14, "RXD1": 15, "GPIO16": 16, "GPIO17": 17, "GPIO18": 18, "GPIO19": 19, "GPIO20": 20, "GPIO21": 21, "GPIO22": 22, "GPIO23": 23, "GPIO24": 24, "GPIO25": 25, "GPIO26": 26, "GPIO27": 27, "RGMII_MDIO": 28, "RGMIO_MDC": 29, "CTS0": 30, "RTS0": 31, "TXD0": 32, "RXD0": 33, "SD1_CLK": 34, "SD1_CMD": 35, "SD1_DATA0": 36, "SD1_DATA1": 37, "SD1_DATA2": 38, "SD1_DATA3": 39, "PWM0_MISO": 40, "PWM1_MOSI": 41, "STATUS_LED_G_CLK": 42, "SPIFLASH_CE_N": 43, "SDA0": 44, "SCL0": 45, "RGMII_RXCLK": 46, "RGMII_RXCTL": 47, "RGMII_RXD0": 48, "RGMII_RXD1": 49, "RGMII_RXD2": 50, "RGMII_RXD3": 51, "RGMII_TXCLK": 52, "RGMII_TXCTL": 53, "RGMII_TXD0": 54, "RGMII_TXD1": 55, "RGMII_TXD2": 56, "RGMII_TXD3": 57 }, "gpiochip1": { "BT_ON": 0, "WL_ON": 1, "PWR_LED_OFF": 2, "GLOBAL_RESET": 3, "VDD_SD_IO_SEL": 4, "CAM_GPIO": 5, "SD_PWR_ON": 6, "SD_OC_N": 7 } } }

Tom-Hirschberger commented 6 months ago

It looks like GPIO 14 is used by some other function as it is not part of the gpioinfo.json.

I will need to add a message for this case to the module but it will not solve your problem.

Can you switch to any GPIO which is named in file as GPIOX where X is the number of the GPIO?

23.03.2024 21:34:18 bayfacalendar @.***>:

{ "gpios": { "ID_SDA": [ 0, 0 ], "ID_SCL": [ 0, 1 ], "SDA1": [ 0, 2 ], "SCL1": [ 0, 3 ], "GPIO_GCLK": [ 0, 4 ], "GPIO5": [ 0, 5 ], "GPIO6": [ 0, 6 ], "SPI_CE1_N": [ 0, 7 ], "SPI_CE0_N": [ 0, 8 ], "SPI_MISO": [ 0, 9 ], "SPI_MOSI": [ 0, 10 ], "SPI_SCLK": [ 0, 11 ], "GPIO12": [ 0, 12 ], "GPIO13": [ 0, 13 ], "TXD1": [ 0, 14 ], "RXD1": [ 0, 15 ], "GPIO16": [ 0, 16 ], "GPIO17": [ 0, 17 ], "GPIO18": [ 0, 18 ], "GPIO19": [ 0, 19 ], "GPIO20": [ 0, 20 ], "GPIO21": [ 0, 21 ], "GPIO22": [ 0, 22 ], "GPIO23": [ 0, 23 ], "GPIO24": [ 0, 24 ], "GPIO25": [ 0, 25 ], "GPIO26": [ 0, 26 ], "GPIO27": [ 0, 27 ], "RGMII_MDIO": [ 0, 28 ], "RGMIO_MDC": [ 0, 29 ], "CTS0": [ 0, 30 ], "RTS0": [ 0, 31 ], "TXD0": [ 0, 32 ], "RXD0": [ 0, 33 ], "SD1_CLK": [ 0, 34 ], "SD1_CMD": [ 0, 35 ], "SD1_DATA0": [ 0, 36 ], "SD1_DATA1": [ 0, 37 ], "SD1_DATA2": [ 0, 38 ], "SD1_DATA3": [ 0, 39 ], "PWM0_MISO": [ 0, 40 ], "PWM1_MOSI": [ 0, 41 ], "STATUS_LED_G_CLK": [ 0, 42 ], "SPIFLASH_CE_N": [ 0, 43 ], "SDA0": [ 0, 44 ], "SCL0": [ 0, 45 ], "RGMII_RXCLK": [ 0, 46 ], "RGMII_RXCTL": [ 0, 47 ], "RGMII_RXD0": [ 0, 48 ], "RGMII_RXD1": [ 0, 49 ], "RGMII_RXD2": [ 0, 50 ], "RGMII_RXD3": [ 0, 51 ], "RGMII_TXCLK": [ 0, 52 ], "RGMII_TXCTL": [ 0, 53 ], "RGMII_TXD0": [ 0, 54 ], "RGMII_TXD1": [ 0, 55 ], "RGMII_TXD2": [ 0, 56 ], "RGMII_TXD3": [ 0, 57 ], "BT_ON": [ 1, 0 ], "WL_ON": [ 1, 1 ], "PWR_LED_OFF": [ 1, 2 ], "GLOBAL_RESET": [ 1, 3 ], "VDD_SD_IO_SEL": [ 1, 4 ], "CAM_GPIO": [ 1, 5 ], "SD_PWR_ON": [ 1, 6 ], "SD_OC_N": [ 1, 7 ] }, "chips": { "gpiochip0": { "ID_SDA": 0, "ID_SCL": 1, "SDA1": 2, "SCL1": 3, "GPIO_GCLK": 4, "GPIO5": 5, "GPIO6": 6, "SPI_CE1_N": 7, "SPI_CE0_N": 8, "SPI_MISO": 9, "SPI_MOSI": 10, "SPI_SCLK": 11, "GPIO12": 12, "GPIO13": 13, "TXD1": 14, "RXD1": 15, "GPIO16": 16, "GPIO17": 17, "GPIO18": 18, "GPIO19": 19, "GPIO20": 20, "GPIO21": 21, "GPIO22": 22, "GPIO23": 23, "GPIO24": 24, "GPIO25": 25, "GPIO26": 26, "GPIO27": 27, "RGMII_MDIO": 28, "RGMIO_MDC": 29, "CTS0": 30, "RTS0": 31, "TXD0": 32, "RXD0": 33, "SD1_CLK": 34, "SD1_CMD": 35, "SD1_DATA0": 36, "SD1_DATA1": 37, "SD1_DATA2": 38, "SD1_DATA3": 39, "PWM0_MISO": 40, "PWM1_MOSI": 41, "STATUS_LED_G_CLK": 42, "SPIFLASH_CE_N": 43, "SDA0": 44, "SCL0": 45, "RGMII_RXCLK": 46, "RGMII_RXCTL": 47, "RGMII_RXD0": 48, "RGMII_RXD1": 49, "RGMII_RXD2": 50, "RGMII_RXD3": 51, "RGMII_TXCLK": 52, "RGMII_TXCTL": 53, "RGMII_TXD0": 54, "RGMII_TXD1": 55, "RGMII_TXD2": 56, "RGMII_TXD3": 57 }, "gpiochip1": { "BT_ON": 0, "WL_ON": 1, "PWR_LED_OFF": 2, "GLOBAL_RESET": 3, "VDD_SD_IO_SEL": 4, "CAM_GPIO": 5, "SD_PWR_ON": 6, "SD_OC_N": 7 } } }

— Reply to this email directly, view it on GitHub[https://github.com/Tom-Hirschberger/MMM-GPIO-Notifications/issues/21#issuecomment-2016596355], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ALMFULH2YEICVQ7LGJMKGZDYZXRMRAVCNFSM6AAAAABE4AHYPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWGU4TMMZVGU]. You are receiving this because you commented. [Verfolgungsbild][https://github.com/notifications/beacon/ALMFULB2UW3IS3I4HERRBU3YZXRMRA5CNFSM6AAAAABE4AHYPGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYGLIYG.gif]

bayfacalendar commented 6 months ago

amazing! Switched it to GPIO16.

working now. Thank you so much!

Tom-Hirschberger commented 6 months ago

Great.

I will change the code in the next days so any pin can be used even if the name is not starting with GPIO.

23.03.2024 21:53:23 bayfacalendar @.***>:

amazing! Switched it to GPIO16.

working now. Thank you so much!

— Reply to this email directly, view it on GitHub[https://github.com/Tom-Hirschberger/MMM-GPIO-Notifications/issues/21#issuecomment-2016600296], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ALMFULCDFQY33MVJ6VT4XZDYZXTUDAVCNFSM6AAAAABE4AHYPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWGYYDAMRZGY]. You are receiving this because you commented. [Verfolgungsbild][https://github.com/notifications/beacon/ALMFULBWK3LM74U7VCDU7ULYZXTUDA5CNFSM6AAAAABE4AHYPGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYGLQOQ.gif]

Tom-Hirschberger commented 6 months ago

As of Version 0.2.1 you will be able to use GPIOs by their name which is shown in gpioinfo. I will close the issue as the intial problem should be solved. Feel free to open a new one or reopen it if you face any problems.