Skip to content

Commit

Permalink
Merge pull request #404 from bitcraze/krichardsson/arming
Browse files Browse the repository at this point in the history
Add arming message
  • Loading branch information
krichardsson authored May 30, 2023
2 parents 4c42407 + e9d5972 commit 9596f6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 15 additions & 1 deletion cflib/crazyflie/platformservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
APP_CHANNEL = 2

PLATFORM_SET_CONT_WAVE = 0
PLATFORM_REQUEST_ARMING = 1

VERSION_GET_PROTOCOL = 0
VERSION_GET_FIRMWARE = 1
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions cflib/drivers/cfusb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9596f6b

Please sign in to comment.