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

Error while receiving package #44

Closed
michapr opened this issue Feb 6, 2017 · 6 comments
Closed

Error while receiving package #44

michapr opened this issue Feb 6, 2017 · 6 comments

Comments

@michapr
Copy link

michapr commented Feb 6, 2017

Hi,

I get an error while receiving package from Hoppe Window handle (rorg=0xF6func=10, type=00):

root@raspberrypi:/home/pi# python3.4 /usr/local/bin/enocean_example.py
2017-02-06 19:57:19,529 - enocean.communicators.SerialCommunicator - INFO - SerialCommunicator started
2017-02-06 19:57:19,529 - enocean.protocol.packet - WARNING - Replacing Packet.optional with default value.
2017-02-06 19:57:19,630 - enocean.communicators.SerialCommunicator - INFO - Sending packet
2017-02-06 19:57:19,630 - enocean.communicators.SerialCommunicator - DEBUG - 0x05 ['0x8'] [] OrderedDict()
2017-02-06 19:57:19,732 - enocean.communicators.SerialCommunicator - DEBUG - 0x02 ['0x0', '0xff', '0xb2', '0x78', '0x80'] ['0xa'] OrderedDict()
The Base ID of your module is FF:B2:78:80.
.....

2017-02-06 19:58:05,549 - enocean.communicators.SerialCommunicator - DEBUG - 01:8E:56:0D->FF:FF:FF:FF (-74 dBm): 0x01 ['0xf6', '0xe0', '0x1', '0x8e', '0x56', '0xd', '0x20'] ['0x2', '0xff', '0xff', '0xff', '0xff', '0x4a', '0x0'] OrderedDict()
Traceback (most recent call last):
File "/usr/local/bin/enocean_example.py", line 52, in
for k in packet.parse_eep(0x02, 0x02):
File "/usr/local/lib/python3.4/dist-packages/enocean/protocol/packet.py", line 272, in parse_eep
provides, values = self.eep.get_values(self._profile, self._bit_data, self._bit_status)
File "/usr/local/lib/python3.4/dist-packages/enocean/protocol/eep.py", line 199, in get_values
output.update(self._get_enum(source, bitarray))
File "/usr/local/lib/python3.4/dist-packages/enocean/protocol/eep.py", line 97, in _get_enum
'value': value_desc['description'].format(value=raw_value),
TypeError: 'NoneType' object is not subscriptable
2017-02-06 19:58:05,655 - enocean.communicators.SerialCommunicator - INFO - SerialCommunicator stopped

receiving a package from not defined device (D2-06-01) I get normal debug messages - without errors.

Any idea what can be wrong?

I have used the Zip file and extracted, because installed files were older (and shorter)

Michael

@msinn
Copy link
Contributor

msinn commented Apr 2, 2017

Hi,

I am just starting with enocean on Python. I am getting the same error. I have installed v0.39 (from the master branch)

@zpfvo
Copy link
Contributor

zpfvo commented Apr 3, 2017

Without having dived into this problem very deep, i have a guess: EEP F6-02-02 defines two enums 'R1' and 'R2' which have 3 Bits reserved for each of them, but only have defines for value 0...3. So if in the bitstream these 3 Bits have a higher value then 3. the program does not know what to do with this.

So this error can always occur when you parse packages with this EEP that are not conform with the EEP. A solution could be to introduce a not specified enum value for the values 4..7. i did this for another Profile here: https://github.com/kipe/enocean/blob/master/enocean/protocol/EEP.xml#L32

on the other hand this actually should not happen, and maybe its better to raise this error because it is clearer that there went something wrong and you probably parsed a package with the wrong eep.

@kipe
Copy link
Owner

kipe commented Apr 3, 2017

Yeah, what @zpfvo pointed out seems to be the most logical source.

The example codes currently assume that the RPS packages are F6-02-02, and try to parse it as such. We do have the implementation of F6-10-00, so you could try altering the line 56 of enocean_example.py to use 0x10, 0x00 instead.

@msinn
Copy link
Contributor

msinn commented Apr 3, 2017

I think you should alter the implementation to return an empty packet.parsed string in such an error condition instead of killing the program with an exception, only if someone misconfigured his application.

In the meantime I modified my application as a precaution. I modified all calls to packet.parse() and packet.parse_eep() in the following way:

    try:
        packet.parse_eep()
    except:
        pass

to keep the application from aborting. This way I get an empty parsed string, what is perfectly fine for me.

@michapr
Copy link
Author

michapr commented Apr 5, 2017

so you could try altering the line 56 of enocean_example.py to use 0x10, 0x00 instead.

Great, it is working ;)

Thanks,
Michael

@michapr michapr closed this as completed Apr 5, 2017
@kipe
Copy link
Owner

kipe commented Apr 6, 2017

Great! Unfortunately the devices don't report their profiles in the message, so the code "just needs to be correct". There's an attempt to fix this in another branch, which would save the learned devices and parse the EEP based on that information, but unfortunately I haven't had the time to properly implement it.

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

4 participants