Skip to content

Commit aa4365b

Browse files
committed
add ac mode
1 parent 4270587 commit aa4365b

File tree

6 files changed

+54
-22
lines changed

6 files changed

+54
-22
lines changed

ac_decoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int ac_decoder::get_ac_type(unsigned short modeac )
9696
dvalue==7)
9797
)
9898
{
99-
unsigned int counted =get_mode_count_stat(a_mode_stat , modeac);
99+
int counted =get_mode_count_stat(a_mode_stat , modeac);
100100
inc_mode_stat(a_mode_stat,modeac);
101101
if(counted ==-1 || counted >MIN_AC_COUNT)
102102
{
@@ -108,7 +108,7 @@ int ac_decoder::get_ac_type(unsigned short modeac )
108108
}
109109
}
110110

111-
unsigned int counted =get_mode_count_stat(na_mode_stat ,modeac);
111+
int counted =get_mode_count_stat(na_mode_stat ,modeac);
112112
if(counted >MIN_AC_COUNT)
113113
{
114114
int altitude = AC_INVALID_ALTITUDE ;

mlat/client/coordinator.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ def update_aircraft(self, now):
149149
ac = self.aircraft.get(icao)
150150
if not ac:
151151
ac = Aircraft(icao)
152-
ac.requested = (icao in self.requested_traffic)
152+
153+
if(icao>0xFF0000):
154+
ac.requested = (icao in self.requested_modeac)
155+
else:
156+
ac.requested = (icao in self.requested_traffic)
157+
153158
ac.rate_measurement_start = now
154159
self.aircraft[icao] = ac
155160

@@ -432,6 +437,22 @@ def received_df17(self, message, now):
432437
self.server.send_sync(ac.even_message, ac.odd_message)
433438

434439
def received_modeac(self, message, now):
440+
#AC Mode
441+
ac = self.aircraft.get(message.address)
442+
if not ac:
443+
ac = Aircraft(message.address)
444+
ac.requested = (message.address in self.requested_modeac)
445+
ac.messages += 1
446+
ac.last_message_time = now
447+
ac.rate_measurement_start = now
448+
self.aircraft[message.address] = ac
449+
return # wait for more messages
450+
451+
ac.messages += 1
452+
ac.last_message_time = now
453+
if ac.messages < 10:
454+
return
455+
435456
if message.address not in self.requested_modeac:
436457
return
437458

mlat/client/jsonclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from mlat.client.util import log, monotonic_time
3737
from mlat.client.stats import global_stats
3838

39-
DEBUG = False
39+
DEBUG = True
4040

4141
# UDP protocol submessages
4242

modes_message.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -386,22 +386,23 @@ static int decode(modesmessage *self)
386386
Py_CLEAR(self->altitude);
387387

388388
if (self->datalen == 2) {
389-
390-
unsigned char ac[2] ;
391-
memcpy(ac , self->data , 2);
392-
393-
ac_decode_result_t ac_ret = ac_decode(ac) ;
394-
if(ac_ret.type == AC_MODE_A)
395-
{
396-
self->df = DF_MODEAC;
397-
int ac_fix_icao = 0x00FF0000 | ac_ret.squawk ;
398-
self->address = PyLong_FromLong(ac_fix_icao) ;
399-
self->valid = 1;
400-
printf("A Mode:%06X\r\n" ,self->address );
401-
return 0;
402-
}
403-
else
404-
return -1;
389+
//AC Message decode , A Mode Start With 0xFFXXXX
390+
391+
unsigned char ac[2] ;
392+
memcpy(ac , self->data , 2);
393+
394+
ac_decode_result_t ac_ret = ac_decode(ac) ;
395+
if(ac_ret.type == AC_MODE_A)
396+
{
397+
self->df = DF_MODEAC;
398+
int ac_fix_icao = 0x00FF0000 | ac_ret.squawk ;
399+
self->address = PyLong_FromLong(ac_fix_icao) ;
400+
self->valid = 1;
401+
printf("A Mode:%06X\r\n" ,ac_fix_icao);
402+
return 0;
403+
}
404+
else
405+
return -1;
405406
}
406407

407408
self->df = (self->data[0] >> 3) & 31;

modes_reader.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,11 +1384,20 @@ static int filter_message(modesreader *self, PyObject *o)
13841384
modesmessage *message = (modesmessage *)o;
13851385

13861386
if (message->df == DF_MODEAC) {
1387+
if (self->seen != NULL && self->seen != Py_None)
1388+
{
1389+
if (PySet_Add(self->seen, message->address) < 0) {
1390+
printf("DF_MODEAC PySet_Add Failed!\r\n") ;
1391+
1392+
return -1;
1393+
}
1394+
}
1395+
1396+
13871397
if (self->modeac_filter != NULL && self->modeac_filter != Py_None) {
13881398
return PySequence_Contains(self->modeac_filter, message->address);
13891399
}
1390-
1391-
return 1;
1400+
return 0;
13921401
}
13931402

13941403
if (!message->valid) {

nogps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mlat-client --input-type sbs --input-connect 10.1.1.172:10001 --server 127.0.0.1:12590 --lon 121.429367 --lat 37.525049 --alt 35 --user SHDL

0 commit comments

Comments
 (0)