Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve features (+ cli) #13494

Merged
merged 10 commits into from
May 20, 2024
Merged

Conversation

ledvinap
Copy link
Contributor

@ledvinap ledvinap commented Apr 3, 2024

Description in commits.

654b658 needs some discussion:

  • is it OK to change feature responses (set/reset/unavailable)?
  • is AlreadyDisabled / AlreadyEnabled usefull?
  • feature list returns all known features. Maybe return only features that are available in firmware? Or mark unavailable ones (!GPS)?

Petr Ledvina added 4 commits April 3, 2024 13:19
Use designated initializers for used features. NULL values are stored
in gaps.
Use ARRAYLEN() for featureNames iteration
Use `unsigned` for bitmasks
bitmask of features that are supported in current build
configuration. Copied from init.c sanitization
featuresSupportedByBuild makes things much easier
- refuse all features that are not compiled in
- AlreadyDisabled/AlreadyEnabled info
- refuse operation if multiple features match
Copy link

github-actions bot commented Apr 3, 2024

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13494 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

src/main/cli/cli.c Outdated Show resolved Hide resolved
@blckmn
Copy link
Member

blckmn commented Apr 9, 2024

the command feature list might be worth adding some params - or simply return all, including unavailable as you indicated.

@haslinghuis
Copy link
Member

In case of unavailable might have to split in all features - with a list of unavailable features on a second row.

@ledvinap
Copy link
Contributor Author

the command feature list might be worth adding some params - or simply return all, including unavailable as you indicated.

Problem is that it needs more parsing of cmdline - lot of code with minimum gain.

