Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
François Revol
firmware
Commits
47aca370
Commit
47aca370
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(bsec): Clean up logging
parent
021448c3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/bsec.c
+36
-31
36 additions, 31 deletions
epicardium/modules/bsec.c
with
36 additions
and
31 deletions
epicardium/modules/bsec.c
+
36
−
31
View file @
47aca370
...
...
@@ -120,19 +120,22 @@ void output_ready(
last_bme680_timestamp
=
timestamp
;
if
(
debug
)
{
printf
(
"BSEC time[ms]: %u, IAQ: %u, IAQ ACC[0-3]: %u, T[.1C]: %u, Hum[.1%%]: %u, P[Pa]: %u, Raw T[.1C]: %u, Raw Hum[.1%%]: %u, Gas[Ohm]: %u, Static IAQ: %u, CO2[ppm]: %u, Breath VOC[ppb]: %u
\n
"
,
(
unsigned
int
)(
timestamp
/
1e6
),
(
unsigned
int
)(
iaq
),
(
unsigned
int
)(
iaq_accuracy
),
(
unsigned
int
)(
temperature
*
10
),
(
unsigned
int
)(
humidity
*
10
),
(
unsigned
int
)(
pressure
),
(
unsigned
int
)(
raw_temperature
*
10
),
(
unsigned
int
)(
raw_humidity
*
10
),
(
unsigned
int
)(
gas
),
(
unsigned
int
)(
static_iaq
),
(
unsigned
int
)(
co2_equivalent
),
(
unsigned
int
)(
breath_voc_equivalent
*
1e3
));
LOG_INFO
(
"bsec"
,
"time[ms]: %u, IAQ: %u, IAQ ACC[0-3]: %u, T[.1C]: %u, Hum[.1%%]: %u, P[Pa]: %u, Raw T[.1C]: %u, Raw Hum[.1%%]: %u, Gas[Ohm]: %u, Static IAQ: %u, CO2[ppm]: %u, Breath VOC[ppb]: %u"
,
(
unsigned
int
)(
timestamp
/
1e6
),
(
unsigned
int
)(
iaq
),
(
unsigned
int
)(
iaq_accuracy
),
(
unsigned
int
)(
temperature
*
10
),
(
unsigned
int
)(
humidity
*
10
),
(
unsigned
int
)(
pressure
),
(
unsigned
int
)(
raw_temperature
*
10
),
(
unsigned
int
)(
raw_humidity
*
10
),
(
unsigned
int
)(
gas
),
(
unsigned
int
)(
static_iaq
),
(
unsigned
int
)(
co2_equivalent
),
(
unsigned
int
)(
breath_voc_equivalent
*
1e3
)
);
}
}
...
...
@@ -158,33 +161,33 @@ static uint32_t bsec_load(char *path, uint8_t *buffer, uint32_t n_buffer)
uint32_t
len
=
0
;
int
fd
,
res
;
printf
(
"BSEC
load %s %lu
\n
"
,
path
,
n_buffer
);
LOG_DEBUG
(
"bsec"
,
"
load %s %lu"
,
path
,
n_buffer
);
if
((
fd
=
epic_file_open
(
path
,
"r"
))
<
0
)
{
printf
(
"Open failed
\n
"
);
LOG_DEBUG
(
"bsec"
,
"Open failed"
);
return
0
;
}
uint32_t
header
;
if
((
res
=
epic_file_read
(
fd
,
&
header
,
sizeof
(
header
)))
!=
sizeof
(
header
))
{
printf
(
"Header failed
\n
"
);
LOG_WARN
(
"bsec"
,
"Header failed"
);
goto
done
;
}
if
(
header
>
n_buffer
)
{
printf
(
"Too large
\n
"
);
LOG_WARN
(
"bsec"
,
"Too large"
);
goto
done
;
}
if
(
epic_file_read
(
fd
,
buffer
,
header
)
!=
(
int
)
header
)
{
printf
(
"Read failed
\n
"
);
LOG_WARN
(
"bsec"
,
"Read failed"
);
goto
done
;
}
len
=
header
;
printf
(
"Success
\n
"
);
LOG_DEBUG
(
"bsec"
,
"Success"
);
done:
epic_file_close
(
fd
);
return
len
;
...
...
@@ -214,27 +217,26 @@ void state_save(const uint8_t *state_buffer, uint32_t length)
{
int
fd
,
res
;
printf
(
"BSEC
state_save %d
\n
"
,
(
int
)
length
);
LOG_DEBUG
(
"bsec"
,
"
state_save %d"
,
(
int
)
length
);
if
((
fd
=
epic_file_open
(
"bsec_iaq.state"
,
"w"
))
<
0
)
{
printf
(
"Open failed
\n
"
);
LOG_WARN
(
"bsec"
,
"Open failed"
);
return
;
}
uint32_t
header
=
length
;
if
((
res
=
epic_file_write
(
fd
,
&
header
,
sizeof
(
header
)))
!=
sizeof
(
header
))
{
printf
(
"Header failed
\n
"
);
LOG_WARN
(
"bsec"
,
"Header failed"
);
goto
done
;
}
if
(
epic_file_write
(
fd
,
state_buffer
,
header
)
!=
(
int
)
header
)
{
printf
(
"Write failed
\n
"
);
LOG_WARN
(
"bsec"
,
"Write failed"
);
goto
done
;
}
printf
(
"stack high: %lu
\n
"
,
uxTaskGetStackHighWaterMark
(
NULL
));
printf
(
"Success
\n
"
);
LOG_DEBUG
(
"bsec"
,
"stack high: %lu"
,
uxTaskGetStackHighWaterMark
(
NULL
));
done:
epic_file_close
(
fd
);
}
...
...
@@ -282,7 +284,7 @@ uint32_t config_load(uint8_t *config_buffer, uint32_t n_buffer)
uint32_t
len
=
bsec_load
(
"bsec_iaq.config"
,
config_buffer
,
n_buffer
);
if
(
len
==
0
)
{
printf
(
"Using default bsec_config_generic_18v_3s_4d
\n
"
);
LOG_INFO
(
"bsec"
,
"Using default bsec_config_generic_18v_3s_4d"
);
len
=
sizeof
(
bsec_config_generic_18v_3s_4d
);
memcpy
(
config_buffer
,
bsec_config_generic_18v_3s_4d
,
len
);
}
...
...
@@ -364,7 +366,7 @@ int bsec_activate(void)
#endif
bool
bsec_enabled
=
config_get_boolean_with_default
(
"bsec_enable
d
"
,
false
);
config_get_boolean_with_default
(
"bsec_enable"
,
false
);
if
(
!
bsec_enabled
)
{
return
-
1
;
}
...
...
@@ -374,8 +376,11 @@ int bsec_activate(void)
float
temperature_offset
=
config_get_integer_with_default
(
"bsec_offset"
,
0
)
/
10
.;
if
(
temperature_offset
!=
0
.
0
)
{
printf
(
"BSEC Temp offset %d/10 K
\n
"
,
(
int
)(
temperature_offset
*
10
));
LOG_INFO
(
"besec"
,
"BSEC Temp offset %d/10 K"
,
(
int
)(
temperature_offset
*
10
)
);
}
/* Puts AT LEAST 2 * #BSEC_MAX_PROPERTY_BLOB_SIZE = 2 * 454 = 908 bytes onto the stack */
...
...
@@ -390,11 +395,11 @@ int bsec_activate(void)
);
if
(
ret
.
bme680_status
)
{
printf
(
"bme680 init failed
\n
"
);
LOG_WARN
(
"bsec"
,
"bme680 init failed"
);
/* Could not intialize BME680 */
return
-
1
;
}
else
if
(
ret
.
bsec_status
)
{
printf
(
"bsec init failed
\n
"
);
LOG_WARN
(
"bsec"
,
"bsec init failed"
);
/* Could not intialize BSEC library */
return
-
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment