drivers: sensors: Add SENSOR_CHAN_FREQUENCY channel
Add new SENSOR_CHAN_FREQUENCY constant to allow implement sensors that output frequency values in Hertz. Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This commit is contained in:
parent
549def6b10
commit
ac579a8f89
3 changed files with 6 additions and 2 deletions
|
|
@ -88,6 +88,7 @@ static const char *sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
|
||||||
[SENSOR_CHAN_POS_DZ] = "pos_dz",
|
[SENSOR_CHAN_POS_DZ] = "pos_dz",
|
||||||
[SENSOR_CHAN_POS_DXYZ] = "pos_dxyz",
|
[SENSOR_CHAN_POS_DXYZ] = "pos_dxyz",
|
||||||
[SENSOR_CHAN_RPM] = "rpm",
|
[SENSOR_CHAN_RPM] = "rpm",
|
||||||
|
[SENSOR_CHAN_FREQUENCY] = "frequency",
|
||||||
[SENSOR_CHAN_GAUGE_VOLTAGE] = "gauge_voltage",
|
[SENSOR_CHAN_GAUGE_VOLTAGE] = "gauge_voltage",
|
||||||
[SENSOR_CHAN_GAUGE_AVG_CURRENT] = "gauge_avg_current",
|
[SENSOR_CHAN_GAUGE_AVG_CURRENT] = "gauge_avg_current",
|
||||||
[SENSOR_CHAN_GAUGE_STDBY_CURRENT] = "gauge_stdby_current",
|
[SENSOR_CHAN_GAUGE_STDBY_CURRENT] = "gauge_stdby_current",
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,9 @@ enum sensor_channel {
|
||||||
/** Revolutions per minute, in RPM. */
|
/** Revolutions per minute, in RPM. */
|
||||||
SENSOR_CHAN_RPM,
|
SENSOR_CHAN_RPM,
|
||||||
|
|
||||||
|
/** Frequency, in Hz. */
|
||||||
|
SENSOR_CHAN_FREQUENCY,
|
||||||
|
|
||||||
/** Voltage, in volts **/
|
/** Voltage, in volts **/
|
||||||
SENSOR_CHAN_GAUGE_VOLTAGE,
|
SENSOR_CHAN_GAUGE_VOLTAGE,
|
||||||
/** Average current, in amps **/
|
/** Average current, in amps **/
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ def test_sensor_shell_attr_get(shell: Shell):
|
||||||
lines = shell.exec_command('sensor attr_get sensor@0 co2 sampling_frequency')
|
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'
|
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'
|
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')
|
logger.info('response is valid')
|
||||||
|
|
@ -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'
|
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'
|
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'
|
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'
|
assert any([expected_line in line for line in lines]), 'expected response not found'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue