Lucifer06 / RemoteGPIO

Remote General Purpose I/O for Venus OS devices (Cerbo GX, ...)
12 stars 3 forks source link

Digital Input doesn't work with RaspBerry #30

Open Lucifer06 opened 6 months ago

Lucifer06 commented 6 months ago

Relays confirm to work with RaspBerry, but Digital Input won't. It will require additional work for making Digital Inputs working with RaspBerry. This was tested with Venus 3.40-2 and RemoteGPIO 3.2.2

cbelcher commented 6 months ago

Yup, sure does. It's a symptom though, not the cause of it tracing back. What the heck is going on.

cbelcher commented 6 months ago

So I've proved what causes /service/dbus-digitalinput to traceback on my bone stock Cerbo GX MK2. Firmware: v3.40~10 SetupHelper: v7.18 GuiMods: v10.24 ShutdownMonitor: v3.2 RemoteGPIO: v3.3.2

If you configure any Digital input that exists on the DT-R008, it traces immediately. If you disable them the service runs forever. Configure native DI's 1-4, no issue.

Going to rebuild this from scratch and see if I have the same results, If so, maybe it's my Cerbo MK2? We shall see.

Can one of you list your Firmware and Package versions your running, that you know works?

Lucifer06 commented 6 months ago

On my production CerboGX MK1, I'm running 3.31 with latest RemoteGPIO package. On my Dev Cerbo GX MK1, I'm running latest venus beta (3.4.x) and latest RemoteGPIO. Both working perfectly

cbelcher commented 6 months ago

Total OS rebuild on Cerbo GX MK2. Same thing, if this works for you guys it's got to me my MK2? Relays work, local Digital Inputs work, but remote DI's DO NOT work on my Cerbo. Set DI 5 to Door alarm and /service/dbus-digitalinputs traces instantaneously.

I have everything documented, I'll post the build and show you it tracing. Have to go have dinner with mom.

I thought I was nuts, but 2 times same results.

cbelcher commented 6 months ago

Build notes from 2nd attempt.

Total rebuild of Cerbo 2nd time.txt

Anything look odd?

cbelcher commented 6 months ago

Yes, this run I kept Official Large 3.31, latest RemoteGPIO v3.3.2. Last run was with Beta 3.40~10 large, no change.

I’ve seen both the Cerbo and Rpi’s behave very differently when you start from ground zero. Can you also start with a factory default Cerbo and see if you can get it running. It’s the only way I see to test my theory. If it works, then it’s the MK2, if it doesn't (which I don’t believe it will) the SoC is identical to the to the MK1, they’ve flipped some ports orientation’s and changed a single USB-Type A to support data. It’s possible it’s the MK2, but I think unlikely.

The /data/logs/dbus-digitalinputs/current. Don’t look right.

See my “Total rebuild of Cerbo 2nd time.txt” Lines 658 – end

Line 707 shows 4 Registering, all 4 native GPIO’s 1-4 712 is where I change GPIO 5 to Door alarm type 2. I would have had to have configured RemoteGPIO to 1 Unit and 8 Relays at this point. In turn, would have expective the logs to show all 12 Registered before this point, 4 natives + my 8 DT-R008’s. Nope only 4.

Line 726 you see the traceback with a PermissionError, this is where I set DI 5 to Door alarm. Then back to registering 1-4, hits 5 and traces, every 3-4 seconds until I clear it.

930 where I set DI 5 to Disable. only then do I see all 12 Register.

There is an answer to this, just need to find it. And proving it’s not my MK2 would be super helpful.

Let me know, I’ll buy a MK1 if I have to.

From: Lucifer06 @.> Sent: Monday, April 29, 2024 3:58 PM To: Lucifer06/RemoteGPIO @.> Cc: Craig Belcher @.>; Mention @.> Subject: Re: [Lucifer06/RemoteGPIO] Digital Input doesn't work with RaspBerry (Issue #30)

