updates to handler

This commit is contained in:
Magnus Lundmark
2019-01-18 17:44:19 +01:00
parent fb4cef7085
commit 1795d2f3c0
2 changed files with 74 additions and 54 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ def np2bin(npbin):
def df(msg): def df(msg):
"""Decode Downlink Format vaule, bits 1 to 5.""" """Decode Downlink Format vaule, bits 1 to 5."""
msgbin = hex2bin(msg) msgbin = hex2bin(msg)
return bin2int(msgbin[0:5]) return min( bin2int(msgbin[0:5]) , 24 )
def crc(msg, encode=False): def crc(msg, encode=False):
+62 -42
View File
@@ -146,64 +146,84 @@ class BaseClient(Thread):
def read_skysense_buffer(self): def read_skysense_buffer(self):
""" """
----------------------------------------------------------------------------------
---------------------------------------------------------------------------------- Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS
Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS ----------------------------------------------------------------------------------
---------------------------------------------------------------------------------- Position: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Position: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ----------------------------------------------------------------------------------
---------------------------------------------------------------------------------- Example: 24 8d 4c a5 c0 20 24 22 f1 28 38 20 f3 24 04 be 8d 0d d8 e0 80 66 ed b9
Example: 24 8d 4c a5 c0 20 24 22 f1 28 38 20 f3 24 04 be 8d 0d d8 e0 80 66 ed b9 Example: 24 5d 3c 48 c8 ad 3d f9 00 00 00 00 00 00 00 be 8d 66 c4 c5 7c 4c d7 2d
Example: 24 5d 3c 48 c8 ad 3d f9 00 00 00 00 00 00 00 be 8d 66 c4 c5 7c 4c d7 2d
SS field - Start character SS field - Start character
Position 0: Position 0:
1 byte = 8 bits 1 byte = 8 bits
Start character '$' Start character '$'
MS field - Payload MS field - Payload
Postion 1 through 14: Postion 1 through 14:
14 bytes = 112 bits 14 bytes = 112 bits
Mode-S payload Mode-S payload
In case of DF types that only carry 7 bytes of information position 8 through 14 are set to 0x00. In case of DF types that only carry 7 bytes of information position 8 through 14 are set to 0x00.
Decoding of payload information is not within the scope of this document. Decoding of payload information is not within the scope of this document.
TS field - Time stamp TS field - Time stamp
Position 15 through 20: Position 15 through 20:
6 bytes = 48 bits 6 bytes = 48 bits
Time stamp with fields as: Time stamp with fields as:
Lock Status - Status of internal time keeping mechanism Lock Status - Status of internal time keeping mechanism
Equal to 1 if operating normally Equal to 1 if operating normally
Bit 47 - 1 bit Bit 47 - 1 bit
Time of day in UTC seconds, between 0 and 86399 Time of day in UTC seconds, between 0 and 86399
Bits 46 through 30 - 17 bits Bits 46 through 30 - 17 bits
Nanoseconds into current second, between 0 and 999999999 Nanoseconds into current second, between 0 and 999999999
Bits 29 through 0 - 30 bits Bits 29 through 0 - 30 bits
RS field - Signal Level RS field - Signal Level
Position 21 through 23: Position 21 through 23:
3 bytes = 24 bits 3 bytes = 24 bits
RSSI (received signal strength indication) and relative noise level with fields RSSI (received signal strength indication) and relative noise level with fields
RNL, Q12.4 unsigned fixed point binary with 4 fractional bits and 8 integer bits. RNL, Q12.4 unsigned fixed point binary with 4 fractional bits and 8 integer bits.
This is and indication of the noise level of the message. Roughly 40 counts per 10dBm. This is and indication of the noise level of the message. Roughly 40 counts per 10dBm.
Bits 23 through 12 - 12 bits Bits 23 through 12 - 12 bits
RSSI, Q12.4 unsigned fixed point binary with 4 fractional bits and 8 integer bits. RSSI, Q12.4 unsigned fixed point binary with 4 fractional bits and 8 integer bits.
This is an indication of the signal level of the received message in ADC counts. Roughly 40 counts per 10dBm. This is an indication of the signal level of the received message in ADC counts. Roughly 40 counts per 10dBm.
Bits 11 through 0 - 12 bits Bits 11 through 0 - 12 bits
"""
""" SS_MSGLENGTH = 24
SS_STARTCHAR = 0x24
messages = [] messages = []
msg = [] msg = []
i = 0 i = 0
while i < len(self.buffer): while i < len(self.buffer):
if self.buffer[i] == 0x24: if self.buffer[i] == SS_STARTCHAR:
i += 1
if (self.buffer[i]>>7):
#Long message
payload = self.buffer[i:i+14]
else:
#Short message
payload = self.buffer[i:i+7]
msg = ''.join('%02X' % i for i in payload)
i += 14
tsbin = self.buffer[i:i+6]
sec = (tsbin[0] << 10) | (tsbin[1] << 2) | (tsbin[2] >> 6)
nano = (tsbin[2] << 24) | (tsbin[3] << 16) | (tsbin[4] << 8) | tsbin[5]
ts = sec + nano*1.0e-9
i += 6
#Signal level - Don't care
i += 3
messages.append( [msg,ts] )