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

sps30_stop_measurement issuing the wrong command #21

Closed
utilebit opened this issue Jan 31, 2019 · 3 comments
Closed

sps30_stop_measurement issuing the wrong command #21

utilebit opened this issue Jan 31, 2019 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@utilebit
Copy link
Contributor

First, thank you for providing this driver and implementation for the SPS30.

When the sps30_stop_measurement method in the sps30.c is called the SPS30 sensor's fan still runs and does not return to idle.

s16 sps30_stop_measurement() {
    u8 param_buf[] = SPS_SUBCMD_MEASUREMENT_STOP;

    return sensirion_shdlc_tx(SPS_ADDR, SPS_CMD_MEASUREMENT,
                              sizeof(param_buf), param_buf);
}

The sps30_stop_measurement method shown above sends a length of 1 and the stop command 0x00 as a sub-command to the sensirion_shdlc_tx method. The SPS30 datasheet for the stop command provides the following example frame for the stop command:

0x7E 0x00 0x01 0x00 0xFE 0x7E

This example frame uses the command 0x01 instead of 0x00 and since it does not have sub-commands it uses a length of zero. The current method does not send the example frame for MOSI described in the datasheet. For this reason, I believe this is a bug.

I was able to fix the bug by adding the constant:

#define SPS_CMD_STOP_MEASUREMENT 0x01

and modifying the method to be:

s16 sps30_stop_measurement() {
    return sensirion_shdlc_tx(SPS_ADDR, SPS_CMD_STOP_MEASUREMENT, 0, NULL);
}
@utilebit utilebit changed the title SPS30 does not go return to idle when calling sps30_stop_measurement() in sps30.c SPS30 does not return to idle after calling sps30_stop_measurement() in sps30.c Jan 31, 2019
@abrauchli
Copy link
Contributor

Hi @utilebit, many thanks for the detailed report and the proposed fix. Would you like to submit a pull request or are you happy with leaving it to us?

When submitting a patch, consider that SPS_CMD_MEASUREMENT would also better be renamed to SPS_CMD_START_MEASUREMENT.

@abrauchli abrauchli added bug Something isn't working good first issue Good for newcomers labels Feb 1, 2019
@abrauchli abrauchli changed the title SPS30 does not return to idle after calling sps30_stop_measurement() in sps30.c sps30_stop_measurement issuing the wrong command Feb 1, 2019
@utilebit
Copy link
Contributor Author

utilebit commented Feb 7, 2019

You are welcome @abrauchli . I submitted a pull request with the fix and the renamed constant.

@abrauchli
Copy link
Contributor

Thanks, merged as 6e3256e (#23)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants