Skip to content

Commit 9596f6b

Browse files
authored
Merge pull request #404 from bitcraze/krichardsson/arming
Add arming message
2 parents 4c42407 + e9d5972 commit 9596f6b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

cflib/crazyflie/platformservice.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
APP_CHANNEL = 2
4141

4242
PLATFORM_SET_CONT_WAVE = 0
43+
PLATFORM_REQUEST_ARMING = 1
4344

4445
VERSION_GET_PROTOCOL = 0
4546
VERSION_GET_FIRMWARE = 1
@@ -82,7 +83,20 @@ def set_continous_wave(self, enabled):
8283
"""
8384
pk = CRTPPacket()
8485
pk.set_header(CRTPPort.PLATFORM, PLATFORM_COMMAND)
85-
pk.data = (0, enabled)
86+
87+
pk.data = (PLATFORM_SET_CONT_WAVE, enabled)
88+
self._cf.send_packet(pk)
89+
90+
def send_arming_request(self, do_arm: bool):
91+
"""
92+
Send system arm/disarm request
93+
94+
Args:
95+
do_arm (bool): True = arm the system, False = disarm the system
96+
"""
97+
pk = CRTPPacket()
98+
pk.set_header(CRTPPort.PLATFORM, PLATFORM_COMMAND)
99+
pk.data = (PLATFORM_REQUEST_ARMING, do_arm)
86100
self._cf.send_packet(pk)
87101

88102
def get_protocol_version(self):

cflib/drivers/cfusb.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ def __init__(self, device=None, devid=0):
102102
self.dev.set_configuration()
103103

104104
self.handle = self.dev
105-
self.version = float(
106-
'{0:x}.{1:x}'.format(self.dev.bcdDevice >> 8,
107-
self.dev.bcdDevice & 0x0FF))
105+
if self.dev:
106+
self.version = float('{0:x}.{1:x}'.format(self.dev.bcdDevice >> 8, self.dev.bcdDevice & 0x0FF))
107+
else:
108+
self.version = 0.0
108109

109110
def get_serial(self):
110111
# The signature for get_string has changed between versions to 1.0.0b1,

0 commit comments

Comments
 (0)