• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WindhoverLabs / yamcs_gdl90 / #36

26 Nov 2024 07:34PM UTC coverage: 0.0%. Remained the same
#36

push

web-flow
Merge 4e5c4b89e into 2cc1ae215

0 of 972 new or added lines in 7 files covered. (0.0%)

20 existing lines in 4 files now uncovered.

0 of 2375 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/windhoverlabs/yamcs/gdl90/WHL_AHRS.java
1
/****************************************************************************
2
 *
3
 *   Copyright (c) 2024 Windhover Labs, L.L.C. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * 1. Redistributions of source code must retain the above copyright
10
 *    notice, this list of conditions and the following disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 *    notice, this list of conditions and the following disclaimer in
13
 *    the documentation and/or other materials provided with the
14
 *    distribution.
15
 * 3. Neither the name Windhover Labs nor the names of its
16
 *    contributors may be used to endorse or promote products derived
17
 *    from this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
 * POSSIBILITY OF SUCH DAMAGE.
31
 *
32
 *****************************************************************************/
33

34
package com.windhoverlabs.yamcs.gdl90;
35

36
import java.io.ByteArrayOutputStream;
37
import java.nio.ByteBuffer;
38
import java.nio.ByteOrder;
39

40
/**
41
 * As per the spec:
42
 * https://www.faa.gov/sites/faa.gov/files/air_traffic/technology/adsb/archival/GDL90_Public_ICD_RevA.PDF
43
 * Pg 18
44
 *
45
 * <p>This message is an extension of the GDL90 protocol by Windhover Labs
46
 */
