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

drivers: sensors: Add SENSOR_CHAN_FREQUENCY channel #83511

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/sensor/sensor_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static const char *sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
[SENSOR_CHAN_POS_DZ] = "pos_dz",
[SENSOR_CHAN_POS_DXYZ] = "pos_dxyz",
[SENSOR_CHAN_RPM] = "rpm",
[SENSOR_CHAN_FREQUENCY] = "frequency",
[SENSOR_CHAN_GAUGE_VOLTAGE] = "gauge_voltage",
[SENSOR_CHAN_GAUGE_AVG_CURRENT] = "gauge_avg_current",
[SENSOR_CHAN_GAUGE_STDBY_CURRENT] = "gauge_stdby_current",
Expand Down
3 changes: 3 additions & 0 deletions include/zephyr/drivers/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ enum sensor_channel {
/** Revolutions per minute, in RPM. */
SENSOR_CHAN_RPM,

/** Frequency, in Hz. */
SENSOR_CHAN_FREQUENCY,

/** Voltage, in volts **/
SENSOR_CHAN_GAUGE_VOLTAGE,
/** Average current, in amps **/
Expand Down
4 changes: 2 additions & 2 deletions samples/sensor/sensor_shell/pytest/test_sensor_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_sensor_shell_attr_get(shell: Shell):
lines = shell.exec_command('sensor attr_get sensor@0 co2 sampling_frequency')
assert any(['sensor@0(channel=co2, attr=sampling_frequency)' in line for line in lines]), 'expected response not found'

lines = shell.exec_command('sensor attr_get sensor@1 53 3')
lines = shell.exec_command('sensor attr_get sensor@1 54 3')
assert any(['sensor@1(channel=gauge_state_of_health, attr=slope_th)' in line for line in lines]), 'expected response not found'

logger.info('response is valid')
Expand All @@ -50,7 +50,7 @@ def test_sensor_shell_attr_set(shell: Shell):
expected_line = 'sensor@0 channel=co2, attr=sampling_frequency set to value=1'
assert any([expected_line in line for line in lines]), 'expected response not found'

lines = shell.exec_command('sensor attr_set sensor@1 53 3 1')
lines = shell.exec_command('sensor attr_set sensor@1 54 3 1')
expected_line = 'sensor@1 channel=gauge_state_of_health, attr=slope_th set to value=1'
assert any([expected_line in line for line in lines]), 'expected response not found'

Expand Down
Loading