mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 02:47:35 +08:00
HoTT: Fixed code style
This commit is contained in:
@@ -57,10 +57,11 @@ open_uart(const char *device)
|
||||
if (uart < 0) {
|
||||
err(1, "ERR: opening %s", device);
|
||||
}
|
||||
|
||||
/* Back up the original uart configuration to restore it after exit */
|
||||
|
||||
/* Back up the original uart configuration to restore it after exit */
|
||||
int termios_state;
|
||||
struct termios uart_config_original;
|
||||
|
||||
if ((termios_state = tcgetattr(uart, &uart_config_original)) < 0) {
|
||||
close(uart);
|
||||
err(1, "ERR: %s: %d", device, termios_state);
|
||||
@@ -77,7 +78,7 @@ open_uart(const char *device)
|
||||
if (cfsetispeed(&uart_config, speed) < 0 || cfsetospeed(&uart_config, speed) < 0) {
|
||||
close(uart);
|
||||
err(1, "ERR: %s: %d (cfsetispeed, cfsetospeed)",
|
||||
device, termios_state);
|
||||
device, termios_state);
|
||||
}
|
||||
|
||||
if ((termios_state = tcsetattr(uart, TCSANOW, &uart_config)) < 0) {
|
||||
|
||||
@@ -69,7 +69,7 @@ static bool _home_position_set = false;
|
||||
static double _home_lat = 0.0d;
|
||||
static double _home_lon = 0.0d;
|
||||
|
||||
void
|
||||
void
|
||||
init_sub_messages(void)
|
||||
{
|
||||
_battery_sub = orb_subscribe(ORB_ID(battery_status));
|
||||
@@ -80,7 +80,7 @@ init_sub_messages(void)
|
||||
_esc_sub = orb_subscribe(ORB_ID(esc_status));
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
init_pub_messages(void)
|
||||
{
|
||||
}
|
||||
@@ -122,12 +122,13 @@ publish_gam_message(const uint8_t *buffer)
|
||||
/* announce the esc if needed, just publish else */
|
||||
if (_esc_pub != nullptr) {
|
||||
orb_publish(ORB_ID(esc_status), _esc_pub, &esc);
|
||||
|
||||
} else {
|
||||
_esc_pub = orb_advertise(ORB_ID(esc_status), &esc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
build_eam_response(uint8_t *buffer, size_t *size)
|
||||
{
|
||||
/* get a local copy of the current sensor values */
|
||||
@@ -147,7 +148,7 @@ build_eam_response(uint8_t *buffer, size_t *size)
|
||||
msg.start = START_BYTE;
|
||||
msg.eam_sensor_id = EAM_SENSOR_ID;
|
||||
msg.sensor_text_id = EAM_SENSOR_TEXT_ID;
|
||||
|
||||
|
||||
msg.temperature1 = (uint8_t)(raw.baro_temp_celcius[0] + 20);
|
||||
msg.temperature2 = msg.temperature1 - BOARD_TEMP_OFFSET_DEG;
|
||||
|
||||
@@ -170,7 +171,7 @@ build_eam_response(uint8_t *buffer, size_t *size)
|
||||
memcpy(buffer, &msg, *size);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
build_gam_response(uint8_t *buffer, size_t *size)
|
||||
{
|
||||
/* get a local copy of the ESC Status values */
|
||||
@@ -185,7 +186,7 @@ build_gam_response(uint8_t *buffer, size_t *size)
|
||||
msg.start = START_BYTE;
|
||||
msg.gam_sensor_id = GAM_SENSOR_ID;
|
||||
msg.sensor_text_id = GAM_SENSOR_TEXT_ID;
|
||||
|
||||
|
||||
msg.temperature1 = (uint8_t)(esc.esc[0].esc_temperature + 20.0F);
|
||||
msg.temperature2 = 20; // 0 deg. C.
|
||||
|
||||
@@ -205,7 +206,7 @@ build_gam_response(uint8_t *buffer, size_t *size)
|
||||
memcpy(buffer, &msg, *size);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
build_gps_response(uint8_t *buffer, size_t *size)
|
||||
{
|
||||
/* get a local copy of the current sensor values */
|
||||
@@ -213,7 +214,7 @@ build_gps_response(uint8_t *buffer, size_t *size)
|
||||
memset(&raw, 0, sizeof(raw));
|
||||
orb_copy(ORB_ID(sensor_combined), _sensor_sub, &raw);
|
||||
|
||||
/* get a local copy of the battery data */
|
||||
/* get a local copy of the battery data */
|
||||
struct vehicle_gps_position_s gps;
|
||||
memset(&gps, 0, sizeof(gps));
|
||||
orb_copy(ORB_ID(vehicle_gps_position), _gps_sub, &gps);
|
||||
@@ -241,12 +242,13 @@ build_gps_response(uint8_t *buffer, size_t *size)
|
||||
uint16_t speed = (uint16_t)(gps.vel_m_s * 3.6f);
|
||||
msg.gps_speed_L = (uint8_t)speed & 0xff;
|
||||
msg.gps_speed_H = (uint8_t)(speed >> 8) & 0xff;
|
||||
|
||||
/* Get latitude in degrees, minutes and seconds */
|
||||
double lat = ((double)(gps.lat))*1e-7d;
|
||||
|
||||
/* Set the N or S specifier */
|
||||
/* Get latitude in degrees, minutes and seconds */
|
||||
double lat = ((double)(gps.lat)) * 1e-7d;
|
||||
|
||||
/* Set the N or S specifier */
|
||||
msg.latitude_ns = 0;
|
||||
|
||||
if (lat < 0) {
|
||||
msg.latitude_ns = 1;
|
||||
lat = abs(lat);
|
||||
@@ -265,32 +267,34 @@ build_gps_response(uint8_t *buffer, size_t *size)
|
||||
msg.latitude_sec_H = (uint8_t)(lat_sec >> 8) & 0xff;
|
||||
|
||||
/* Get longitude in degrees, minutes and seconds */
|
||||
double lon = ((double)(gps.lon))*1e-7d;
|
||||
double lon = ((double)(gps.lon)) * 1e-7d;
|
||||
|
||||
/* Set the E or W specifier */
|
||||
msg.longitude_ew = 0;
|
||||
|
||||
if (lon < 0) {
|
||||
msg.longitude_ew = 1;
|
||||
lon = abs(lon);
|
||||
}
|
||||
|
||||
convert_to_degrees_minutes_seconds(lon, °, &min, &sec);
|
||||
|
||||
|
||||
uint16_t lon_min = (uint16_t)(deg * 100 + min);
|
||||
msg.longitude_min_L = (uint8_t)lon_min & 0xff;
|
||||
msg.longitude_min_H = (uint8_t)(lon_min >> 8) & 0xff;
|
||||
uint16_t lon_sec = (uint16_t)(sec);
|
||||
msg.longitude_sec_L = (uint8_t)lon_sec & 0xff;
|
||||
msg.longitude_sec_H = (uint8_t)(lon_sec >> 8) & 0xff;
|
||||
|
||||
|
||||
/* Altitude */
|
||||
uint16_t alt = (uint16_t)(gps.alt*1e-3f + 500.0f);
|
||||
uint16_t alt = (uint16_t)(gps.alt * 1e-3f + 500.0f);
|
||||
msg.altitude_L = (uint8_t)alt & 0xff;
|
||||
msg.altitude_H = (uint8_t)(alt >> 8) & 0xff;
|
||||
|
||||
/* Get any (and probably only ever one) _home_sub postion report */
|
||||
bool updated;
|
||||
orb_check(_home_sub, &updated);
|
||||
|
||||
if (updated) {
|
||||
/* get a local copy of the home position data */
|
||||
struct home_position_s home;
|
||||
|
||||
+52
-52
@@ -125,63 +125,63 @@ struct eam_module_msg {
|
||||
#define GAM_SENSOR_TEXT_ID 0xd0
|
||||
|
||||
struct gam_module_msg {
|
||||
uint8_t start; /**< Start byte */
|
||||
uint8_t gam_sensor_id; /**< GAM sensor id */
|
||||
uint8_t warning_beeps;
|
||||
uint8_t sensor_text_id;
|
||||
uint8_t alarm_invers1;
|
||||
uint8_t alarm_invers2;
|
||||
uint8_t cell1; /**< Lipo cell voltages. Not supported. */
|
||||
uint8_t cell2;
|
||||
uint8_t cell3;
|
||||
uint8_t cell4;
|
||||
uint8_t cell5;
|
||||
uint8_t cell6;
|
||||
uint8_t batt1_L; /**< Battery 1 voltage LSB value. 0.1V steps. 50 = 5.5V */
|
||||
uint8_t batt1_H;
|
||||
uint8_t batt2_L; /**< Battery 2 voltage LSB value. 0.1V steps. 50 = 5.5V */
|
||||
uint8_t batt2_H;
|
||||
uint8_t temperature1; /**< Temperature 1. offset of 20. a value of 20 = 0°C */
|
||||
uint8_t temperature2; /**< Temperature 2. offset of 20. a value of 20 = 0°C */
|
||||
uint8_t fuel_procent; /**< Fuel capacity in %. Values 0 - 100 */
|
||||
/**< Graphical display ranges: 0 25% 50% 75% 100% */
|
||||
uint8_t fuel_ml_L; /**< Fuel in ml scale. Full = 65535 */
|
||||
uint8_t fuel_ml_H;
|
||||
uint8_t rpm_L; /**< RPM in 10 RPM steps. 300 = 3000rpm */
|
||||
uint8_t rpm_H;
|
||||
uint8_t altitude_L; /**< Altitude in meters. offset of 500, 500 = 0m */
|
||||
uint8_t altitude_H;
|
||||
uint8_t climbrate_L; /**< Climb rate in 0.01m/s. Value of 30000 = 0.00 m/s */
|
||||
uint8_t climbrate_H;
|
||||
uint8_t climbrate3s; /**< Climb rate in m/3sec. Value of 120 = 0m/3sec */
|
||||
uint8_t current_L; /**< Current in 0.1A steps */
|
||||
uint8_t current_H;
|
||||
uint8_t main_voltage_L; /**< Main power voltage using 0.1V steps */
|
||||
uint8_t main_voltage_H;
|
||||
uint8_t batt_cap_L; /**< Used battery capacity in 10mAh steps */
|
||||
uint8_t batt_cap_H;
|
||||
uint8_t speed_L; /**< Speed in km/h */
|
||||
uint8_t speed_H;
|
||||
uint8_t min_cell_volt; /**< Minimum cell voltage in 2mV steps. 124 = 2,48V */
|
||||
uint8_t min_cell_volt_num; /**< Number of the cell with the lowest voltage */
|
||||
uint8_t rpm2_L; /**< RPM in 10 RPM steps. 300 = 3000rpm */
|
||||
uint8_t rpm2_H;
|
||||
uint8_t general_error_number; /**< Voice error == 12. TODO: more docu */
|
||||
uint8_t pressure; /**< Pressure up to 16bar. 0,1bar scale. 20 = 2bar */
|
||||
uint8_t version;
|
||||
uint8_t stop; /**< Stop byte */
|
||||
uint8_t checksum; /**< Lower 8-bits of all bytes summed */
|
||||
uint8_t start; /**< Start byte */
|
||||
uint8_t gam_sensor_id; /**< GAM sensor id */
|
||||
uint8_t warning_beeps;
|
||||
uint8_t sensor_text_id;
|
||||
uint8_t alarm_invers1;
|
||||
uint8_t alarm_invers2;
|
||||
uint8_t cell1; /**< Lipo cell voltages. Not supported. */
|
||||
uint8_t cell2;
|
||||
uint8_t cell3;
|
||||
uint8_t cell4;
|
||||
uint8_t cell5;
|
||||
uint8_t cell6;
|
||||
uint8_t batt1_L; /**< Battery 1 voltage LSB value. 0.1V steps. 50 = 5.5V */
|
||||
uint8_t batt1_H;
|
||||
uint8_t batt2_L; /**< Battery 2 voltage LSB value. 0.1V steps. 50 = 5.5V */
|
||||
uint8_t batt2_H;
|
||||
uint8_t temperature1; /**< Temperature 1. offset of 20. a value of 20 = 0°C */
|
||||
uint8_t temperature2; /**< Temperature 2. offset of 20. a value of 20 = 0°C */
|
||||
uint8_t fuel_procent; /**< Fuel capacity in %. Values 0 - 100 */
|
||||
/**< Graphical display ranges: 0 25% 50% 75% 100% */
|
||||
uint8_t fuel_ml_L; /**< Fuel in ml scale. Full = 65535 */
|
||||
uint8_t fuel_ml_H;
|
||||
uint8_t rpm_L; /**< RPM in 10 RPM steps. 300 = 3000rpm */
|
||||
uint8_t rpm_H;
|
||||
uint8_t altitude_L; /**< Altitude in meters. offset of 500, 500 = 0m */
|
||||
uint8_t altitude_H;
|
||||
uint8_t climbrate_L; /**< Climb rate in 0.01m/s. Value of 30000 = 0.00 m/s */
|
||||
uint8_t climbrate_H;
|
||||
uint8_t climbrate3s; /**< Climb rate in m/3sec. Value of 120 = 0m/3sec */
|
||||
uint8_t current_L; /**< Current in 0.1A steps */
|
||||
uint8_t current_H;
|
||||
uint8_t main_voltage_L; /**< Main power voltage using 0.1V steps */
|
||||
uint8_t main_voltage_H;
|
||||
uint8_t batt_cap_L; /**< Used battery capacity in 10mAh steps */
|
||||
uint8_t batt_cap_H;
|
||||
uint8_t speed_L; /**< Speed in km/h */
|
||||
uint8_t speed_H;
|
||||
uint8_t min_cell_volt; /**< Minimum cell voltage in 2mV steps. 124 = 2,48V */
|
||||
uint8_t min_cell_volt_num; /**< Number of the cell with the lowest voltage */
|
||||
uint8_t rpm2_L; /**< RPM in 10 RPM steps. 300 = 3000rpm */
|
||||
uint8_t rpm2_H;
|
||||
uint8_t general_error_number; /**< Voice error == 12. TODO: more docu */
|
||||
uint8_t pressure; /**< Pressure up to 16bar. 0,1bar scale. 20 = 2bar */
|
||||
uint8_t version;
|
||||
uint8_t stop; /**< Stop byte */
|
||||
uint8_t checksum; /**< Lower 8-bits of all bytes summed */
|
||||
};
|
||||
|
||||
/* GPS sensor constants. */
|
||||
#define GPS_SENSOR_ID 0x8a
|
||||
#define GPS_SENSOR_TEXT_ID 0xa0
|
||||
|
||||
/**
|
||||
/**
|
||||
* The GPS sensor message
|
||||
* Struct based on: https://code.google.com/p/diy-hott-gps/downloads
|
||||
* Struct based on: https://code.google.com/p/diy-hott-gps/downloads
|
||||
*/
|
||||
struct gps_module_msg {
|
||||
struct gps_module_msg {
|
||||
uint8_t start; /**< Start byte */
|
||||
uint8_t sensor_id; /**< GPS sensor ID*/
|
||||
uint8_t warning; /**< 0…= warning beeps */
|
||||
@@ -191,19 +191,19 @@ struct gps_module_msg {
|
||||
uint8_t flight_direction; /**< 119 = Flightdir./dir. 1 = 2°; 0° (North), 9 0° (East), 180° (South), 270° (West) */
|
||||
uint8_t gps_speed_L; /**< 8 = /GPS speed low byte 8km/h */
|
||||
uint8_t gps_speed_H; /**< 0 = /GPS speed high byte */
|
||||
|
||||
|
||||
uint8_t latitude_ns; /**< 000 = N = 48°39’988 */
|
||||
uint8_t latitude_min_L; /**< 231 0xE7 = 0x12E7 = 4839 */
|
||||
uint8_t latitude_min_H; /**< 018 18 = 0x12 */
|
||||
uint8_t latitude_sec_L; /**< 171 220 = 0xDC = 0x03DC =0988 */
|
||||
uint8_t latitude_sec_H; /**< 016 3 = 0x03 */
|
||||
|
||||
|
||||
uint8_t longitude_ew; /**< 000 = E= 9° 25’9360 */
|
||||
uint8_t longitude_min_L; /**< 150 157 = 0x9D = 0x039D = 0925 */
|
||||
uint8_t longitude_min_H; /**< 003 3 = 0x03 */
|
||||
uint8_t longitude_sec_L; /**< 056 144 = 0x90 0x2490 = 9360 */
|
||||
uint8_t longitude_sec_H; /**< 004 36 = 0x24 */
|
||||
|
||||
|
||||
uint8_t distance_L; /**< 027 123 = /distance low byte 6 = 6 m */
|
||||
uint8_t distance_H; /**< 036 35 = /distance high byte */
|
||||
uint8_t altitude_L; /**< 243 244 = /Altitude low byte 500 = 0m */
|
||||
|
||||
Reference in New Issue
Block a user