On my production CerboGX MK1, I'm running 3.31 with latest RemoteGPIO package. On my Dev Cerbo GX MK1, I'm running latest venus beta (3.4.x) and latest RemoteGPIO. Both working perfectly

— Reply to this email directly, view it on GitHubhttps://github.com/Lucifer06/RemoteGPIO/issues/30#issuecomment-2083550528, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABB7DNIV54IE5ES7DNGEFJDY72Q3FAVCNFSM6AAAAABF2PSV5OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTGU2TANJSHA. You are receiving this because you were mentioned.Message ID: @.**@.>>

cbelcher commented 6 months ago

Tired mapping around 205-208, still traces. I won’t stop until I find it 😊

From: Derrick @.> Sent: Friday, April 26, 2024 10:10 PM To: Lucifer06/RemoteGPIO @.> Cc: Craig Belcher @.>; Mention @.> Subject: Re: [Lucifer06/RemoteGPIO] Digital Input doesn't work with RaspBerry (Issue #30)

Working.. What the heck is that option there for, lol.... I tried it earlier this morning and it didn't change anything? Been rebuilt 5 times since then, so who knows.

Okay, we have a fully function RPi 4 Model B running RemoteGPIO v3.3.2. Nice..

Now I just copy my S90 to my git folder then do what, a commit?

The option is there because not everyone will use the feature, and disabling it saves on system resources. Same reason with reading relays option.

— Reply to this email directly, view it on GitHubhttps://github.com/Lucifer06/RemoteGPIO/issues/30#issuecomment-2080320428, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABB7DNPGNRLS4QCIO3ZOZITY7MCF7AVCNFSM6AAAAABF2PSV5OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBQGMZDANBSHA. You are receiving this because you were mentioned.Message ID: @.**@.>>

cbelcher commented 6 months ago

No matter where I map the gpio2xx to on the Cerbo. it creates this edge file. The RPi does not.

It cannot be there. Will never work, as it traces it just appends a “both” to the file until I stop it.

Cerbo GX MK2 after mapping digital_intput_5 to 209, did the same thing on every mapping. Including the default gpio205. @.:/dev/gpio/digital_input_5# ls -lah drwxr-xr-x 3 root root 4.0K Apr 30 00:18 . drwxr-xr-x 34 root root 4.0K Feb 23 16:23 .. -rw-r--r-- 1 root root 2 Feb 22 23:14 active_low lrwxrwxrwx 1 root root 18 Feb 22 23:14 device -> ../../../gpiochip0 -rw-r--r-- 1 root root 3 Feb 22 23:14 direction -rw-r--r-- 1 root root 20 Apr 30 00:18 edge <-- 1 minutes it’s already 20 bytes, shouldn’t even be there. lrwxrwxrwx 1 root root 34 Feb 23 15:18 gpio209 -> /data/rgpio/sys/class/gpio/gpio209 drwxr-xr-x 2 root root 4.0K Feb 22 23:14 power lrwxrwxrwx 1 root root 31 Feb 22 23:14 subsystem -> ../../../../../../../class/gpio -rw-r--r-- 1 root root 0 Feb 22 23:14 uevent -rw-r--r-- 1 root root 2 Apr 30 01:02 value @.:/dev/gpio/digital_input_5# cat edge bothbothbothbothboth @.***:/dev/gpio/digital_input_5#

RPi @.:/dev/gpio/digital_input_5# ls -lah drwxr-xr-x 3 root root 4.0K Feb 23 15:18 . drwxr-xr-x 34 root root 4.0K Feb 23 16:23 .. -rw-r--r-- 1 root root 2 Feb 22 23:14 active_low lrwxrwxrwx 1 root root 18 Feb 22 23:14 device -> ../../../gpiochip0 -rw-r--r-- 1 root root 3 Feb 22 23:14 direction lrwxrwxrwx 1 root root 34 Feb 23 15:18 gpio209 -> /data/rgpio/sys/class/gpio/gpio209 drwxr-xr-x 2 root root 4.0K Feb 22 23:14 power lrwxrwxrwx 1 root root 31 Feb 22 23:14 subsystem -> ../../../../../../../class/gpio -rw-r--r-- 1 root root 0 Feb 22 23:14 uevent -rw-r--r-- 1 root root 2 Apr 30 01:24 value @.:/dev/gpio/digital_input_5#

No, edge file. Works!

I’m on to something, just need to divide and concur to rule out what it’s not.

From: Derrick @.> Sent: Friday, April 26, 2024 10:10 PM To: Lucifer06/RemoteGPIO @.> Cc: Craig Belcher @.>; Mention @.> Subject: Re: [Lucifer06/RemoteGPIO] Digital Input doesn't work with RaspBerry (Issue #30)

Working.. What the heck is that option there for, lol.... I tried it earlier this morning and it didn't change anything? Been rebuilt 5 times since then, so who knows.

Okay, we have a fully function RPi 4 Model B running RemoteGPIO v3.3.2. Nice..

Now I just copy my S90 to my git folder then do what, a commit?

The option is there because not everyone will use the feature, and disabling it saves on system resources. Same reason with reading relays option.

— Reply to this email directly, view it on GitHubhttps://github.com/Lucifer06/RemoteGPIO/issues/30#issuecomment-2080320428, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABB7DNPGNRLS4QCIO3ZOZITY7MCF7AVCNFSM6AAAAABF2PSV5OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBQGMZDANBSHA. You are receiving this because you were mentioned.Message ID: @.**@.>>

cbelcher commented 6 months ago

@Lucifer06 @drtinaz

I know I've asked you before if you were familiar with the /opt/victronenergy/dbus-digitalinputs/dbus-digitalinputs.py script where you added the 'Transfer switch'. This is the script creating/appending the "both" to the edge file every time dbus-digitainputs service starts. The edge file is not created on the RPi and works.

The file is created here. Still can't figure out how to get this thing to format like I want it to :(

`class EpollPulseCounter(BasePulseCounter): def init(self): self.gpiomap = {} self.states = {} self.ob = epoll()

def register(self, path, gpio):
    path = os.path.realpath(path)

    # Set up gpio for rising edge interrupts
    with open(os.path.join(path, 'edge'), 'ab') as fp:
        fp.write(b'both')`

Guess I need to query dbus to see what's different between the 2 platforms. Cerbo the edge file is created and the RPi it's not.

Still don't know if this is my MK2 or not, but the fact is RemoteGPIO Digital inputs DO NOT function on it. Relays no issue.

Curious, either of you guys have edge files in gpio205 if you enable Input 5 on your MK1's?

I may need some help on this one?

cbelcher commented 6 months ago

@Lucifer06 @drtinaz

I see what's going on. Can you either of you check your Cerbo's to see if the flags parameter is set in the dbus_digitalinputs.py process? It should not. It will show up between "dbus_digitalinputs.py (here) /dev/gpio/digital_input_1"

Like this.

RPi dbus_digitalinputs.py --poll=poll /dev/gpio/digital_input_1

Cerbo GX MK2 dbus_digitalinputs.py /dev/gpio/digital_input_1

If that flag is not set to "--poll=poll" there is no way the remote DI's can function.

Going to prove it right after this. It's all in the start-digitalinput.sh file. Haven't tested, but I'll the farm that the Native DI's will work on my Cerbo. Since they require the edge file to be present and set to "none".

And while you're at it, tell me if gpio205 has the edge file present.

drtinaz commented 6 months ago

Guimods is responsible for modifying the digital inputs python script so you might hit up @kwindrem and see if he has any insight.

cbelcher commented 6 months ago

I think I’ve got it, not a solution but to prove my theory. If it holds, then the problem definition is at hand.

Keep you posted, will know in about 5 minutes.

D, you in front of your Cerbo? Or you at work?

From: Derrick @.> Sent: Tuesday, April 30, 2024 10:23 AM To: Lucifer06/RemoteGPIO @.> Cc: Craig Belcher @.>; Mention @.> Subject: Re: [Lucifer06/RemoteGPIO] Digital Input doesn't work with RaspBerry (Issue #30)

Guimods is responsible for modifying the digital inputs python script so you might hit up @kwindremhttps://github.com/kwindrem and see if he has any insight.

— Reply to this email directly, view it on GitHubhttps://github.com/Lucifer06/RemoteGPIO/issues/30#issuecomment-2085466899, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABB7DNOJMSLML7RKPBNKOODY76SN3AVCNFSM6AAAAABF2PSV5OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBVGQ3DMOBZHE. You are receiving this because you were mentioned.Message ID: @.**@.>>

drtinaz commented 6 months ago

I have just finished migrating all of my automation's over to a Rpi4 running home assistant OS with node red integrated. Home assistant is now in full control of everything, though it took a few days to accomplish. I was forced into a crash course of MQTT communications between the cerbo and HA. I am no longer running RemoteGPIO natively on the GX and I don't currently have my test system setup. I don't have an 8 relay module so I would't be much help in that regard anyway. I am now using TCP/IP through node red which integrates the relay settings and overview in the Cerbo via MQTT.

On a side note, I am extremely happy with my setup now. Home assistant is by far a much nicer GUI and the cerbo is now restricted to only doing cerbo things which has resulted in a much snappier and more responsive experience. I have a lot of Victron components connected to the cerbo and it really was not designed to handle a lot of extra load put on it by all these add-ons.

kwindrem commented 6 months ago

My RPI4 has the ...edge... file but my Cerbo does not. I'm sure it's a MK1 Cerbo.

I doubt that the Dingtian module would provide pulse-counter functionality. If not, you may need to modify other parts of the digital input code to insure it's not selectable and to insure the functions associated with it don't get called.

cbelcher commented 6 months ago

@Lucifer06 Theory proved,

I've got both native and remote Digital inputs working on Cerbo GX MK2. No more tracebacks every 4 seconds, no more edge files created on the remote gpio devices.

I have the solution, but you guys have to let me know if you can reproduce this on your dev Cerbo MK1's. That will entail a complete Venus OS reinstall and build it back from scratch. I can't see how it's going to work? Take 30 minutes max.

Duplicate mine: Firmware: v3.31 Official release Type: Large Node-RED Enabled SetupHelper: v7.18 GuiMods: v10.24 ShutdownMonitor: v3.2 RemoteGPIO: v3.3.2 1 - Dingtian DT-R008 Hardware Version: V3.6J Software Version: V3.1.3541B

Shortly, there are going to be MK2's all over the place. We have to figure out if this is isolated to just the MK2.

cbelcher commented 6 months ago

@kwindrem, "The Master" joins the thread. Thanks Kevin!

I'd been working on getting these Digital inputs working on the RPi, then I noticed that my code didn't run on my Cerbo. I was like what the heck, didn't change a single line of code that dealt with the Cerbo GX. Did a complete OS reload, and still didn't work. Just 1/2 hour ago I got it working. It's the startdigitalinputs.sh script not setting the flags=--poll=poll then calling dbus_digitalinputs.py. If that flags parameter is null, it causes all sorts of issues with remote DI's. One of which is, they don't work :)

Boy, been fun learning how this all works.

I'm a HomeSeer guy, have been for 15+ years. Tried out HA, just didn't do anything for me. So new to all this, that integration is way down on my list.

Thanks for chiming is! Cheers.

cbelcher commented 6 months ago

The comments in dbus_digitalinputs.py are pretty funny.

` # NOTE: There has not been a report of a missed interrupt yet.

Belts and suspenders.`

Least he's having fun...

@kwindrem What's --poll=poll, parameters role in this script? It's getting pretty deep, can you sum it up in a sentence or 2?

kwindrem commented 6 months ago

I am by no means the master of digital inputs code. My best guess is that poll has to do with how information about some part of a digital input is obtained. Based on the comment you quoted, my best guess is that some systems use interrupts and some have to pole for changes.

