// Comm-B messages count for a large portion of the Mode S selective interrogation responses.(means, only transmitted information upon selective request)
// Comm-B messages protocol supports many different types of msg's (up to 255).The three more popular ones are the following ones:
// (a) Mode S ELementary Surveillance (ELS) / (b) Mode S EnHanced Surveillance (EHS) / (c) Meteorological information
// Comm-B Data Selector (BDS) is an 8-bit code that determines which information to be included in the MB fields
// 32 31 30 29 28 27 26 25 24 23 22 21 20 (it was wrong , now corrected) bit order inside frame msg
// D4 B4 D2 B2 D1 B1 __ A4 C4 A2 C2 A1 C1 standard spec order of the 13 bits, to be sent , each octal digit = 3 bits , (example A=7 binary A4 A2 A0 = 111
// ABCD = code (octal, 0000~7777)
// FEDCBA9876543210
// xAAAxBBBxCCCxDDD
// x421x421x421x421
squawk_coded=((squawk<<10)&0x1000)|// D4
((squawk<<1)&0x0800)|// B4
((squawk<<9)&0x0400)|// D2
((squawk<<0)&0x0200)|// B2
((squawk<<8)&0x0100)|// D1
((squawk>>1)&0x0080)|// B1
((squawk>>9)&0x0020)|// A4
((squawk>>2)&0x0010)|// C4
((squawk>>10)&0x0008)|// A2
((squawk>>3)&0x0004)|// C2
((squawk>>11)&0x0002)|// A1
((squawk>>4)&0x0001);// C1
frame.push_byte(squawk_coded>>5);
frame.push_byte(squawk_coded<<3);
// FEDCBA9876543210
// xAAAxBBBxCCCxDDD 4 x 3 bits (each octal digit)
// x421x421x421x421 binary weight of each binary position, example AAA = 7 = 111 -------------------------
// 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 bit position of the frame msg, (Squawk id is bit 20-32, from C1..D4).
// UM4 UM2 UM1 C1 A1 C2 A2 C4 A4 X B1 D1 B2 D2 B4 D4 3 lower bit UM4,UM2,UM1 of the UM (6bits), and we should re-order the 13 bits ABCD changing 12 bit poistion based on std.
// 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Two bytes , bit position to be send.
squawk_coded=(((UM_field&(0b111))<<13)|((squawk<<9)&0x1000))|// C1 It also leaves in the top 3 lower bottom bitd part of UM field.
((squawk<<2)&0x0800)|// A1
((squawk<<6)&0x0400)|// C2
((squawk>>1)&0x0200)|// A2
((squawk<<3)&0x0100)|// C4
((squawk>>4)&0x0080)|// A4
((squawk>>1)&0x0020)|// B1
((squawk<<4)&0x0010)|// D1
((squawk>>4)&0x0008)|// B2
((squawk<<1)&0x0004)|// D2
((squawk>>7)&0x0002)|// B4
((squawk>>2)&0x0001);// D4
frame.push_byte(squawk_coded>>8);// UM4 UM2 UM1 C1 A1 C2 A2 C4 that is the correct order, confirmed with dump1090
frame.push_byte(squawk_coded);// A4 X(1) B1 D1 B2 D2 B4 D4 that is the correct order, confirmed with dupm1090
// DF 21 messages , has 56 bits more after 13 bits of squawk, we should add MB (56 bits)
// In this example, we are adding fixed MB = Track and turn report (BDS 5,0) decoding MB example = "F9363D3BBF9CE9" (56 bits)
// # -9.7, roll angle (deg)
// # 140.273, track angle (deg)
// # -0.406, track angle rate (deg/s)
// # 476, ground speed (kt)
// # 466, TAS (kt)
frame.push_byte(0xF9);frame.push_byte(0x36);frame.push_byte(0x3D);frame.push_byte(0x3B);// If we deltele those two lines, to send this fixed MB (56 bits),
frame.push_byte(0xBF);frame.push_byte(0x9C);frame.push_byte(0xE9);// current fw is padding with 56 x 0's to complete 112 bits msg.
frame.make_CRC();
}
}
floatcpr_mod(floata,floatb){
returna-(b*floor(a/b));
@@ -183,6 +225,13 @@ float cpr_Dlon(float lat, int is_odd) {
return360.0/cpr_N(lat,is_odd);
}
// An ADS-B frame Civil aircraft message type starts with Dowlink Format (DF=17) and frame is 112 bits long.
// All known DF's >=16 are long (112 bits). All known DF's <=15 are short (56 bits). (In this case 112 bits)
// Msg structure consists of five main parts :|DF=17 (5 bits)|CA (3 bits)|ICAO (24 bits)|ME (56 bits)|CRC (24 bits)
// TC : (1..4) : Aircraft identification Type Code. // TC : 9 to 18: Airbone postion and altitude // TC : 19 Airbone velocity .
// Airborne position message is used to broadcast the position and altitude of the aircraft. It has the Type Code 9–18 and 20–22. (here , we use TC=11)
// Airborne velocities are all transmitted with Type Code 19 ( TC=19, using 5 bits ,TC=19 [Binary: 10011]), the following 3 bits are Subt-type Code ,SC= 1,2,3,4
// SC Subtypes code 1 and 2 are used to report ground speeds of aircraft. (SC 3,4 to used to report true airspeed. SC 2,4 are for supersonic aircraft (not used in commercial airline).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.