本文整理匯總了Python中cflib.drivers.crazyradio.Crazyradio.scan_selected方法的典型用法代碼示例。如果您正苦於以下問題:Python Crazyradio.scan_selected方法的具體用法?Python Crazyradio.scan_selected怎麽用?Python Crazyradio.scan_selected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cflib.drivers.crazyradio.Crazyradio
的用法示例。
在下文中一共展示了Crazyradio.scan_selected方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RadioDriver
# 需要導入模塊: from cflib.drivers.crazyradio import Crazyradio [as 別名]
# 或者: from cflib.drivers.crazyradio.Crazyradio import scan_selected [as 別名]
#.........這裏部分代碼省略.........
self._thread = _RadioDriverThread(self.cradio, self.in_queue,
self.out_queue,
self.link_quality_callback,
self.link_error_callback,
self)
self._thread.start()
def close(self):
""" Close the link. """
# Stop the comm thread
self._thread.stop()
# Close the USB dongle
try:
if self.cradio:
self.cradio.close()
except:
# If we pull out the dongle we will not make this call
pass
self.cradio = None
while not self.out_queue.empty():
self.out_queue.get()
# Clear callbacks
self.link_error_callback = None
self.link_quality_callback = None
def _scan_radio_channels(self, start=0, stop=125):
""" Scan for Crazyflies between the supplied channels. """
return list(self.cradio.scan_channels(start, stop, (0xff,)))
def scan_selected(self, links):
to_scan = ()
for l in links:
one_to_scan = {}
uri_data = re.search("^radio://([0-9]+)((/([0-9]+))"
"(/(250K|1M|2M))?)?$",
l)
one_to_scan["channel"] = int(uri_data.group(4))
datarate = Crazyradio.DR_2MPS
if uri_data.group(6) == "250K":
datarate = Crazyradio.DR_250KPS
if uri_data.group(6) == "1M":
datarate = Crazyradio.DR_1MPS
if uri_data.group(6) == "2M":
datarate = Crazyradio.DR_2MPS
one_to_scan["datarate"] = datarate
to_scan += (one_to_scan,)
found = self.cradio.scan_selected(to_scan, (0xFF, 0xFF, 0xFF))
ret = ()
for f in found:
dr_string = ""
if f["datarate"] == Crazyradio.DR_2MPS:
dr_string = "2M"
if f["datarate"] == Crazyradio.DR_250KPS:
dr_string = "250K"
if f["datarate"] == Crazyradio.DR_1MPS:
dr_string = "1M"
開發者ID:NilanjanDaw,項目名稱:Ground-based-Control-and-Remote-Stabilization-for-MAV,代碼行數:70,代碼來源:radiodriver.py