116 lines
4.4 KiB
C
116 lines
4.4 KiB
C
|
/*
|
||
|
* Copyright (C) 2023 Daniele Lacamera <root@danielinux.net>
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#ifndef KSP_SERIAL_H
|
||
|
#define KSP_SERIAL_H
|
||
|
#include <stdint.h>
|
||
|
|
||
|
|
||
|
typedef struct __attribute__((packed)) vesselData {
|
||
|
uint8_t id; //1
|
||
|
float AP; //2
|
||
|
float PE; //3
|
||
|
float SemiMajorAxis; //4
|
||
|
float SemiMinorAxis; //5
|
||
|
float VVI; //6
|
||
|
float e; //7
|
||
|
float inc; //8
|
||
|
float G; //9
|
||
|
int32_t TAp; //10
|
||
|
int32_t TPe; //11
|
||
|
float TrueAnomaly; //12
|
||
|
float Density; //13
|
||
|
int32_t period; //14
|
||
|
float RAlt; //15
|
||
|
float Alt; //16
|
||
|
float Vsurf; //17
|
||
|
float Lat; //18
|
||
|
float Lon; //19
|
||
|
float LiquidFuelTot; //20
|
||
|
float LiquidFuel; //21
|
||
|
float OxidizerTot; //22
|
||
|
float Oxidizer; //23
|
||
|
float EChargeTot; //24
|
||
|
float ECharge; //25
|
||
|
float MonoPropTot; //26
|
||
|
float MonoProp; //27
|
||
|
float IntakeAirTot; //28
|
||
|
float IntakeAir; //29
|
||
|
float SolidFuelTot; //30
|
||
|
float SolidFuel; //31
|
||
|
float XenonGasTot; //32
|
||
|
float XenonGas; //33
|
||
|
float LiquidFuelTotS; //34
|
||
|
float LiquidFuelS; //35
|
||
|
float OxidizerTotS; //36
|
||
|
float OxidizerS; //37
|
||
|
uint32_t MissionTime; //38
|
||
|
float deltaTime; //39
|
||
|
float VOrbit; //40
|
||
|
uint32_t MNTime; //41
|
||
|
float MNDeltaV; //42
|
||
|
float Pitch; //43
|
||
|
float Roll; //44
|
||
|
float Heading; //45
|
||
|
uint16_t ActionGroups; //46 status bit order:SAS, RCS, Light, Gear, Brakes, Abort, Custom01 - 10
|
||
|
uint8_t SOINumber; //47 SOI Number (decimal format: sun-planet-moon e.g. 130 = kerbin, 131 = mun)
|
||
|
uint8_t MaxOverHeat; //48 Max part overheat (% percent)
|
||
|
float MachNumber; //49
|
||
|
float IAS; //50 Indicated Air Speed
|
||
|
uint8_t CurrentStage; //51 Current stage number
|
||
|
uint8_t TotalStage; //52 TotalNumber of stages
|
||
|
float TargetDist; //53 Distance to targeted vessel (m)
|
||
|
float TargetV; //54 Target vessel relative velocity (m/s)
|
||
|
uint8_t NavballSASMode; //55 Combined byte for navball target mode and SAS mode
|
||
|
// First four bits indicate AutoPilot mode:
|
||
|
// 0 SAS is off //1 = Regular Stability Assist //2 = Prograde
|
||
|
// 3 = RetroGrade //4 = Normal //5 = Antinormal //6 = Radial In
|
||
|
// 7 = Radial Out //8 = Target //9 = Anti-Target //10 = Maneuver node
|
||
|
// Last 4 bits set navball mode. (0=ignore,1=ORBIT,2=SURFACE,3=TARGET)
|
||
|
} vesselData_t;
|
||
|
|
||
|
typedef struct __attribute__((packed)) handShakePacket {
|
||
|
uint8_t id;
|
||
|
uint8_t M1;
|
||
|
uint8_t M2;
|
||
|
uint8_t M3;
|
||
|
} handShakePacket_t;
|
||
|
|
||
|
typedef struct __attribute__((packed)) controlPacket {
|
||
|
uint8_t id;
|
||
|
uint8_t MainControls; // SAS RCS Lights Gear Brakes Precision Abort Stage
|
||
|
uint8_t Mode; // 0 = stage, 1 = docking, 2 = map
|
||
|
uint16_t ControlGroup; // control groups 1-10 in 2 bytes
|
||
|
uint8_t NavBallSASMode; // other stuff
|
||
|
uint8_t AdditionalControlByte1;
|
||
|
int16_t Pitch; // -1000 -> 1000
|
||
|
int16_t Roll; // -1000 -> 1000
|
||
|
int16_t Yaw; // -1000 -> 1000
|
||
|
int16_t TX; // -1000 -> 1000
|
||
|
int16_t TY; // -1000 -> 1000
|
||
|
int16_t TZ; // -1000 -> 1000
|
||
|
int16_t WheelSteer; // -1000 -> 1000
|
||
|
int16_t Throttle; // 0 -> 1000
|
||
|
int16_t WheelThrottle; // 0 -> 1000
|
||
|
} controlPacket_t;
|
||
|
|
||
|
|
||
|
extern vesselData_t *cur_vdata;
|
||
|
void ksp_serial_send(const void *data, uint8_t len);
|
||
|
|
||
|
#endif
|