本文整理汇总了Python中packet.Packet.make_packet方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.make_packet方法的具体用法?Python Packet.make_packet怎么用?Python Packet.make_packet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packet.Packet
的用法示例。
在下文中一共展示了Packet.make_packet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RadioSubsystem
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import make_packet [as 别名]
#.........这里部分代码省略.........
"""
Transmit data.
Parameters
----------
mode : str
Mode of operation. Used to create appropriate packet header and payload.
{`send_reconfig_command` | `request_data` | `stream_data`}.
mod : str, opt
Modulation, one of {`fsk` | `gfsk` | `ook` }.
eirp : int, opt
Transmit power, one of { 8 | 11 | 14 | 17 }.
bitrate : float, opt
Radio bitrate, one of {...}
"""
if mode == 'stream_data':
self.packet.set_flags_node_a(send_stream=True)
payload = self.data.pack_data(mode)
elif mode == 'send_reconfig_command':
self.packet.set_flags_node_a(send_command=True)
payload = self.data.pack_data(mode, mod, eirp, bitrate)
elif mode == 'request_data':
self.packet.set_flags_node_a(request_data=True)
payload = self.data.pack_data(mode)
else:
print "error in _send_packet, no mode specified"
raise ValueError
tx_packet = self.packet.make_packet(self.tx_packet_number, self.current_location, payload)
self.tx_packet_number += 1
self.radio.transmit(tx_packet)
# logging.info("packet sent")
def _receive_packet(self):
"""
Receive packet
"""
(self.rssi_level, rx_packet) = self.radio.receive(rx_fifo_threshold=63, timeout=None)
# rx_packet = self.radio.receive(rx_fifo_threshold=64, timeout=None)
pkt_num, t, loc, flags, data = self.packet.parse_packet(rx_packet)
return pkt_num, loc, flags, data
def set_current_location(self, current_location):
"""
Set current location.
Used by controller to tell radio subsytem the current physical
location.
Parameters
----------
current_location : int
Value of barcode representing current location.
"""
self.current_location = current_location