Skip to content

Commit

Permalink
Fix Python 3.9 support for #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Feb 9, 2022
1 parent 5525c58 commit 7a19c35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions library/pa1010d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,21 @@ def _write_sentence(self, bytestring):
"""
for char_index in bytestring:
self._i2c.write_byte(self._i2c_addr, ord(char_index))
self._i2c.write_byte(self._i2c_addr, char_index)

def send_command(self, command, add_checksum=True):
"""Send a command string to the PA1010D.
If add_checksum is True (the default) a NMEA checksum will automatically be computed and added.
"""
if type(command) is not bytes:
command = command.encode("ascii")

# TODO replace with pynmea2 functionality
if command.startswith("$"):
if command[0] == b"$":
command = command[1:]
if command.endswith("*"):
if command[-1] == b"*":
command = command[:-1]

buf = bytearray()
Expand Down
7 changes: 7 additions & 0 deletions library/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ def test_setup(smbus):

gps = pa1010d.PA1010D()
del gps


def test_send_command(smbus):
import pa1010d

gps = pa1010d.PA1010D()
gps.send_command("$TEST")

0 comments on commit 7a19c35

Please sign in to comment.