12 SSID_PASSWORD_MSG = 0x0013
13 SSID_PASSWORD_CMD = 0x0014
14 WIFI_REGION_MSG = 0x0015
15 WIFI_REGION_CMD = 0x0016
17 VIDEO_ENCODER_RATE_CMD = 0x0020
18 VIDEO_DYN_ADJ_RATE_CMD = 0x0021
20 VIDEO_START_CMD = 0x0025
21 VIDEO_RATE_QUERY = 0x0028
22 TAKE_PICTURE_COMMAND = 0x0030
23 VIDEO_MODE_CMD = 0x0031
24 VIDEO_RECORD_CMD = 0x0032
27 JPEG_QUALITY_MSG = 0x0037
32 ACTIVATION_TIME_MSG = 0x0047
33 LOADER_VERSION_MSG = 0x0049
38 SET_ALT_LIMIT_CMD = 0x0058
40 THROW_AND_GO_CMD = 0x005d
41 PALM_LAND_CMD = 0x005e
42 TELLO_CMD_FILE_SIZE = 0x0062
43 TELLO_CMD_FILE_DATA = 0x0063
44 TELLO_CMD_FILE_COMPLETE = 0x0064
45 SMART_VIDEO_CMD = 0x0080
46 SMART_VIDEO_STATUS_MSG = 0x0081
47 LOG_HEADER_MSG = 0x1050
49 LOG_CONFIG_MSG = 0x1052
51 CALIBRATE_CMD = 0x1054
52 LOW_BAT_THRESHOLD_CMD = 0x1055
53 ALT_LIMIT_MSG = 0x1056
54 LOW_BAT_THRESHOLD_MSG = 0x1057
55 ATT_LIMIT_CMD = 0x1058
56 ATT_LIMIT_MSG = 0x1059
58 EMERGENCY_CMD =
'emergency' 79 def __init__(self, cmd, pkt_type=0x68, payload=b''):
80 if isinstance(cmd, str):
81 self.
buf = bytearray()
83 self.buf.append(ord(c))
84 elif isinstance(cmd, (bytearray, bytes)):
85 self.
buf = bytearray()
88 self.
buf = bytearray([
93 (cmd & 0xff), ((cmd >> 8) & 0xff),
95 self.buf.extend(payload)
99 if buf[0] == START_OF_PACKET:
100 buf[1], buf[2] =
le16(len(buf)+2)
101 buf[1] = (buf[1] << 3)
102 buf[3] = crc.crc8(buf[0:3])
103 buf[7], buf[8] =
le16(seq_num)
110 return self.
buf[9:len(self.
buf)-2]
113 self.buf.append(val & 0xff)
123 self.
add_int16(int(time.microsecond/1000) & 0xff)
124 self.
add_int16((int(time.microsecond/1000) >> 8) & 0xff)
129 hour =
int16(buf[0], buf[1])
130 min =
int16(buf[2], buf[3])
131 sec =
int16(buf[4], buf[5])
132 millisec =
int16(buf[6], buf[8])
133 now = datetime.datetime.now()
134 return datetime.datetime(now.year, now.month, now.day, hour, min, sec, millisec)
199 self.
em_sky = ((data[17] >> 0) & 0x1)
201 self.
em_open = ((data[17] >> 2) & 0x1)
213 self.
front_in = ((data[22] >> 0) & 0x1)
221 (
"ALT: %2d" % self.
height) +
242 return self.buffer.getvalue()
252 self.buffer.seek(fragment*1024)
253 self.buffer.write(data)
260 packets_per_frame = 0
264 if VideoData.packets_per_frame < (self.
h1 & 0x7f):
265 VideoData.packets_per_frame = (self.
h1 & 0x7f)
267 def gap(self, video_data):
268 if video_data
is None:
275 if ((v0.h0 != v1.h0
and v0.h0 != ((v1.h0 + 1) & 0xff))
276 or (v0.h0 != v1.h0
and (v0.h1 & 0x7f) != 00)
277 or (v0.h0 == v1.h0
and (v0.h1 & 0x7f) != (v1.h1 & 0x7f) + 1)):
281 loss = loss * VideoData.packets_per_frame + ((v0.h1 & 0x7f) - (v1.h1 & 0x7f) - 1)
287 ID_NEW_MVO_FEEDBACK = 29
300 return (
'MVO: ' + str(self.
mvo) +
301 '|IMU: ' + str(self.
imu) +
306 self.mvo.format_cvs() +
307 ',' + self.imu.format_cvs() +
312 self.mvo.format_cvs_header() +
313 ',' + self.imu.format_cvs_header() +
317 if isinstance(data, bytearray):
320 self.log.debug(
'LogData: data length=%d' % len(data))
323 while (pos < len(data) - 2):
324 if (struct.unpack_from(
'B', data, pos+0)[0] != 0x55):
325 raise Exception(
'LogData: corrupted data at pos=%d, data=%s' 327 length = struct.unpack_from(
'<h', data, pos+1)[0]
328 checksum = data[pos+3]
329 id = struct.unpack_from(
'<H', data, pos+4)[0]
334 if isinstance(data, str):
335 payload = bytearray([ord(x) ^ ord(xorval)
for x
in data[pos+10:pos+10+length-12]])
337 payload = bytearray([x ^ xorval
for x
in data[pos+10:pos+10+length-12]])
339 self.mvo.update(payload, self.
count)
341 self.imu.update(payload, self.
count)
344 self.log.info(
'LogData: UNHANDLED LOG DATA: id=%5d, length=%4d' % (id, length-12))
345 self.unknowns.append(id)
348 if pos != len(data) - 2:
349 raise Exception(
'LogData: corrupted data at pos=%d, data=%s' 380 "mvo.vel_x,mvo.vel_y,mvo.vel_z" +
381 ",mvo.pos_x,mvo.pos_y,mvo.pos_z" +
385 self.log.debug(
'LogNewMvoFeedback: length=%d %s' % (len(data),
byte_to_hexstring(data)))
387 (self.
vel_x, self.
vel_y, self.
vel_z) = struct.unpack_from(
'<hhh', data, 2)
391 (self.
pos_x, self.
pos_y, self.
pos_z) = struct.unpack_from(
'fff', data, 8)
392 self.log.debug(
'LogNewMvoFeedback: ' + str(self))
419 (
" QUATERNION: %5.2f %5.2f %5.2f %5.2f" % (self.
q0, self.
q1, self.
q2, self.
q3)) +
420 (
" VG: %5.2f %5.2f %5.2f" % (self.
vg_x, self.
vg_y, self.
vg_z)) +
427 (
",%f,%f,%f,%f" % (self.
q0, self.
q1, self.
q2, self.
q3)) +
433 "imu.acc_x,imu.acc_y,imu.acc_z" +
434 ",imu.gyro_x,imu.gyro_y,imu.gyro_z" +
435 ",imu.q0,imu.q1,imu.q2, self.q3" +
436 ",imu.vg_x,imu.vg_y,imu.vg_z" +
440 self.log.debug(
'LogImuAtti: length=%d %s' % (len(data),
byte_to_hexstring(data)))
442 (self.
acc_x, self.
acc_y, self.
acc_z) = struct.unpack_from(
'fff', data, 20)
444 (self.
q0, self.
q1, self.
q2, self.
q3) = struct.unpack_from(
'ffff', data, 48)
445 (self.
vg_x, self.
vg_y, self.
vg_z) = struct.unpack_from(
'fff', data, 76)
446 self.log.debug(
'LogImuAtti: ' + str(self))
def __init__(self, log, data=None)
electrical_machinery_state
def __init__(self, log=None, data=None)
def add_time(self, time=datetime.datetime.now())
def haveFragment(self, chunk, fragment)
def gap(self, video_data)
def byte_to_hexstring(buf)
def __init__(self, log=None, data=None)
def recvFragment(self, chunk, fragment, size, data)
def format_cvs_header(self)
def fixup(self, seq_num=0)
def update(self, data, count=0)
def __init__(self, cmd, pkt_type=0x68, payload=b'')
def update(self, data, count=0)
def format_cvs_header(self)
def format_cvs_header(self)
def get_time(self, buf=None)
def __init__(self, filenum, size)