Beispiel #1
0
int UavcanNode::getHardwareVersion(uavcan::protocol::HardwareVersion &hwver)
{
	int rv = -1;

	if (UavcanNode::instance()) {
		if (!std::strncmp(px4_board_name(), "PX4FMU_V1", 9)) {
			hwver.major = 1;

		} else if (!std::strncmp(px4_board_name(), "PX4FMU_V2", 9)) {
			hwver.major = 2;

		} else {
			; // All other values of px4_board_name() resolve to zero
		}

		mfguid_t mfgid = {};
		board_get_mfguid(mfgid);
		uavcan::copy(mfgid, mfgid + sizeof(mfgid), hwver.unique_id.begin());
		rv = 0;
	}

	return rv;
}
Beispiel #2
0
int UavcanNode::getHardwareVersion(uavcan::protocol::HardwareVersion &hwver)
{
	int rv = -1;

	if (UavcanNode::instance()) {
		if (!std::strncmp(px4_board_name(), "PX4FMU_V1", 9)) {
			hwver.major = 1;

		} else if (!std::strncmp(px4_board_name(), "PX4FMU_V2", 9)) {
			hwver.major = 2;

		} else {
			; // All other values of px4_board_name() resolve to zero
		}

		uint8_t udid[12] = {};  // Someone seems to love magic numbers
		get_board_serial(udid);
		uavcan::copy(udid, udid + sizeof(udid), hwver.unique_id.begin());
		rv = 0;
	}

	return rv;
}