Skip to content

Commit a3cad20

Browse files
mrmcwethytannewt
authored andcommitted
changed conditional import for struct and ustruct (#2)
changed conditional import for struct and ustruct
1 parent 3f06bae commit a3cad20

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

adafruit_max31855.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
amplifier module.
2929
3030
"""
31-
32-
import ustruct
31+
try:
32+
import struct
33+
except ImportError:
34+
import ustruct as struct
3335

3436
from adafruit_bus_device.spi_device import SPIDevice
3537

@@ -54,7 +56,7 @@ def _read(self, internal=False):
5456
raise RuntimeError("short circuit to power")
5557
if self.data[1] & 0x01:
5658
raise RuntimeError("faulty reading")
57-
temp, refer = ustruct.unpack('>hh', self.data)
59+
temp, refer = struct.unpack('>hh', self.data)
5860
refer >>= 4
5961
temp >>= 2
6062
if internal:

0 commit comments

Comments
 (0)