File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed
Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ namespace Plane
8282 vertrate = VERTRATE_UNDEFINED;
8383 squawk = SQUAWK_UNDEFINED;
8484 alert = emergency = spi = onground = BoolType::UNKNOWN;
85- callsign[8 ] = ' \0 ' ;
85+ callsign[0 ] = ' \0 ' ;
8686 }
8787
8888 // Getters
@@ -117,12 +117,19 @@ namespace Plane
117117 void setGroundSpeed (FLOAT32 gs) { groundspeed = gs; }
118118 void setTrack (FLOAT32 t) { track = t; }
119119 void setVertRate (int vr) { vertrate = vr; }
120- void setCallsign (const std::string &c)
121- {
122- for (int i = 0 ; i < 8 ; i++)
123- {
124- if (i < c.size () && c[i] != ' \0 ' && c[i] != ' @' )
120+
121+ void setCallsign (const std::string &c) {
122+ callsign[0 ] = ' \0 ' ;
123+ size_t end = c.length ();
124+ while (end > 0 && c[end-1 ] == ' ' ) {
125+ end--;
126+ }
127+
128+ for (int i = 0 ; i < 8 ; i++) {
129+ if (i < end && c[i] != ' \0 ' && c[i] != ' @' && c[i] >= 32 && c[i] <= 126 )
130+ {
125131 callsign[i] = c[i];
132+ }
126133 else {
127134 callsign[i] = ' \0 ' ;
128135 break ;
Original file line number Diff line number Diff line change @@ -74,7 +74,10 @@ class Basestation : public SimpleStreamInOut<RAW, Plane::ADSB>
7474 // HexIdent (Field 4)
7575 if (!fields[4 ].empty ())
7676 {
77- msg.setHexIdent (std::stoul (fields[4 ], nullptr , 16 ));
77+ if (fields[4 ][0 ] == ' ~' )
78+ msg.setHexIdent (std::stoul (fields[4 ].substr (1 ), nullptr , 16 ));
79+ else
80+ msg.setHexIdent (std::stoul (fields[4 ], nullptr , 16 ));
7881 }
7982
8083 // Timestamps (Fields 7-10)
@@ -90,6 +93,7 @@ class Basestation : public SimpleStreamInOut<RAW, Plane::ADSB>
9093 msg.setCallsign (fields[10 ]);
9194 }
9295
96+
9397 // Altitude (Field 11)
9498 if (fields.size () > 11 && !fields[11 ].empty ())
9599 {
@@ -147,6 +151,7 @@ class Basestation : public SimpleStreamInOut<RAW, Plane::ADSB>
147151 }
148152
149153 // msg.Print();
154+
150155 Send (&msg, 1 , tag);
151156 }
152157
@@ -163,7 +168,12 @@ class Basestation : public SimpleStreamInOut<RAW, Plane::ADSB>
163168 {
164169 if (line.length () > 0 )
165170 {
171+ try {
166172 processLine ();
173+ } catch (const std::exception &e) {
174+ std::cerr << " Error processing line: " << line << " " << e.what () << std::endl;
175+
176+ }
167177 line.clear ();
168178 }
169179 }
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ class PlaneDB : public StreamIn<Plane::ADSB>
111111 if (msg->getSquawk () != SQUAWK_UNDEFINED) {
112112 plane.setSquawk (msg->getSquawk ());
113113 }
114- if (msg->getCallsign () != " @@@@@@@@ " ) {
114+ if (! msg->getCallsign (). empty () ) {
115115 plane.setCallsign (msg->getCallsign ());
116116 }
117117
@@ -169,7 +169,7 @@ class PlaneDB : public StreamIn<Plane::ADSB>
169169 (plane.getTrack () != TRACK_UNDEFINED ? std::to_string (plane.getTrack ()) : null_str) + comma +
170170 (plane.getVertRate () != VERTRATE_UNDEFINED ? std::to_string (plane.getVertRate ()) : null_str) + comma +
171171 (plane.getSquawk () != SQUAWK_UNDEFINED ? std::to_string (plane.getSquawk ()) : null_str) + comma +
172- plane.getCallsign () + comma +
172+ + " \" " + plane.getCallsign () + " \" " + comma +
173173 (plane.getAlert () != Plane::BoolType::UNKNOWN ? std::to_string (static_cast <int >(plane.getAlert ())) : null_str) + comma +
174174 (plane.getEmergency () != Plane::BoolType::UNKNOWN ? std::to_string (static_cast <int >(plane.getEmergency ())) : null_str) + comma +
175175 (plane.getSPI () != Plane::BoolType::UNKNOWN ? std::to_string (static_cast <int >(plane.getSPI ())) : null_str) + comma +
You can’t perform that action at this time.
0 commit comments