Skip to content

Commit

Permalink
Merge branch 'add-application-errors' into 'main'
Browse files Browse the repository at this point in the history
Add support for sensor specific errors

See merge request MSO-SW/drivers/arduino/arduino-core!29
  • Loading branch information
rnestler committed Nov 19, 2021
2 parents 39c5932 + 3ac0d8d commit b850372
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

`Unreleased`_
-------------

- Add support for sensor specific errors


`0.5.2`_ 2021-08-03
-------------------

Expand Down
8 changes: 8 additions & 0 deletions src/SensirionErrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@

void errorToString(uint16_t error, char errorMessage[],
size_t errorMessageSize) {

uint16_t highLevelError = error & 0xFF00;
uint16_t lowLevelError = error & 0x00FF;

if (error & HighLevelError::SensorSpecificError) {
snprintf(errorMessage, errorMessageSize, "Sensor specific error: 0x%2x",
lowLevelError);
return;
}

switch (highLevelError) {
case HighLevelError::NoError:
if (!error) {
Expand Down
6 changes: 5 additions & 1 deletion src/SensirionErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ enum HighLevelError : uint16_t {
TxFrameError = 0x0300,
RxFrameError = 0x0400,
// shdlc errors
ExecutionError = 0x0500
ExecutionError = 0x0500,
// i2c errors

// Sensor specific errors. All errors higher than that are depending on the
// sensor used.
SensorSpecificError = 0x8000,
};

enum LowLevelError : uint16_t {
Expand Down

0 comments on commit b850372

Please sign in to comment.