I don't know what will happen if you enable poll on systems that aren't currently using it. Might cause issues with the internal digital inputs. So you might need to put polling for the remote digital inputs somewhere else or add code to see if it's a local or remote digital input and base polling on that if poll is not set.

I know the Victron engineers are busy with gui-v2 but might be prudent to ask for some understanding.

Sorry I can't be of any real help here.

cbelcher commented 6 months ago

@kwindrem

With it set to --poll=poll, native digital inputs show no signs of issues. The di.py script, doesn't even list it as an option.

parser.add_argument('--poll', help='Use a different kind of polling. Options are epoll, dumb and debug', default='epoll')

But for sure if I don't send it the $flags parameter and epoll is the default. It flat out will not detect the state change of a remote digital input.

Thanks again Kevin! Putting this to bed.

Cheers!

gharshaw commented 2 weeks ago

Looking to add this to my RPI but need digital inputs for generator control. Are digital inputs still not working with the RPI's?

cbelcher commented 2 weeks ago

I had is working way back when. Probably still does, looking at the last time anyone has made any changes to the project? Bottom line, don't head down this rabbit hole just use Node-Red. If you never used it like me, took a couple days to get the hang of it. Just crazy powerful, I use it for everything now.

Take my word, don't spend another second with this on your RPI.

gharshaw commented 2 weeks ago

Thanks for the update. Can I ask what you are using for relays on your PI?

cbelcher commented 2 weeks ago

Same make and model all of us, working on the project, were using.

Make: Dingtian Model: DT-R008 Ethernet, WiFi, CAN. Part Number: 8CH ETH WIFI CAN CAS

Got both of them from the same vendor on AliExpress: dtwonder Store

Ordered 1 on 3/13/2024 the 2nd on 6/27/2024. Both out-the-door to FL for $36.92 USD.

Pretty slick, highly recommended.


From: gharshaw @.> Sent: Tuesday, October 15, 2024 12:15 PM To: Lucifer06/RemoteGPIO @.> Cc: Craig Belcher @.>; Mention @.> Subject: Re: [Lucifer06/RemoteGPIO] Digital Input doesn't work with RaspBerry (Issue #30)

Thanks for the update. Can I ask what you are using for relays on your PI?

— Reply to this email directly, view it on GitHubhttps://github.com/Lucifer06/RemoteGPIO/issues/30#issuecomment-2414457745, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABB7DNIEZMDAZGQQZNHVOADZ3U5SFAVCNFSM6AAAAABP7KXTR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJUGQ2TONZUGU. You are receiving this because you were mentioned.Message ID: @.***>

gharshaw commented 2 weeks ago

@cbelcher Are you using the node-red large package with Venus OS on a RPI or a separate RPI running raspberry pi os with node red installed that controls the di and relays? Thanks

cbelcher commented 2 weeks ago

I chose to run Node-Red on a 2nd RPI, just like the flexibility it afforded me for the $40. I don't regret it.

And that is running Ubuntu Server 24.04 LTS 64, didn't have any experience with RPI OS.


From: gharshaw @.> Sent: Tuesday, October 15, 2024 3:19 PM To: Lucifer06/RemoteGPIO @.> Cc: Craig Belcher @.>; Mention @.> Subject: Re: [Lucifer06/RemoteGPIO] Digital Input doesn't work with RaspBerry (Issue #30)

@cbelcherhttps://github.com/cbelcher Are you using the node-red large package with Venus OS on a RPI or a separate RPI running raspberry pi os with node red installed that controls the di and relays? Thanks

— Reply to this email directly, view it on GitHubhttps://github.com/Lucifer06/RemoteGPIO/issues/30#issuecomment-2414824111, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABB7DNNYG7LTQXUWQY35UXDZ3VTFVAVCNFSM6AAAAABP7KXTR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJUHAZDIMJRGE. You are receiving this because you were mentioned.