Skip to content

Commit

Permalink
fix format (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo authored Jan 25, 2024
1 parent 824a8c1 commit 56671b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 0 additions & 2 deletions node_scripts/sdp_v2_device_interface_printer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env python

import rospy

from smart_device_protocol.smart_device_protocol_interface import DeviceDictSDPInterface


if __name__ == "__main__":
rospy.init_node("smart_device_protocol_device_interface_printer")
sdp_interface = DeviceDictSDPInterface()
Expand Down
27 changes: 20 additions & 7 deletions node_scripts/sdp_v2_packet_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,36 @@


class Node:

def __init__(self, target_address_str = None):
self.target_address = address_str_to_tuple(target_address_str) if target_address_str is not None else None
self.interface = SDPInterface(callback_data=self.callback, callback_meta=self.callback)
def __init__(self, target_address_str=None):
self.target_address = (
address_str_to_tuple(target_address_str)
if target_address_str is not None
else None
)
self.interface = SDPInterface(
callback_data=self.callback, callback_meta=self.callback
)

def callback(self, src_address, frame):
if self.target_address is not None:
if src_address == self.target_address:
print("{} Packet from {}".format(type(frame), address_tuple_to_str(src_address)))
print(
"{} Packet from {}".format(
type(frame), address_tuple_to_str(src_address)
)
)
print("{}".format(frame))
else:
print("{} Packet from {}".format(type(frame), address_tuple_to_str(src_address)))
print(
"{} Packet from {}".format(
type(frame), address_tuple_to_str(src_address)
)
)
print("{}".format(frame))


if __name__ == "__main__":
rospy.init_node("smart_device_protocol_packet_printer")
target_address = rospy.get_param('~target_address', None)
target_address = rospy.get_param("~target_address", None)
node = Node(target_address_str=target_address)
rospy.spin()

0 comments on commit 56671b8

Please sign in to comment.