NEW
47
public class WHL_AHRS {
×
48

NEW
49
  byte FlagByte = 0x7E;
×
50
  public static final byte MessageID = 0x66;
51
  public static final byte AHRSSubMessageID = 0x00;
52
  public double Roll;
53
  public double Pitch;
54
  public double Heading;
55

56
  public double Lat;
57
  public double Lon;
58
  public double Alt;
59

60
  public double northVel;
61
  public double eastVel;
62
  public double downVel;
63

64
  public byte[] toBytes() throws Exception {
65

NEW
66
    ByteArrayOutputStream messageStream = new ByteArrayOutputStream();
×
67

NEW
68
    messageStream.write(MessageID);
×
NEW
69
    messageStream.write(AHRSSubMessageID);
×
70

NEW
71
    byte[] packedRollBytes =
×
NEW
72
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(Roll).array();
×
NEW
73
    messageStream.write(packedRollBytes[0]);
×
NEW
74
    messageStream.write(packedRollBytes[1]);
×
NEW
75
    messageStream.write(packedRollBytes[2]);
×
NEW
76
    messageStream.write(packedRollBytes[3]);
×
NEW
77
    messageStream.write(packedRollBytes[4]);
×
NEW
78
    messageStream.write(packedRollBytes[5]);
×
NEW
79
    messageStream.write(packedRollBytes[6]);
×
NEW
80
    messageStream.write(packedRollBytes[7]);
×
81

NEW
82
    byte[] packedPitchBytes =
×
NEW
83
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(Pitch).array();
×
NEW
84
    messageStream.write(packedPitchBytes[0]);
×
NEW
85
    messageStream.write(packedPitchBytes[1]);
×
NEW
86
    messageStream.write(packedPitchBytes[2]);
×
NEW
87
    messageStream.write(packedPitchBytes[3]);
×
NEW
88
    messageStream.write(packedPitchBytes[4]);
×
NEW
89
    messageStream.write(packedPitchBytes[5]);
×
NEW
90
    messageStream.write(packedPitchBytes[6]);
×
NEW
91
    messageStream.write(packedPitchBytes[7]);
×
92

93
    //    Heading = -80;
NEW
94
    double packedHeading = WHL_PackWHLHeading(Heading);
×
95

96
    //    0x01C2 = 450
97
    //    int packedHeading = packDegrees(45);
98

NEW
99
    byte[] packedHeadingBytes =
×
NEW
100
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(packedHeading).array();
×
NEW
101
    messageStream.write(packedHeadingBytes[0]);
×
NEW
102
    messageStream.write(packedHeadingBytes[1]);
×
NEW
103
    messageStream.write(packedHeadingBytes[2]);
×
NEW
104
    messageStream.write(packedHeadingBytes[3]);
×
NEW
105
    messageStream.write(packedHeadingBytes[4]);
×
NEW
106
    messageStream.write(packedHeadingBytes[5]);
×
NEW
107
    messageStream.write(packedHeadingBytes[6]);
×
NEW
108
    messageStream.write(packedHeadingBytes[7]);
×
109

NEW
110
    byte[] packedLatBytes =
×
NEW
111
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(Lat).array();
×
NEW
112
    messageStream.write(packedLatBytes[0]);
×
NEW
113
    messageStream.write(packedLatBytes[1]);
×
NEW
114
    messageStream.write(packedLatBytes[2]);
×
NEW
115
    messageStream.write(packedLatBytes[3]);
×
NEW
116
    messageStream.write(packedLatBytes[4]);
×
NEW
117
    messageStream.write(packedLatBytes[5]);
×
NEW
118
    messageStream.write(packedLatBytes[6]);
×
NEW
119
    messageStream.write(packedLatBytes[7]);
×
120

NEW
121
    byte[] packedLonBytes =
×
NEW
122
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(Lon).array();
×
NEW
123
    messageStream.write(packedLonBytes[0]);
×
NEW
124
    messageStream.write(packedLonBytes[1]);
×
NEW
125
    messageStream.write(packedLonBytes[2]);
×
NEW
126
    messageStream.write(packedLonBytes[3]);
×
NEW
127
    messageStream.write(packedLonBytes[4]);
×
NEW
128
    messageStream.write(packedLonBytes[5]);
×
NEW
129
    messageStream.write(packedLonBytes[6]);
×
NEW
130
    messageStream.write(packedLonBytes[7]);
×
131

NEW
132
    byte[] packedAltBytes =
×
NEW
133
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(Alt).array();
×
NEW
134
    messageStream.write(packedAltBytes[0]);
×
NEW
135
    messageStream.write(packedAltBytes[1]);
×
NEW
136
    messageStream.write(packedAltBytes[2]);
×
NEW
137
    messageStream.write(packedAltBytes[3]);
×
NEW
138
    messageStream.write(packedAltBytes[4]);
×
NEW
139
    messageStream.write(packedAltBytes[5]);
×
NEW
140
    messageStream.write(packedAltBytes[6]);
×
NEW
141
    messageStream.write(packedAltBytes[7]);
×
142

NEW
143
    byte[] NorthtBytes =
×
NEW
144
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(northVel).array();
×
NEW
145
    messageStream.write(NorthtBytes[0]);
×
NEW
146
    messageStream.write(NorthtBytes[1]);
×
NEW
147
    messageStream.write(NorthtBytes[2]);
×
NEW
148
    messageStream.write(NorthtBytes[3]);
×
NEW
149
    messageStream.write(NorthtBytes[4]);
×
NEW
150
    messageStream.write(NorthtBytes[5]);
×
NEW
151
    messageStream.write(NorthtBytes[6]);
×
NEW
152
    messageStream.write(NorthtBytes[7]);
×
153

NEW
154
    byte[] EastBytes =
×
NEW
155
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(eastVel).array();
×
NEW
156
    messageStream.write(EastBytes[0]);
×
NEW
157
    messageStream.write(EastBytes[1]);
×
NEW
158
    messageStream.write(EastBytes[2]);
×
NEW
159
    messageStream.write(EastBytes[3]);
×
NEW
160
    messageStream.write(EastBytes[4]);
×
NEW
161
    messageStream.write(EastBytes[5]);
×
NEW
162
    messageStream.write(EastBytes[6]);
×
NEW
163
    messageStream.write(EastBytes[7]);
×
164

NEW
165
    byte[] DownBytes =
×
NEW
166
        ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putDouble(downVel).array();
×
NEW
167
    messageStream.write(DownBytes[0]);
×
NEW
168
    messageStream.write(DownBytes[1]);
×
NEW
169
    messageStream.write(DownBytes[2]);
×
NEW
170
    messageStream.write(DownBytes[3]);
×
NEW
171
    messageStream.write(DownBytes[4]);
×
NEW
172
    messageStream.write(DownBytes[5]);
×
NEW
173
    messageStream.write(DownBytes[6]);
×
NEW
174
    messageStream.write(DownBytes[7]);
×
175

NEW
176
    byte[] crcData = messageStream.toByteArray();
×
NEW
177
    int crc = CrcTable.crcCompute(crcData, 0, crcData.length);
×
178
    //
179
    // Go through message data and escape characters as per the spec
180
    // ....
181
    //
182

NEW
183
    byte[] crcBytes = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(crc).array();
×
NEW
184
    messageStream.write(crcBytes[3]);
×
NEW
185
    messageStream.write(crcBytes[2]);
×
186

NEW
187
    ByteArrayOutputStream messageStreamOut =
×
NEW
188
        OwnshipGeoAltitude.escapeBytes(messageStream.toByteArray());
×
189

NEW
190
    ByteBuffer bbOut = ByteBuffer.allocate(messageStreamOut.toByteArray().length + 2).put(FlagByte);
×
191

NEW
192
    bbOut.put(messageStreamOut.toByteArray());
×
193

NEW
194
    bbOut.put(FlagByte);
×
195

NEW
196
    byte[] dataOut = bbOut.array();
×
197

NEW
198
    messageStream.toByteArray();
×
199

NEW
200
    return dataOut;
×
201
  }
202

203
  public double WHL_PackWHLHeading(double heading) {
204

205
    // Connvert heading of [-180, 180] to [0,360]
NEW
206
    double PackedHeading = heading;
×
NEW
207
    if (heading < 0) {
×
NEW
208
      PackedHeading = 360 + heading;
×
209
    } else {
NEW
210
      PackedHeading = heading;
×
211
    }
NEW
212
    return (PackedHeading);
×
213
  }
214
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc