Skip to content

Commit

Permalink
core: frontend: autopilot: parameter: Allow handling undefined cases …
Browse files Browse the repository at this point in the history
…by caller

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Mar 20, 2024
1 parent 5cd5351 commit 92e81f6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/frontend/src/types/autopilot/parameter.ts
Expand Up @@ -39,13 +39,12 @@ export default interface Parameter {
units?: string
}

export function printParam(param?: Parameter): string {
export function printParam(param: Parameter | undefined): string | undefined {
if (param === undefined) {
return 'Unknown'
return undefined
}

// Show device id as an hexadecimal value
if (param?.name.includes('_DEV_ID') || param?.name.includes('_DEVID')) {
if (param.name.includes('_DEV_ID') || param.name.includes('_DEVID')) {
return `0x${param.value.toString(16).padStart(8, '0')}`
}

Expand Down

0 comments on commit 92e81f6

Please sign in to comment.