Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Errors (#142)
Browse files Browse the repository at this point in the history
Added & updated error messages when using incompatible shield (firmware)
  • Loading branch information
peter-pycom authored Apr 9, 2021
1 parent e6985cd commit 29c580d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shields/lib/pycoproc_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self, board_type, i2c=None, sda='P22', scl='P21'):
self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 7))

if self.read_fw_version() < 6:
raise ValueError('Firmware out of date')
raise ValueError('Firmware for Shield1 out of date')


def _write(self, data, wait=True):
Expand Down
2 changes: 1 addition & 1 deletion shields/lib/pycoproc_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, i2c=None, sda='P22', scl='P21'):
# for Pysense/Pytrack 2.0, the minimum firmware version is 15
fw = self.read_fw_version()
if fw < 16:
raise ValueError('Firmware out of date', fw)
raise ValueError('Firmware for Shield2 out of date', fw)

# init the ADC for the battery measurements
self.write_byte(ANSELC_ADDR, 1 << 2) # RC2 analog input
Expand Down
2 changes: 2 additions & 0 deletions shields/pysense_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
pycom.rgbled(0x0A0A08) # white

py = Pycoproc()
if py.read_product_id() != Pycoproc.USB_PID_PYSENSE:
raise Exception('Not a Pysense')

mp = MPL3115A2(py,mode=ALTITUDE) # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals
print("MPL3115A2 temperature: " + str(mp.temperature()))
Expand Down
2 changes: 2 additions & 0 deletions shields/pytrack_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
print('Adjusted from UTC to EST timezone', utime.localtime(), '\n')

py = Pycoproc()
if py.read_product_id() != Pycoproc.USB_PID_PYTRACK:
raise Exception('Not a Pytrack')

time.sleep(1)
l76 = L76GNSS(py, timeout=30, buffer=512)
Expand Down

0 comments on commit 29c580d

Please sign in to comment.