2023-09-15 20:44:17 +02:00
|
|
|
from pycsdr.modules import ExecModule
|
2023-08-22 19:59:00 +02:00
|
|
|
from pycsdr.types import Format
|
2023-09-15 20:44:17 +02:00
|
|
|
from csdr.module import LineBasedModule
|
2023-08-22 19:59:00 +02:00
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Dump1090Module(ExecModule):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super().__init__(
|
|
|
|
|
Format.COMPLEX_SHORT,
|
|
|
|
|
Format.CHAR,
|
2023-09-15 20:44:17 +02:00
|
|
|
["dump1090", "--ifile", "-", "--iformat", "SC16", "--raw"],
|
2023-08-24 19:04:45 +02:00
|
|
|
# send some data on decoder shutdown since the dump1090 internal reader locks up otherwise
|
|
|
|
|
# dump1090 reads chunks of 100ms, which equals to 240k samples at 2.4MS/s
|
|
|
|
|
# some extra should not hurt
|
|
|
|
|
flushSize=300000
|
2023-08-22 19:59:00 +02:00
|
|
|
)
|
2023-08-22 21:16:38 +02:00
|
|
|
|
|
|
|
|
|
2023-08-29 01:56:27 +02:00
|
|
|
class RawDeframer(LineBasedModule):
|
|
|
|
|
def process(self, line: bytes):
|
2023-08-22 21:16:38 +02:00
|
|
|
if line.startswith(b'*') and line.endswith(b';') and len(line) in [16, 30]:
|
|
|
|
|
return bytes.fromhex(line[1:-1].decode())
|
2023-08-30 18:18:38 +02:00
|
|
|
elif line == b"*0000;":
|
|
|
|
|
# heartbeat message. not a valid message, but known. do not log.
|
|
|
|
|
return
|
2023-08-22 21:16:38 +02:00
|
|
|
else:
|
|
|
|
|
logger.warning("invalid raw message: %s", line)
|