Beispiel #1
0
 def stop():
     nativePk = cflinkcpp.Packet()
     nativePk.port = 8  # Port 8 = HL Commander
     nativePk.payload = struct.pack('<BB',
                                    3,  # Command (3 = stop)
                                    0)  # Group Mask (0 = all groups)
     return nativePk
Beispiel #2
0
 def takeoff(height, yaw, time):
   nativePk = cflinkcpp.Packet()
   nativePk.port = 8  # Port 8 = HL Commander
   nativePk.payload = struct.pack('<BBff?f',
                                   7,        # Command (7 = takeoff)
                                   0,        # Group Mask (0 = all groups)
                                   height,
                                   yaw,
                                   False,    # Use current yaw
                                   time)     # Duration (seconds)
   return nativePk
Beispiel #3
0
 def send_packet(self, pk):
     """Send a CRTP packet"""
     nativePk = cflinkcpp.Packet()
     nativePk.port = pk.port
     nativePk.channel = pk.channel
     nativePk.payload = bytes(pk.data)
     try:
         self._connection.send(nativePk)
     except Exception as e:
         if self._link_error_callback is not None:
             import traceback
             self._link_error_callback(
                 'Error communicating! Perhaps your device has been unplugged?\n'
                 'Exception:{}\n\n{}'.format(e, traceback.format_exc()))