Currently all are returned, for backward compatibility. New commit splits features on two lines, each with header (even code parsing 'Available:' shall work, with limited feature list

@ledvinap
Copy link
Contributor Author

ledvinap commented Apr 10, 2024

When this PR is open - is it worth supporting feature softserial telem -led_st -osd 3d ( = multiple enable.disable in single command)?

@blckmn
Copy link
Member

blckmn commented May 7, 2024

When this PR is open - is it worth supporting feature softserial telem -led_st -osd 3d ( = multiple enable.disable in single command)?

this would make the diff and dump interesting... I like the idea, but it might be more complicated than the potential value it would deliver.

@nerdCopter
Copy link
Member

nerdCopter commented May 10, 2024

a4cded977 bare-minimum testing:
https://build.betaflight.com/api/builds/9ed43bba544fdfa398274c9e207cc175/json

  • show features
  • feature list
  • modified features
  • show features again
  • set unavailable
# diff all

# version
# Betaflight / STM32F405 (S405) 4.5.0 May 10 2024 / 19:00:12 (a4cded977) MSP API: 1.46
# config rev: 39d434c

# start the command batch
batch start

# reset configuration to default settings
defaults nosave

board_name FOXEERF405
manufacturer_id FOXE
mcu_id 0042004f4e48500920303452
signature 

# feature
feature TELEMETRY
feature LED_STRIP
feature OSD

# master
set acc_calibration = -11,13,80,1
set osd_canvas_height = 13

profile 0

profile 1

profile 2

profile 3

# restore original profile selection
profile 0

rateprofile 0

rateprofile 1

rateprofile 2

rateprofile 3

# restore original rateprofile selection
rateprofile 0

# save configuration
save
# feature
Enabled:  RX_SERIAL TELEMETRY LED_STRIP OSD AIRMODE ANTI_GRAVITY

# feature list
Available:  INFLIGHT_ACC_CAL RX_SERIAL MOTOR_STOP SOFTSERIAL GPS TELEMETRY 3D RSSI_ADC LED_STRIP OSD AIRMODE ESC_SENSOR ANTI_GRAVITY
NotSupported: RX_PPM SERVO_TILT RANGEFINDER RX_PARALLEL_PWM DISPLAY CHANNEL_FORWARDING TRANSPONDER RX_SPI

# feature ESC_SENSOR
Enabled ESC_SENSOR

# feature -LED_STRIP
Disabled LED_STRIP

# feature
Enabled:  RX_SERIAL TELEMETRY OSD AIRMODE ESC_SENSOR ANTI_GRAVITY

# feature RANGEFINDER
Unavailable RANGEFINDER

src/main/cli/cli.c Outdated Show resolved Hide resolved
@nerdCopter
Copy link
Member

@ledvinap , i do not mind listing unsupported in feature list as you have done. if the ! is used, then such might not be human-readable.

also, maybe feature should output the same as feature list and no need for the extra word list 🤷‍♂️

@SteveCEvans
Copy link
Member

The available list is in the configurator. I think it best if the firmware only reports on the features built into it.

@haslinghuis
Copy link
Member

@ledvinap please rebase

@haslinghuis haslinghuis requested a review from a team May 15, 2024 23:10
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
@ledvinap
Copy link
Contributor Author

The available list is in the configurator. I think it best if the firmware only reports on the features built into it.

I did try to follow old behavior - it did print all features, compiled-in or not.
It was meant to remind user that feature does exist, but must be enabled somehow.

I started this PR because I struggled with some feature (maybe SOFTSERIAL, nut I'm not sure) that was not enabled in cloud build. It took some time before I realized it.

@nerdCopter
Copy link
Member

nerdCopter commented May 17, 2024

i like the unavailable list. i would not want to have to search for and compare against some external source.
i'd like to repeat:

also, maybe feature should output the same as feature list and no need for the extra word list 🤷‍♂️

IMHO

@ledvinap
Copy link
Contributor Author

@nerdCopter : Enabled / Available / Unavailable ?

Maybe I can even add features that got automatically disabled (since last reboot only)

Comment on lines +424 to +425
FEATURE_DASHBOARD | FEATURE_LED_STRIP | FEATURE_OSD | FEATURE_RANGEFINDER
| FEATURE_CHANNEL_FORWARDING | FEATURE_SERVO_TILT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think these are most common, the other ones should be enabled manually

Suggested change
FEATURE_DASHBOARD | FEATURE_LED_STRIP | FEATURE_OSD | FEATURE_RANGEFINDER
| FEATURE_CHANNEL_FORWARDING | FEATURE_SERVO_TILT
FEATURE_LED_STRIP | FEATURE_OSD

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haslinghuis : I tried to avoid changing behavior of code where not necessary. We can easily change defaults in separate PR, probably together with target defaults

@nerdCopter
Copy link
Member

74ed6e7ab

# version
# Betaflight / STM32F405 (S405) 4.6.0 May 20 2024 / 08:17:02 (74ed6e7ab) MSP API: 1.46
# config rev: 93dfc69
# board: manufacturer_id: FOXE, board_name: FOXEERF405

# feature
Enabled:  RX_SERIAL LED_STRIP OSD AIRMODE ANTI_GRAVITY
Available:  INFLIGHT_ACC_CAL MOTOR_STOP SOFTSERIAL GPS TELEMETRY 3D RSSI_ADC ESC_SENSOR
Unavailable: RX_PPM SERVO_TILT RANGEFINDER RX_PARALLEL_PWM DISPLAY CHANNEL_FORWARDING TRANSPONDER RX_SPI

# feature -LED_STRIP
Disabled LED_STRIP

# feature ESC_SENSOR
Enabled ESC_SENSOR

# feature
Enabled:  RX_SERIAL OSD AIRMODE ESC_SENSOR ANTI_GRAVITY
Available:  INFLIGHT_ACC_CAL MOTOR_STOP SOFTSERIAL GPS TELEMETRY 3D RSSI_ADC LED_STRIP
Unavailable: RX_PPM SERVO_TILT RANGEFINDER RX_PARALLEL_PWM DISPLAY CHANNEL_FORWARDING TRANSPONDER RX_SPI

@haslinghuis haslinghuis merged commit 286cfb5 into betaflight:master May 20, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants