File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -145,21 +145,25 @@ void AP_AIS::update()
145
145
} else if (_incoming.num == _incoming.total ) {
146
146
// last part of a multi part message
147
147
uint8_t index = 0 ;
148
- uint8_t msg_parts[_incoming.num - 1 ];
148
+
149
+ // We have the last part, need to find preceding fragments
150
+ const uint8_t parts = _incoming.num - 1 ;
151
+
152
+ uint8_t msg_parts[parts];
149
153
for (uint8_t i = 0 ; i < AIVDM_BUFFER_SIZE; i++) {
150
154
// look for the rest of the message from the start of the buffer
151
155
// we assume the message has be received in the correct order
152
156
if (_AIVDM_buffer[i].num == (index + 1 ) && _AIVDM_buffer[i].total == _incoming.total && _AIVDM_buffer[i].ID == _incoming.ID ) {
153
157
msg_parts[index] = i;
154
158
index++;
155
- if (index >= _incoming. num ) {
159
+ if (index >= parts ) {
156
160
break ;
157
161
}
158
162
}
159
163
}
160
164
161
165
// did we find the right number?
162
- if (_incoming.num != index ) {
166
+ if (_incoming.num != parts ) {
163
167
// could not find all of the message, save messages
164
168
#if HAL_LOGGING_ENABLED
165
169
if (log_unsupported) {
You can’t perform that action at this time.
0 commit comments