[go: nahoru, domu]

Skip to content

Commit

Permalink
Added "node id" test
Browse files Browse the repository at this point in the history
If a float is passed as a node id it can fail. added int 0 to 31 check to first value in payload.
http://openenergymonitor.org/emon/node/6048
  • Loading branch information
pb66 committed Dec 9, 2014
1 parent 30bd975 commit 366b3db
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/emonhub_interfacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def _validate_frame(self, ref, received):
except Exception:
self._log.warning(str(ref) + " Discarded RX frame 'non-numerical content' : " + str(received))
return False

# Discard if first value is not a valid node id
if received[0] % 1 != 0 or received[0] < 0 or received[0] > 31
self._log.warning(str(ref) + " Discarded RX frame 'node id outside scope' : " + str(received))
return False

# If it passes all the checks return
return received
Expand Down

0 comments on commit 366b3db

Please sign in to comment.