openskynetwork / java-adsb

Mode S and ADS-B decoding library for Java
GNU General Public License v3.0
103 stars 41 forks source link

Fails to decode some EHS message #17

Closed yanghsu closed 7 years ago

yanghsu commented 7 years ago

There is a message makes the example decoder crash.

$ java -cp libadsb-2.1.jar org.opensky.example.ExampleDecoder 
1,abd30f589bc61c
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
    at org.opensky.libadsb.msgs.CommBIdentifyReply.<init>(CommBIdentifyReply.java:73)
    at org.opensky.libadsb.Decoder.genericDecoder(Decoder.java:108)
    at org.opensky.example.ExampleDecoder.decodeMsg(ExampleDecoder.java:78)
    at org.opensky.example.ExampleDecoder.main(ExampleDecoder.java:284)

message is “abd30f589bc61c”

What's wrong with this message or the decoder?

mablae commented 7 years ago

I will try to debug it with the python decoder wich is a bit more solid.

yanghsu commented 7 years ago

I have reviewed the python decoder. It seems an EHS message should be 28 byte hex chars. I am not sure about it.

affitz commented 7 years ago

The reason for this error was that the raw message you fed into the receiver has downlink format 21 and a length of 7 bytes. DF 21 is supposed to have a length of 14 bytes according to the standards. The decoder now behaves like this:

java -cp libadsb-2.1.jar org.opensky.example.ExampleDecoder 1,abd30f589bc61c Malformed message! Skipping it. Message: Message 'abd30f589bc61c' has an illegal format: Downlink format 21 suggests length 14 byte but input has length 7

Fixed in 765b65c