mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 04:13:34 +08:00
Kill the old board info code.
This commit is contained in:
@@ -110,76 +110,3 @@ int task_spawn(const char *name, int scheduler, int priority, int stack_size, ma
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
#define PX4_BOARD_ID_FMU (5)
|
||||
|
||||
int fmu_get_board_info(struct fmu_board_info_s *info)
|
||||
{
|
||||
/* Check which FMU version we're on */
|
||||
struct stat sb;
|
||||
int statres;
|
||||
|
||||
/* Copy version-specific fields */
|
||||
statres = stat("/dev/bma180", &sb);
|
||||
|
||||
if (statres == OK) {
|
||||
/* BMA180 indicates a v1.5-v1.6 board */
|
||||
strcpy(info->board_name, "FMU v1.6");
|
||||
info->board_version = 16;
|
||||
|
||||
} else {
|
||||
statres = stat("/dev/accel", &sb);
|
||||
|
||||
if (statres == OK) {
|
||||
/* MPU-6000 indicates a v1.7+ board */
|
||||
strcpy(info->board_name, "FMU v1.7");
|
||||
info->board_version = 17;
|
||||
|
||||
} else {
|
||||
/* If no BMA and no MPU is present, it is a v1.3 board */
|
||||
strcpy(info->board_name, "FMU v1.3");
|
||||
info->board_version = 13;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy general FMU fields */
|
||||
memcpy(info->header, "PX4", 3);
|
||||
info->board_id = PX4_BOARD_ID_FMU;
|
||||
|
||||
return sizeof(struct fmu_board_info_s);
|
||||
}
|
||||
|
||||
int carrier_store_board_info(const struct carrier_board_info_s *info)
|
||||
{
|
||||
int ret;
|
||||
int fd = open("/dev/eeprom", O_RDWR | O_NONBLOCK);
|
||||
|
||||
if (fd < 0) fprintf(stderr, "[boardinfo carrier] ERROR opening carrier eeprom\n");
|
||||
|
||||
/* Enforce correct header */
|
||||
ret = write(fd, info, sizeof(struct carrier_board_info_s));
|
||||
//ret = write(fd, "PX4", 3);
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int carrier_get_board_info(struct carrier_board_info_s *info)
|
||||
{
|
||||
int ret;
|
||||
int fd = open("/dev/eeprom", O_RDONLY | O_NONBLOCK);
|
||||
|
||||
if (fd < 0)
|
||||
return -1; /* no board */
|
||||
|
||||
ret = read(fd, info, sizeof(struct carrier_board_info_s));
|
||||
|
||||
/* Enforce NUL termination of human-readable string */
|
||||
if (ret == sizeof(struct carrier_board_info_s)) {
|
||||
info->board_name[sizeof(info->board_name) - 1] = '\0';
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user