@@ -1183,14 +1183,15 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
1183
1183
if (value & OSTC4_COMPASS_HEADING_CLEARED_FLAG ) {
1184
1184
snprintf (buf , BUFLEN , "Cleared compass heading" );
1185
1185
} else {
1186
+ sample .event .value = heading ;
1187
+
1186
1188
if (value & OSTC4_COMPASS_HEADING_SET_FLAG ) {
1187
1189
sample .event .type = SAMPLE_EVENT_HEADING ;
1188
- snprintf (buf , BUFLEN , "Set compass heading %d degrees" , heading );
1190
+ snprintf (buf , BUFLEN , "Set compass heading [ degrees]%s " , sample . event . value ? "" : ": 0" );
1189
1191
} else {
1190
- snprintf (buf , BUFLEN , "Logged compass heading %d degrees" , heading );
1192
+ snprintf (buf , BUFLEN , "Logged compass heading [ degrees]%s " , sample . event . value ? "" : ": 0" );
1191
1193
}
1192
1194
1193
- sample .event .value = heading ;
1194
1195
}
1195
1196
1196
1197
sample .event .name = buf ;
@@ -1210,7 +1211,10 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
1210
1211
}
1211
1212
1212
1213
unsigned int scrubberState = array_uint16_le (data + offset );
1213
- int scrubberTimeMinutes = (scrubberState & 0x0800 ) ? (-1 ^ 0x0FFF ) | (scrubberState & 0x0FFF ) : scrubberState & 0x0FFF ; // extract 12 bit signed int
1214
+ int scrubberTimeMinutes = scrubberState & 0x0FFF ; // Extract the 12-bit value
1215
+ if (scrubberState & 0x0800 ) { // Check if the sign bit is set
1216
+ scrubberTimeMinutes -= 0x1000 ; // Perform sign extension
1217
+ }
1214
1218
if (parser -> first_scrubber_time_minutes == INT_MAX ) {
1215
1219
parser -> first_scrubber_time_minutes = scrubberTimeMinutes ;
1216
1220
}
@@ -1220,23 +1224,23 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
1220
1224
dc_sample_value_t sample = {
1221
1225
.event .type = SAMPLE_EVENT_STRING ,
1222
1226
.event .flags = SAMPLE_FLAGS_SEVERITY_STATE ,
1227
+ .event .value = scrubberTimeMinutes ,
1223
1228
};
1224
1229
1225
-
1226
1230
if (scrubberState & OSTC4_SCRUBBER_STATE_ERROR_FLAG ) {
1227
1231
if (!parser -> scrubber_error_reported ) {
1228
- sample .event .flags = SAMPLE_FLAGS_SEVERITY_ALARM ;
1229
- parser -> scrubber_error_reported = true;
1232
+ sample .event .flags = SAMPLE_FLAGS_SEVERITY_ALARM ;
1233
+ parser -> scrubber_error_reported = true;
1230
1234
}
1231
- snprintf (buf , BUFLEN , "Scrubber exhausted: %d minutes remaining" , scrubberTimeMinutes );
1235
+ snprintf (buf , BUFLEN , "Scrubber exhausted, time remaining [minutes]%s " , sample . event . value ? "" : ": 0" );
1232
1236
} else if (scrubberState & OSTC4_SCRUBBER_STATE_WARNING_FLAG ) {
1233
1237
if (!parser -> scrubber_warning_reported ) {
1234
- sample .event .flags = SAMPLE_FLAGS_SEVERITY_WARN ;
1235
- parser -> scrubber_warning_reported = true;
1238
+ sample .event .flags = SAMPLE_FLAGS_SEVERITY_WARN ;
1239
+ parser -> scrubber_warning_reported = true;
1236
1240
}
1237
- snprintf (buf , BUFLEN , "Scrubber warning: %d minutes remaining" , scrubberTimeMinutes );
1241
+ snprintf (buf , BUFLEN , "Scrubber warning, time remaining [minutes]%s " , sample . event . value ? "" : ": 0" );
1238
1242
} else {
1239
- snprintf (buf , BUFLEN , "Scrubber: %d minutes remaining" , scrubberTimeMinutes );
1243
+ snprintf (buf , BUFLEN , "Scrubber time remaining [minutes]%s " , sample . event . value ? "" : ": 0" );
1240
1244
}
1241
1245
1242
1246
sample .event .name = buf ;
0 commit comments