Skip to content

Commit 4ec7309

Browse files
committed
convert serial number to integer for printing
1 parent 92d6798 commit 4ec7309

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

example-usage/scd4x_i2c_example_usage.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@
4343

4444
#define sensirion_hal_sleep_us sensirion_i2c_hal_sleep_usec
4545

46-
void print_ushort_array(uint16_t* array, uint16_t len) {
47-
uint16_t i = 0;
48-
printf("0x");
49-
for (; i < len; i++) {
50-
printf("%04x", array[i]);
51-
}
46+
void convert_and_print_serial(uint16_t* serial_raw) {
47+
uint64_t serial_as_int = 0;
48+
sensirion_common_to_integer((uint8_t*)serial_raw, (uint8_t*)&serial_as_int, LONG_INTEGER, 6);
49+
printf("0x%" PRIx64, serial_as_int);
5250
}
5351

5452
int main(void) {
@@ -81,7 +79,7 @@ int main(void) {
8179
return error;
8280
}
8381
printf("serial number: ");
84-
print_ushort_array(serial_number, 3);
82+
convert_and_print_serial(serial_number);
8583
printf("\n");
8684
//
8785
// If temperature offset and/or sensor altitude compensation

0 commit comments

Comments
 (0)