Skip to content

Commit

Permalink
Implement retry in __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xzf89718 committed Nov 15, 2022
1 parent 2ef7c0c commit 133439d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions AHT20_sensor_control/AHT20_sensor_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def triggerAndMeasureAndCRCcheck(AHT20_sensor):
raise NotImplementedError("Should be a AHT20_wrapper")
temperature, humidity = triggerAndMeasure(AHT20_sensor)
CRCStatus = AHT20_sensor.CheckCRC()
if (CRCStatus == AHT20Status.AHT20_CRCNOTOK):
AHT20_logger.warning("CRC8 check fail")
return temperature, humidity, CRCStatus


Expand Down
4 changes: 3 additions & 1 deletion AHT20_sensor_control/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
temperature, humidity = triggerAndMeasure(my_wrapper)
mylogger.info("{0:.2f} C\t{1:.2f} %RH".format(temperature, humidity * 100))
else:
temerature, humidity, CRC8_check = triggerAndMeasureAndCRCcheck(my_wrapper)
CRC8_check = AHT20Status.AHT20_CRCNOTOK
while (CRC8_check == AHT20Status.AHT20_CRCNOTOK):
temerature, humidity, CRC8_check = triggerAndMeasureAndCRCcheck(my_wrapper)
mylogger.info("{0:.2f} C\t{1:.2f} %RH\t{2}".format(temperature, humidity * 100, str(CRC8_check)))
time.sleep(MEASURE_INTERVAL)
except KeyboardInterrupt:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sensors-control-gpio-xzf8971"
version = "1.2.0"
version = "2.0.0"
authors = [
{ name="Zifeng", email="[email protected]" },
]
Expand Down

0 comments on commit 133439d

Please sign in to comment.