-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_frame_header_ARIS.m
221 lines (207 loc) · 10.2 KB
/
get_frame_header_ARIS.m
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
function header = get_frame_header_ARIS(fid,resolution,serialnumber)
%get_frame_header_ddf2 returns structure with frame header components
% File is already opened and fid obtained
% resolution (frequency mode) Lo = 0 Hi = 1
% serialnumber = serial number of sonar providing this data
%fseek(fid,1024,'bof');
%fseek(fid,1024,'cof');
initialposition = ftell(fid); %get initial position of file pointer
header.framenumber = fread(fid,1,'uint');
header.frametime = fread(fid,1,'uint64'); % Recording timestamp
%header.frametime = floor(header.frametime/1000); % Correcting padding
%datestr(header.matlabtime)
header.version = fread(fid,1,'uint');
header.status = fread(fid,1,'uint');
header.sonartimestamp = fread(fid,1,'uint64');
%header.matlabtime = datetime(header.frametime*10^-6, 'ConvertFrom', 'posixtime');
header.matlabtime = datetime(header.sonartimestamp*10^-6, 'ConvertFrom', 'posixtime');
%st = datetime(header.sonartimestamp*10^-6, 'ConvertFrom', 'posixtime');
%datestr(st)
header.tsday = fread(fid,1,'uint');
header.tshour = fread(fid,1,'uint');
header.tsminute = fread(fid,1,'uint');
header.tssecond = fread(fid,1,'uint');
header.tshsecond = fread(fid,1,'uint');
header.transmitmode = fread(fid,1,'uint');
header.windowstart = fread(fid,1,'float');
header.windowlength = fread(fid,1,'float');
header.threshold = fread(fid,1,'uint');
header.intensity = fread(fid,1,'int');
header.receivergain = fread(fid,1,'uint');
header.degc1 = fread(fid,1,'uint');
header.degc2 = fread(fid,1,'uint');
header.humidity = fread(fid,1,'uint');
header.focus = fread(fid,1,'uint');
header.battery = fread(fid,1,'uint');
header.uservalue1 = fread(fid,1,'float');
header.uservalue2 = fread(fid,1,'float');
header.uservalue3 = fread(fid,1,'float');
header.uservalue4 = fread(fid,1,'float');
header.uservalue5 = fread(fid,1,'float');
header.uservalue6 = fread(fid,1,'float');
header.uservalue7 = fread(fid,1,'float');
header.uservalue8 = fread(fid,1,'float');
header.velocity = fread(fid,1,'float');
header.depth = fread(fid,1,'float');
header.altitude = fread(fid,1,'float');
header.pitch = fread(fid,1,'float');
header.pitchrate = fread(fid,1,'float');
header.roll = fread(fid,1,'float');
header.rollrate = fread(fid,1,'float');
header.heading = fread(fid,1,'float');
header.headingrate = fread(fid,1,'float');
header.compassheading = fread(fid,1,'float');
header.compasspitch = fread(fid,1,'float');
header.compassroll = fread(fid,1,'float');
header.latitude = fread(fid,1,'double');
header.longitude = fread(fid,1,'double');
header.sonarposition = fread(fid,1,'float');
header.configflags = fread(fid,1,'uint');
header.beamtilt = fread(fid,1,'float');
header.targetrange = fread(fid,1,'float');
header.targetbearing = fread(fid,1,'float');
header.targetpresent = fread(fid,1,'uint');
header.firmwarerevision = fread(fid,1,'uint');
header.flags = fread(fid,1,'uint');
header.sourceframe = fread(fid,1,'uint');
header.watertemp = fread(fid,1,'float');
header.timerperiod = fread(fid,1,'uint');
header.sonarx = fread(fid,1,'float');
header.sonary = fread(fid,1,'float');
header.sonarz = fread(fid,1,'float');
header.sonarpan = fread(fid,1,'float');
header.sonartilt = fread(fid,1,'float');
header.sonarroll = fread(fid,1,'float');
header.panpnnl = fread(fid,1,'float');
header.tiltpnnl = fread(fid,1,'float');
header.rollpnnl = fread(fid,1,'float');
header.vehicletime = fread(fid,1,'double');
header.timeggk = fread(fid,1,'float');
header.dateggk = fread(fid,1,'uint');
header.qualityggk = fread(fid,1,'uint');
header.numsatsggk = fread(fid,1,'uint');
header.dopggk = fread(fid,1,'float');
header.ehtggk = fread(fid,1,'float');
header.heavetss = fread(fid,1,'float');
header.yeargps = fread(fid,1,'uint');
header.monthgps = fread(fid,1,'uint');
header.daygps = fread(fid,1,'uint');
header.hourgps = fread(fid,1,'uint');
header.minutegps = fread(fid,1,'uint');
header.secondgps = fread(fid,1,'uint');
header.hsecondgps = fread(fid,1,'uint');
header.sonarpanoffset = fread(fid,1,'float');
header.sonartiltoffset = fread(fid,1,'float');
header.sonarrolloffset = fread(fid,1,'float');
header.sonarxoffset = fread(fid,1,'float');
header.sonaryoffset = fread(fid,1,'float');
header.sonarzoffset = fread(fid,1,'float');
header.tmatrix = fread(fid,16,'float');
header.samplerate = fread(fid,1,'float');
header.accellx = fread(fid,1,'float');
header.accelly = fread(fid,1,'float');
header.accellz = fread(fid,1,'float');
header.pingmode = fread(fid,1,'uint');
header.frequencyhilow = fread(fid,1,'uint');
header.pulsewidth = fread(fid,1,'uint');
header.cycleperiod = fread(fid,1,'uint');
header.sampleperiod = fread(fid,1,'uint');
header.transmitenable = fread(fid,1,'uint');
header.framerate = fread(fid,1,'float');
header.soundspeed = fread(fid,1,'float');
header.samplesperbeam = fread(fid,1,'uint');
header.enable150v = fread(fid,1,'uint');
header.samplestartdelay = fread(fid,1,'uint');
header.largelens = fread(fid,1,'uint');
header.thesystemtype = fread(fid,1,'uint');
header.sonarserialnumber = fread(fid,1,'uint');
header.encryptedkey = fread(fid,1,'uint64');
header.ariserrorflagsuint = fread(fid,1,'uint');
header.missedpackets = fread(fid,1,'uint');
header.arisappversion = fread(fid,1,'uint');
header.available2 = fread(fid,1,'uint');
header.reorderedsamples = fread(fid,1,'uint');
header.salinity = fread(fid,1,'uint');
header.pressure = fread(fid,1,'float');
header.batteryvoltage = fread(fid,1,'float');
header.mainvoltage = fread(fid,1,'float');
header.switchvoltage = fread(fid,1,'float');
header.focusmotormoving = fread(fid,1,'uint');
header.voltagechanging = fread(fid,1,'uint');
header.focustimeoutfault = fread(fid,1,'uint');
header.focusovercurrentfault = fread(fid,1,'uint');
header.focusnotfoundfault = fread(fid,1,'uint');
header.focusstalledfault = fread(fid,1,'uint');
header.fpgatimeoutfault = fread(fid,1,'uint');
header.fpgabusyfault = fread(fid,1,'uint');
header.fpgastuckfault = fread(fid,1,'uint');
header.cputempfault = fread(fid,1,'uint');
header.psutempfault = fread(fid,1,'uint');
header.watertempfault = fread(fid,1,'uint');
header.humidityfault = fread(fid,1,'uint');
header.pressurefault = fread(fid,1,'uint');
header.voltagereadfault = fread(fid,1,'uint');
header.voltagewritefault = fread(fid,1,'uint');
header.focuscurrentposition = fread(fid,1,'uint');
header.targetpan = fread(fid,1,'float');
header.targettilt = fread(fid,1,'float');
header.targetroll = fread(fid,1,'float');
header.panmotorerrorcode = fread(fid,1,'uint');
header.tiltmotorerrorcode = fread(fid,1,'uint');
header.rollmotorerrorcode = fread(fid,1,'uint');
header.panabsposition = fread(fid,1,'float');
header.tiltabsposition = fread(fid,1,'float');
header.rollabsposition = fread(fid,1,'float');
header.panaccelx = fread(fid,1,'float');
header.panaccely = fread(fid,1,'float');
header.panaccelz = fread(fid,1,'float');
header.tiltaccelx = fread(fid,1,'float');
header.tiltaccely = fread(fid,1,'float');
header.tiltaccelz = fread(fid,1,'float');
header.rollaccelx = fread(fid,1,'float');
header.rollaccely = fread(fid,1,'float');
header.rollaccelz = fread(fid,1,'float');
header.appliedsettings = fread(fid,1,'uint');
header.constrainedsettings = fread(fid,1,'uint');
header.invalidsettings = fread(fid,1,'uint');
header.enableinterpacketdelay = fread(fid,1,'uint');
header.interpacketdelayperiod = fread(fid,1,'uint');
header.uptime = fread(fid,1,'uint');
header.arisappversionmajor = fread(fid,1,'uint16');
header.arisappversionminor = fread(fid,1,'uint16');
header.gotime = fread(fid,1,'uint64');
header.panvelocity = fread(fid,1,'float');
header.tiltvelocity = fread(fid,1,'float');
header.rollvelocity = fread(fid,1,'float');
header.sentinel = fread(fid,1,'uint');
header.userassigned=fread(fid,292,'char'); %Free space for user
header.length =ftell(fid)-initialposition;
if (serialnumber < 19) %Special Case 1
header.configflags = 1;
end
if (serialnumber == 15) %Special Case 2
header.configflags = 3;
end
%warning('Hack in didson reader to make things work')
%switch header.configflags %
%case 0
% winlengths=[0.83 2.5 5 10 20 40]; % DIDSON-S, Extended Windows
% case 1
% winlengths=[1.125 2.25 4.5 9 18 36]; % DIDSON-S, Classic Windows
% case 2
% winlengths=[2.5 5 10 20 40 70]; % DIDSON-LR, Extended Windows
% case 3
% winlengths=[2.25 4.5 9 18 36 72]; % DIDSON-LR, Classic Windows
%end
% %Windowlength index determined. Windowlength determined at end of file.
% index=fread(fid,1,'int32') +1 +2*(resolution == 0); %Add 2 if low resolution (index between 1 and 6)
%
%header.windowlength = winlengths(index); % Convert windowlength code to meters
%Windowstart 1 to 31 times 0.75 (lo) or 0.375 (hi) or 0.419 for extended
% switch header.configflags
% case {1,3}
% header.windowstart = header.windowstart*(0.375 +(resolution == 0)*0.375); %meters for standard or long range DIDSON
% case {0,2}
% header.windowstart = header.windowstart*(0.419 +(resolution == 0)*0.419); %meters for extended DIDSON
% end
end