Skip to content

Prevent infinite loop on Index Error #3

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion enocean/communicators/serialcommunicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def run(self):
try:
self.parse()
except Exception as e:
self.logger.error('Exception occured while parsing: ' + str(e))
self.logger.exception('Exception occured while parsing: ')
time.sleep(0)

self.__ser.close()
Expand Down
25 changes: 14 additions & 11 deletions enocean/protocol/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,21 @@ def parse_msg(buf):
return PARSE_RESULT.CRC_MISMATCH, buf, None

# If we got this far, everything went ok (?)
if packet_type == PACKET.RADIO_ERP1:
# Need to handle UTE Teach-in here, as it's a separate packet type...
if data[0] == RORG.UTE:
packet = UTETeachInPacket(packet_type, data, opt_data)
try:
if packet_type == PACKET.RADIO_ERP1:
# Need to handle UTE Teach-in here, as it's a separate packet type...
if data[0] == RORG.UTE:
packet = UTETeachInPacket(packet_type, data, opt_data)
else:
packet = RadioPacket(packet_type, data, opt_data)
elif packet_type == PACKET.RESPONSE:
packet = ResponsePacket(packet_type, data, opt_data)
elif packet_type == PACKET.EVENT:
packet = EventPacket(packet_type, data, opt_data)
else:
packet = RadioPacket(packet_type, data, opt_data)
elif packet_type == PACKET.RESPONSE:
packet = ResponsePacket(packet_type, data, opt_data)
elif packet_type == PACKET.EVENT:
packet = EventPacket(packet_type, data, opt_data)
else:
packet = Packet(packet_type, data, opt_data)
packet = Packet(packet_type, data, opt_data)
except IndexError:
return PARSE_RESULT.INCOMPLETE, buf, None

return PARSE_RESULT.OK, buf, packet

Expand Down