Skip to content

Commit

Permalink
ardupilot: Don't early return on NAMED_VALUE_FLOAT messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Jan 17, 2025
1 parent 01b7c21 commit 897ba29
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/libs/vehicle/ardupilot/ardupilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,28 @@ export abstract class ArduPilotVehicle<Modes> extends Vehicle.AbstractVehicle<Mo

const messageType = mavlink_message.message.type

// Special handling for NAMED_VALUE_FLOAT messages
// Inject variables from the MAVLink messages into the DataLake
if (messageType === 'NAMED_VALUE_FLOAT') {
// Special handling for NAMED_VALUE_FLOAT messages
const name = (mavlink_message.message.name as string[]).join('').replace(/\0/g, '')
const path = `${messageType}/${name}`
if (getDataLakeVariableInfo(path) === undefined) {
createDataLakeVariable(new DataLakeVariable(path, path, 'number'))
}
setDataLakeVariableData(path, mavlink_message.message.value)
return
} else {
// For all other messages, use the flattener
const flattened = flattenData(mavlink_message.message)
flattened.forEach(({ path, value }) => {
if (value === null) return
if (typeof value !== 'string' && typeof value !== 'number') return
if (getDataLakeVariableInfo(path) === undefined) {
createDataLakeVariable(new DataLakeVariable(path, path, typeof value === 'string' ? 'string' : 'number'))
}
setDataLakeVariableData(path, value)
})
}

// For all other messages, use the flattener
const flattened = flattenData(mavlink_message.message)
flattened.forEach(({ path, value }) => {
if (value === null) return
if (typeof value !== 'string' && typeof value !== 'number') return
if (getDataLakeVariableInfo(path) === undefined) {
createDataLakeVariable(new DataLakeVariable(path, path, typeof value === 'string' ? 'string' : 'number'))
}
setDataLakeVariableData(path, value)
})

// Update our internal messages
this._messages.set(mavlink_message.message.type, { ...mavlink_message.message, epoch: new Date().getTime() })

Expand Down

0 comments on commit 897ba29

Please sign in to comment.