diff --git a/cflib/crazyflie/platformservice.py b/cflib/crazyflie/platformservice.py index e1c8d398c..8b96c214a 100644 --- a/cflib/crazyflie/platformservice.py +++ b/cflib/crazyflie/platformservice.py @@ -40,6 +40,7 @@ APP_CHANNEL = 2 PLATFORM_SET_CONT_WAVE = 0 +PLATFORM_REQUEST_ARMING = 1 VERSION_GET_PROTOCOL = 0 VERSION_GET_FIRMWARE = 1 @@ -82,7 +83,20 @@ def set_continous_wave(self, enabled): """ pk = CRTPPacket() pk.set_header(CRTPPort.PLATFORM, PLATFORM_COMMAND) - pk.data = (0, enabled) + + pk.data = (PLATFORM_SET_CONT_WAVE, enabled) + self._cf.send_packet(pk) + + def send_arming_request(self, do_arm: bool): + """ + Send system arm/disarm request + + Args: + do_arm (bool): True = arm the system, False = disarm the system + """ + pk = CRTPPacket() + pk.set_header(CRTPPort.PLATFORM, PLATFORM_COMMAND) + pk.data = (PLATFORM_REQUEST_ARMING, do_arm) self._cf.send_packet(pk) def get_protocol_version(self): diff --git a/cflib/drivers/cfusb.py b/cflib/drivers/cfusb.py index 124e27061..80d12a321 100644 --- a/cflib/drivers/cfusb.py +++ b/cflib/drivers/cfusb.py @@ -102,9 +102,10 @@ def __init__(self, device=None, devid=0): self.dev.set_configuration() self.handle = self.dev - self.version = float( - '{0:x}.{1:x}'.format(self.dev.bcdDevice >> 8, - self.dev.bcdDevice & 0x0FF)) + if self.dev: + self.version = float('{0:x}.{1:x}'.format(self.dev.bcdDevice >> 8, self.dev.bcdDevice & 0x0FF)) + else: + self.version = 0.0 def get_serial(self): # The signature for get_string has changed between versions to 1.0.0b1,