pyModeS.common module

pyModeS.common.allzeros(msg)[source]

Check if the data bits are all zeros.

Parameters

msg (String) – 28 bytes hexadecimal message string

Returns

True or False

Return type

bool

pyModeS.common.altcode(msg)[source]

Compute the altitude.

Applicable only for DF4 or DF20 message, bit 20-32. credit: @fbyrkjeland

Parameters

msg (String) – 28 bytes hexadecimal message string

Returns

altitude in ft

Return type

int

pyModeS.common.bin2int(binstr)[source]

Convert a binary string to integer.

pyModeS.common.cprNL(lat)[source]

NL() function in CPR decoding.

pyModeS.common.crc(msg, encode=False)[source]

Mode-S Cyclic Redundancy Check.

Detect if bit error occurs in the Mode-S message. When encode option is on, the checksum is generated.

Parameters
  • msg (string) – 28 bytes hexadecimal message string

  • encode (bool) – True to encode the date only and return the checksum

Returns

message checksum, or partity bits (encoder)

Return type

int

pyModeS.common.crc_legacy(msg, encode=False)[source]

Mode-S Cyclic Redundancy Check. (Legacy code, 2x slow).

pyModeS.common.data(msg)[source]

Return the data frame in the message, bytes 9 to 22.

pyModeS.common.df(msg)[source]

Decode Downlink Format value, bits 1 to 5.

pyModeS.common.floor(x)[source]

Mode-S floor function.

Defined as the greatest integer value k, such that k <= x For example: floor(3.6) = 3 and floor(-3.6) = -4

pyModeS.common.gray2alt(codestr)[source]
pyModeS.common.gray2int(graystr)[source]

Convert greycode to binary.

pyModeS.common.hex2bin(hexstr)[source]

Convert a hexdecimal string to binary string, with zero fillings.

pyModeS.common.hex2int(hexstr)[source]

Convert a hexdecimal string to integer.

pyModeS.common.icao(msg)[source]

Calculate the ICAO address from an Mode-S message.

Applicable only with DF4, DF5, DF20, DF21 messages.

Parameters

msg (String) – 28 bytes hexadecimal message string

Returns

ICAO address in 6 bytes hexadecimal string

Return type

String

pyModeS.common.idcode(msg)[source]

Compute identity (squawk code).

Applicable only for DF5 or DF21 messages, bit 20-32. credit: @fbyrkjeland

Parameters

msg (String) – 28 bytes hexadecimal message string

Returns

squawk code

Return type

string

pyModeS.common.is_icao_assigned(icao)[source]

Check whether the ICAO address is assigned (Annex 10, Vol 3).

pyModeS.common.typecode(msg)[source]

Type code of ADS-B message

Parameters

msg (string) – 28 bytes hexadecimal message string

Returns

type code number

Return type

int

pyModeS.common.wrongstatus(data, sb, msb, lsb)[source]

Check if the status bit and field bits are consistency.

This Function is used for checking BDS code versions.