utils.py
Go to the documentation of this file.
1 import sys
2 import traceback
3 import struct
4 
5 def byte(c):
6  if isinstance(c, str):
7  return ord(c)
8  return c
9 
10 
11 def le16(val):
12  return (val & 0xff), ((val >> 8) & 0xff)
13 
14 
15 def uint16(val0, val1):
16  return (val0 & 0xff) | ((val1 & 0xff) << 8)
17 
18 
19 def int16(val0, val1):
20  if (val1 & 0xff) is not 0:
21  return ((val0 & 0xff) | ((val1 & 0xff) << 8)) - 0x10000
22  else:
23  return (val0 & 0xff) | ((val1 & 0xff) << 8)
24 
25 
27  if isinstance(buf, str):
28  return ''.join(["%02x " % ord(x) for x in buf]).strip()
29 
30  return ''.join(["%02x " % ord(chr(x)) for x in buf]).strip()
31 
32 def float_to_hex(f):
33  return hex(struct.unpack('<I', struct.pack('<f', f))[0])
34 
36  exc_type, exc_value, exc_traceback = sys.exc_info()
37  traceback.print_exception(exc_type, exc_value, exc_traceback)
def int16(val0, val1)
Definition: utils.py:19
def byte_to_hexstring(buf)
Definition: utils.py:26
def uint16(val0, val1)
Definition: utils.py:15
def show_exception(ex)
Definition: utils.py:35


tello_driver
Author(s): Jordy van Appeven
autogenerated on Wed May 13 2020 03:34:54