forked from Georacer/ardupilog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformatLength.m
More file actions
73 lines (72 loc) · 1.7 KB
/
Copy pathformatLength.m
File metadata and controls
73 lines (72 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
%> @brief return the size of the input variable type as designated
%> @param[in] varType (char)
%> @param[out] len (double) typed size
%> @author George Zogopoulos-Papaliakos
%> @author Hunter McClelland
function len = formatLength(varType)
% Format characters in the format string for binary log messages
% a : int16_t[32] (array of 32 int16_t's)
% b : int8_t
% B : uint8_t
% h : int16_t
% H : uint16_t
% i : int32_t
% I : uint32_t
% f : float
% d : double
% n : char[4]
% N : char[16]
% Z : char[64]
% c : int16_t * 100
% C : uint16_t * 100
% e : int32_t * 100
% E : uint32_t * 100
% L : int32_t latitude/longitude
% M : uint8_t flight mode
% q : int64_t
% Q : uint64_t
switch varType
case 'a' % int16_t[32] (array of 32 int16_t's)
len = 2*32;
case 'b' % int8_t
len = 1;
case 'B' % uint8_t
len = 1;
case 'h' % int16_t
len = 2;
case 'H' % uint16_t
len = 2;
case 'i' % int32_t
len = 4;
case 'I' % uint32_t
len = 4;
case 'q' % int64_t
len = 8;
case 'Q' % uint64_t
len = 8;
case 'f' % float (32 bits)
len = 4;
case 'd' % double
len = 8;
case 'n' % char[4]
len = 4;
case 'N' % char[16]
len = 16;
case 'Z' % char[64]
len = 64;
case 'c' % int16_t * 100
len = 2;
case 'C' % uint16_t * 100
len = 2;
case 'e' % int32_t * 100
len = 4;
case 'E' % uint32_t * 100
len = 4;
case 'L' % int32_t (Latitude/Longitude)
len = 4;
case 'M' % uint8_t (Flight mode)
len = 1;
otherwise
error('Unknown variable type designator');
end
end