Page 1 of 1

Connect4 a problem in slicing bytes! for variable x2out and some led colors

Posted: 13 Sep 2024, 11:19
by Ayman
Hello, my name is Ayman,

I'm new to Revolution PI, I managed to get a connect4 with DIO module 28 inputs/outputs. I'm trying to control the 5 Status LEDs on the Revolution PI Connect4, there's maybe a problem in the library revpimodio2 especially device.py file, when I looked on configuration of the class and the class itself, there were function for every LEDs to set a value to it, or get its state, Except for x2in and x2out.

Also, for in creating the objects for the WD, x2in and x2out there also was a problem:

Code: Select all

        
        # IO Objekte für WD und X2 in/out erzeugen
        self.x2in = IOBase(
            self,
            ["core.x2in", 0, 1, self._slc_statusbyte.start, exp_x2in, None, "Connect_X2_IN", "6"],
            INP,
            "little",
            False,
        )
        self.x2out = IOBase(
            self,
            ["core.x2out", 0, 1, self._slc_led.start, exp_x2out, None, "Connect_X2_OUT", "6"],
            OUT,
            "little",
            False,
        )
You can see easily that WD is not defined at all, and also for x2out which I think must take the parameter "self._slc_output" instead "self._slc_led" to write the byte of the relay, because I looked the byte of RevPiLED and and RevPiOutput they were different from each other, so that what got me to think that the parameter which is passed to self.x2out objects is not the right one!
I tried also to activate the 'wd' object by using this script from the forum RevPiModIO/RevPiModIO and that was the question in German "Watchdog bei einem Connect 4 mit RevPiModIO toggeln?" and Sven respond with that script :

Code: Select all

import revpimodio2
rpi = revpimodio2.RevPiModIO(autorefresh=True)

rpi.core.wd_toggle()

rpi.exit()
So, I used it and I got error "AttributeError: 'Connect4' object has no attribute 'wd_toggle'". So, which pretty normal for me, because the object wasn't created in the Connect4 class under the file device.py!!

So, I tried to toggle the relay be typing this command directly to the terminal 'piTest -w 119.0.1' I got message Length must be one of 1|2|4. So, I type again 'piTest -w 119.1.1' and the relay is closed, and 'piTest -w 119.1.0' to open it again.

Also, I figured out that when you use the alternative '.core.A1 = revpimodio2.GREEN' that you proposed on the website 'https://revpimodio.org/en/doc2/core/#connect' the led actually goes red instead of green, and if you type '.core.A1 = revpimodio2.RED' you get green !!

So I hope I get a quick answer and explanation about these problems or maybe I am wrong about something and I don't see where :D

Re: Connect4 a problem in slicing bytes! for variable x2out and some led colors

Posted: 13 Sep 2024, 12:40
by Ayman
Hello again!

I made some changes to the library on the self.x2out object creation line and it works now! But I still need confirmation to be sure it was just that and nothing else :D

So, the modifications are here, I'm going to add the old line and the new one! I did it just for the Connect4 not for others,because I saw the same line somewhere in the script but to be honest, I cared just about mine :D
the number of creation of the object are between 1299-1305!

Code: Select all

Old Version:
self.x2out = IOBase(
            self,
            ["core.x2out", 0, 1, self._slc_led.start, exp_x2out, None, "Connect_X2_OUT", "6"],
            OUT,
            "little",
            False,
        )


New Version:
        self.x2out = IOBase(
            self,
            ["core.x2out", 0, 1, self._slc_output.start, exp_x2out, None, "Connect_X2_OUT", "0"],
            OUT,
            "little",
            False,
        )

I added the old version just to show what you have to change! So, you need just replace the
self._slc_led.start
with the
self._slc_output.start
, and number 6 with 0!

I tried it with the LEDs and everything is fine. So now it is up to you guys to do the right action for the green and red part of the original post :lol:
Also, I found out that if you use the alternative '.core.A1 = revpimodio2.GREEN' that you suggested on the website 'https://revpimodio.org/en/doc2/core/#connect' the LED actually goes red instead of green, and if you type '.core.A1 = revpimodio2.RED' you get green !!
.

Re: Connect4 a problem in slicing bytes! for variable x2out and some led colors

Posted: 18 Sep 2024, 10:31
by RevPiModIO
Hi Ayman!

I have an RC1 for RevPiModIO here, which contains your patch for x2out (thanks for your work). In addition, the A1 - A5 properties are repaired there and the constants GREEN, RED now switches the correct LEDs.

It would be great if you could test the version once, the history is on Github (https://github.com/naruxde/revpimodio2/tree/rc)

https://revpimodio.org/dnl/revpimodio2/ ... -1_all.deb

The function wd_toggle() no longer exists on the RevPi Connect 4, because KUNBUS with the Connect 4 no longer provides the hardware Watchdog in the process image. This change is a big hurdle for switching from Connect 3 devices to Connect 4. The hardware Watchdog must now be implemented by the users via other functions :(

Sven

Re: Connect4 a problem in slicing bytes! for variable x2out and some led colors

Posted: 18 Sep 2024, 11:07
by RevPiModIO
I will add a NotImplementedError for wd_toggle on connect 4 devices, to clarify that this function is no longer available due to the changes of KUNBUS to the process image.

https://github.com/naruxde/revpimodio2/ ... 99f094d973

Re: Connect4 a problem in slicing bytes! for variable x2out and some led colors

Posted: 19 Sep 2024, 09:24
by Ayman
RevPiModIO wrote: 18 Sep 2024, 10:31 Hi Ayman!

I have an RC1 for RevPiModIO here, which contains your patch for x2out (thanks for your work). In addition, the A1 - A5 properties are repaired there and the constants GREEN, RED now switches the correct LEDs.

It would be great if you could test the version once, the history is on Github (https://github.com/naruxde/revpimodio2/tree/rc)

https://revpimodio.org/dnl/revpimodio2/ ... -1_all.deb

The function wd_toggle() no longer exists on the RevPi Connect 4, because KUNBUS with the Connect 4 no longer provides the hardware Watchdog in the process image. This change is a big hurdle for switching from Connect 3 devices to Connect 4. The hardware Watchdog must now be implemented by the users via other functions :(

Sven

Hi Sven,

I'm sorry to hear that, because when I decided to buy the Connect 4, the integrated watchdog hardware was one of the options why I chose it! But it's ok, as you said, there are other ways to implement the watchdog, and I did it while waiting for your answer ;) .

I downloaded the rc1 from the branches and tested it, it works correctly, for the colors of the core LEDs and the relay too! I tried the function "wd_toggle()" but it wasn't implemented in the rc1 branch, so I added it myself after reading your second replay :D, it works too!

Thanks for your support, and I am glad that I could do something to help, I will be happy to test or debug some other problems if you need any help, and if I face another problem I will try to solve it and I will let you know ;)

Ayman.