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

Commit 29c580d

Browse files
authored
Errors (#142)
Added & updated error messages when using incompatible shield (firmware)
1 parent e6985cd commit 29c580d

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

shields/lib/pycoproc_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __init__(self, board_type, i2c=None, sda='P22', scl='P21'):
127127
self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 7))
128128

129129
if self.read_fw_version() < 6:
130-
raise ValueError('Firmware out of date')
130+
raise ValueError('Firmware for Shield1 out of date')
131131

132132

133133
def _write(self, data, wait=True):

shields/lib/pycoproc_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(self, i2c=None, sda='P22', scl='P21'):
152152
# for Pysense/Pytrack 2.0, the minimum firmware version is 15
153153
fw = self.read_fw_version()
154154
if fw < 16:
155-
raise ValueError('Firmware out of date', fw)
155+
raise ValueError('Firmware for Shield2 out of date', fw)
156156

157157
# init the ADC for the battery measurements
158158
self.write_byte(ANSELC_ADDR, 1 << 2) # RC2 analog input

shields/pysense_2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
pycom.rgbled(0x0A0A08) # white
2525

2626
py = Pycoproc()
27+
if py.read_product_id() != Pycoproc.USB_PID_PYSENSE:
28+
raise Exception('Not a Pysense')
2729

2830
mp = MPL3115A2(py,mode=ALTITUDE) # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals
2931
print("MPL3115A2 temperature: " + str(mp.temperature()))

shields/pytrack_2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
print('Adjusted from UTC to EST timezone', utime.localtime(), '\n')
3737

3838
py = Pycoproc()
39+
if py.read_product_id() != Pycoproc.USB_PID_PYTRACK:
40+
raise Exception('Not a Pytrack')
3941

4042
time.sleep(1)
4143
l76 = L76GNSS(py, timeout=30, buffer=512)

0 commit comments

Comments
 (0)