Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
mcu_arch.c
Go to the documentation of this file.
1
2#include "mcu_arch.h"
3#include "mcu.h"
4
5#include <stdio.h>
6#include <string.h>
7
8void mcu_arch_init(void) {}
9
15{
16 static const char *paths[] = { "/etc/machine-id", "/var/lib/dbus/machine-id" };
17 for (unsigned int p = 0; p < sizeof(paths) / sizeof(paths[0]); p++) {
18 char line[40];
19 FILE *f = fopen(paths[p], "r");
20 if (f == NULL) {
21 continue;
22 }
23 char *ok = fgets(line, sizeof(line), f);
24 fclose(f);
25 if (ok == NULL || strspn(line, "0123456789abcdef") != 32) {
26 continue;
27 }
28 uint8_t len = Min(16, max_len);
29 for (uint8_t i = 0; i < len; i++) {
30 unsigned int b;
31 sscanf(&line[2 * i], "%2x", &b);
32 uid[i] = b;
33 }
34 return len;
35 }
36 return 0;
37}
void mcu_arch_init(void)
Initialize the specific archittecture functions.
Definition mcu_arch.c:157
#define Min(x, y)
Definition esc_dshot.c:110
uint8_t mcu_get_uid(uint8_t *uid, uint8_t max_len)
Get the 96-bit unique device ID of the STM32.
Definition mcu_arch.c:252
static float p[2][2]
Arch independent mcu ( Micro Controller Unit ) utilities.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup).
Definition wedgebug.c:204
float b
Definition wedgebug.c:202