[CUL transport] Fix for issue with CUL transport race condition

Hi there,

I’ve opened this issue on github, related to a race condition, which occurs in my system, when sending many Intertechno commands by a rule.

I would be happy, if someone can test my changes, especially with other bindings than Intertechno. I’m using it for about a month with Intertechno, without any problems.

You can download the updated bundle here: org.openhab.io.transport.cul-1.11.0-SNAPSHOT.jar

Cheers
Mik

High Mik,
in order to test both of your .jars (CUL Intertechno binding and CUL transport), do I need to put both of them into the addons folder? Since the late isn’t a binding I’m not sure on that. (Preparing myself to start testing when hardware is delivered ).

Yes, just drop both in your addons folder. It doesn’t matter, if it’s a binding, transport or anything else.

Had both .jars in the addons folder of a fresh install of the snapshot version(1099) and got those in the log:

19:48:50.123 [ERROR] [org.openhab.io.transport.cul ] - FrameworkEvent ERROR - org.openhab.io.transport.cul
org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.transport.cul [202]
Unresolved requirement: Import-Package: org.openhab.core.binding

    at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1599) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]

and

19:49:10.302 [ERROR] [org.openhab.binding.intertechno ] - FrameworkEvent ERROR - org.openhab.binding.intertechno
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.intertechno [201]
Unresolved requirement: Import-Package: org.openhab.core.binding

    at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]

Hi Jürgen,

can you try this?
Install the 1.x compatibility layer.

First, enter the karaf console from inside your system by:

ssh -p 8101 openhab@localhost

The default password is “habopen”.
Then install the compatibility layer by:

openhab> feature:install openhab-runtime-compat1x

Maybe, you have to restart your system or load the new bundles manualy.

You can also use the karaf console to enable TRACE information for the two bundles:

openhab> log:set TRACE org.openhab.binding.intertechno
openhab> log:set TRACE org.openhab.io.transport.cul
openhab> log:tail

and to reset to normal log level:

openhab> log:set INFO org.openhab.binding.intertechno
openhab> log:set INFO org.openhab.io.transport.cul

Didn’t think of the compatibility layer, will try that and continue.

I have both .jars working now. In between I hab a situation when I lost the ssh connection out off a unknown reason. When restablishing the login to the Karaf-console did take minutes, so I rebooted the system, which was also delayed for minutes. That started after I changed the .item file in order to use the syntax (no address anymore, only commandON and CommandOFF)

After the restart it seems to be running fine.

I’m actually having problems to get the RF messages handles by some of sockets correctly ( for example: on one socket ON/OFF from the original remote is working, via CUL only only OFF is working), so I can’t test the sending of several messages to different sockets in a short time.That problem has nothing to do with your bindings!
I do have no such problem using my oldest sockets (>25 years, “hard-wired” code).

I can’t say, if the hang is related to my changes. Maybe if you have some logs for me.

But I’m happy to hear, that everything is now working as expected. Can you give me some feedback in a few days, if still working then?

Hi Mik,
I also had a deep look into the CUL IO binding, because I see that openhab sends “X” to the CUL device after each receiving command. This is the “credit report”. fhem does not.

I think it is not necessary to send a credit report after each receiving command. I see that, due to the “credit report” the binding can not get all update messages form a FHT sender.

I found in “…/openhab/io/transport/cul/internal/AbstractCULHandler.java” in the function “processNextLine” the call of requestCreditReport().

I have disabled this line (line no. 223) and it works.
May you build a .jar with your and my changes and I will test that.

protected void processNextLine(String data) {
    log.debug("Received raw message from CUL: " + data);
    if ("EOB".equals(data)) {
        log.warn("(EOB) End of Buffer. Last message lost. Try sending less messages per time slot to the CUL");
        return;
    } else if ("LOVF".equals(data)) {
        log.warn(
                "(LOVF) Limit Overflow: Last message lost. You are using more than 1% transmitting time. Reduce the number of rf messages");
        return;
    } else if (data.matches("^d+s+d+")) {
        processCreditReport(data);
        return;
    }
    notifyDataReceived(data);
    requestCreditReport();
}

Regards
Andy

Hi Andy,
I’m happy to get some additional response on this topic.

As you can see in my pull request, I already removed this request for a credit report. Did you test the bundle from the starting post in this thread?

I also don’t know, if it’s actually necessary to get a credit report after each transmitted command at all. The result isn’t used anywhere, as far as I can see.

Anyway, I appreciate your testing with an other binding than Intertechno, which I’m using, very much.

Hi Mik,
I did not see your pull request so far.
My experience with git is at the beginning and I do not want to do something wrong.
So build my own version without credit request locally outside of git.

I will start to use your .jar this evening and let you know about the test result in the next days.

Andy

Hi Mik,
my first test was successful. FHT binding still works. This weekend I will configure FS20 devices.
Also Intertechno with a second CUL.

I will let you know.

Andy

Great,
if you are going to test Intertechno, you can also test my adopted Intertechno binding described here. It adds support for V3 protocol.

Here is the description of the changes I made:

Intertechno V3

{ culintertechno="type=v3;id=01101011000011110000000000;channel=2" }

You have to provide the 26 digits id and the channel (0-15). Optional, you can provide the group parameter (with value “1”) , which results in switching all items with the given id.

{ culintertechno="type=v3;id=01101011000011110000000000;group=1" }

Raw mode

If you have an unsupported intertechno device you can fallback to the raw mode

{ culintertechno="type=raw;commandOn=FF00FF00FF;commandOff=FF00FF00F0" }

This configuration allows you to manual specify the complete commands to send in either ON or OFF state. The given commands will be sent directly to the CUL (prefixed with “is”).

1 Like

Ok, I wll test your Intertechno binding and let you know.

Andy

I do not understand why my OH is ignoring the 2 jars I added…

Okay, so I removed the built in intertechno binidng via PaperUI and it works great now!

I can finally control my intertechno V3! :smiley:
and I am getting closer to my add old sockets that work with 1F… and 0F… (not working consistently yet).

Wow, insanely unlucky.

I moved my CUL earlier, and it just was about not reaching my socket.

Anyway, now everything works!
V3 and old sockets:

Switch Funkstecker1 "Test1" { culintertechno="type=raw;commandOn=0F0F0FFFFFFF;commandOff=1F0F0FFFFFFF" }
Switch SmartWares0 "SmartWares0" { culintertechno="type=v3;id=01011011001000001011100010;channel=0" }
Switch SmartWares1 "SmartWares1" { culintertechno="type=v3;id=01011011001000001011100010;channel=1" }
Switch SmartWares2 "SmartWares2" { culintertechno="type=v3;id=01011011001000001011100010;channel=2" }

I love your binding so far!

Glad you got it working! You see reading other posts and reading the docs does help!

1 Like

Yeah, is finally got it all to work.

Next challenge is Max! (I think it can figure it out) and sitemaps…
Confusing me.

I’ll open a new thread for that.

Thanks.

Your PR broke the initial filling of credit10ms
-> https://github.com/openhab/openhab1-addons/issues/5753

We should fix it or revert it.

In general i think its a good behavior to check credits before
sending a message instead of running in an error.