Skip to content

Commit

Permalink
Merge pull request #25 from the-hive-lab/24-tag-id
Browse files Browse the repository at this point in the history
Move `tag_id` property to `UartDwm1001` base class
  • Loading branch information
adamlm committed Jun 29, 2023
2 parents 9fc2a7c + f83dae3 commit 4fe6d80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions dwm1001.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ class UartDwm1001:
def __init__(self, serial_handle: Serial) -> None:
self.serial_handle = serial_handle

@property
def tag_id(self) -> str:
self.send_shell_command(ShellCommand.SI)

report = []
for _ in range(9):
report.append(self.serial_handle.readline().decode())

# System info has a lot of lines, but we only care about the address
address_line = report[2]
address_text_start = address_line.find("addr=")
address_string = address_line[address_text_start:-1].strip()

# We only use the last four characters in the address
return address_string[-4:]

def send_shell_command(self, command: ShellCommand) -> None:
self.serial_handle.write(command.value)
self.serial_handle.write(ShellCommand.ENTER.value)
Expand Down Expand Up @@ -134,22 +150,6 @@ def start_position_reporting(self) -> None:
def stop_position_reporting(self) -> None:
self.send_shell_command(ShellCommand.ENTER)

@property
def tag_id(self) -> str:
self.send_shell_command(ShellCommand.SI)

report = []
for _ in range(9):
report.append(self.serial_handle.readline().decode())

# System info has a lot of lines, but we only care about the address
address_line = report[2]
address_text_start = address_line.find("addr=")
address_string = address_line[address_text_start:-1].strip()

# We only use the last four characters in the address
return address_string[-4:]

@property
def position(self) -> TagPosition:
report = self.serial_handle.readline().decode().split(",")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pydwm1001"
version = "0.4.0"
version = "0.5.0"
authors = [
{ name="Adam Morrissett", email="morrissettal2@vcu.edu" },
]
Expand Down

0 comments on commit 4fe6d80

Please sign in to comment.