Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle DBus structure on the receiver side #76

Open
RomanMeR opened this issue Aug 26, 2017 · 2 comments
Open

How to handle DBus structure on the receiver side #76

RomanMeR opened this issue Aug 26, 2017 · 2 comments

Comments

@RomanMeR
Copy link

In the Tx DBus Tutorial it's described how one could send a structure using dbusOrder class variable. I would like to have convenient way of unmarshalling such structure on the receiving side. As of now I presumably invented the wheel with the from_marshalled method:

class SensorDescription(object):
    dbusOrder = ['name', 'parameter', 'type']
    def __init__(self, sensor = None):
        if sensor != None:
            self.name = sensor.name
            self.parameter = sensor.parameter
            self.type = sensor.type

    @classmethod
    def from_marshalled(cls, marshalled_item):
        assert isinstance(marshalled_item, list)
        assert len(marshalled_item) == len(SensorDescription.dbusOrder)
        result = cls()
        for i in range(0, len(SensorDescription.dbusOrder)):
            setattr(result, SensorDescription.dbusOrder[i], marshalled_item[i])
        return result

Does txdbus have some way of automatic structure unmarshalling? Maybe I could register my structure on the client side for unmarshalling and txdbus would do for me the same as the code in the from_marshalled class method above?

@cocagne
Copy link
Owner

cocagne commented Aug 28, 2017 via email

@RomanMeR
Copy link
Author

Thank you Tom for the answer!
I'm sorry, but I'm in a such period of life that it's not possible for me to spend even small amout of time on making a patch. Wrote this in order not to create unreasonable expectations.
P.S. Thank you Tom for txdbus, it's really great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants