Skip to content

Commit

Permalink
fix verify code
Browse files Browse the repository at this point in the history
  • Loading branch information
pjb304 committed Jan 29, 2019
1 parent 63813b5 commit d2e96b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions novafitness_sds018/novafitness_sds018.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(self, line):
an object containing the data
"""
self.timestamp = datetime.utcnow()
self.pm10 = (line[5] << 8 + line[4]) / 10
self.pm25 = (line[3] << 8 + line[2]) / 10
self.pm10 = ((line[5] << 8) + line[4]) / 10
self.pm25 = ((line[3] << 8) + line[2]) / 10

def __str__(self):
return (
Expand Down Expand Up @@ -88,7 +88,7 @@ def _verify(self, recv):
to verify that the data recived is correct
"""
calc = 0
calc = (recv[2]+recv[3]+recv[4]+recv[5]+recv[6]+recv[7])%2
calc = (recv[2] + recv[3] + recv[4] + recv[5] + recv[6] + recv[7]) % 256
self.logger.debug(calc)
sent = recv[-2] # Combine the 2 bytes together
if sent != calc:
Expand Down

0 comments on commit d2e96b9

Please sign in to comment.