kopia lustrzana https://github.com/glidernet/python-ogn-client
Added Support for FANET beacons
rodzic
a8a83e960b
commit
12bdf25243
|
@ -1,6 +1,6 @@
|
|||
# CHANGELOG
|
||||
## Unreleased
|
||||
- parser: Added support for OGNLT24 (LT24), OGSKYL (Skylines), OGSPID (Spider) and OGSPOT (Spot)
|
||||
- parser: Added support for OGNLT24 (LT24), OGSKYL (Skylines), OGSPID (Spider), OGSPOT (Spot) and OGNFNT (Fanet)
|
||||
- parser: Added support for (server) comments
|
||||
|
||||
## 0.8.2: - 2018-01-20
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import re
|
||||
|
||||
from ogn.parser.utils import fpm2ms
|
||||
from ogn.parser.pattern import PATTERN_FANET_POSITION_COMMENT
|
||||
|
||||
from .base import BaseParser
|
||||
|
||||
|
||||
class FanetParser(BaseParser):
|
||||
def __init__(self):
|
||||
self.beacon_type = 'fanet'
|
||||
|
||||
@staticmethod
|
||||
def parse_position(aprs_comment):
|
||||
ac_match = re.search(PATTERN_FANET_POSITION_COMMENT, aprs_comment)
|
||||
return {'id': ac_match.group('id') if ac_match.group('id') else None,
|
||||
'climb_rate': int(ac_match.group('climb_rate')) * fpm2ms if ac_match.group('climb_rate') else None}
|
|
@ -6,6 +6,7 @@ from ogn.parser.pattern import PATTERN_APRS, PATTERN_APRS_POSITION, PATTERN_APRS
|
|||
from ogn.parser.exceptions import AprsParseError, OgnParseError
|
||||
|
||||
from ogn.parser.aprs_comment.ogn_parser import OgnParser
|
||||
from ogn.parser.aprs_comment.fanet_parser import FanetParser
|
||||
from ogn.parser.aprs_comment.lt24_parser import LT24Parser
|
||||
from ogn.parser.aprs_comment.naviter_parser import NaviterParser
|
||||
from ogn.parser.aprs_comment.flarm_parser import FlarmParser
|
||||
|
@ -81,6 +82,7 @@ def parse_aprs(message, reference_date, reference_time=None):
|
|||
|
||||
|
||||
dstcall_parser_mapping = {'APRS': OgnParser(),
|
||||
'OGNFNT': FanetParser(),
|
||||
'OGFLR': FlarmParser(),
|
||||
'OGNTRK': TrackerParser(),
|
||||
'OGNSDR': ReceiverParser(),
|
||||
|
|
|
@ -5,6 +5,11 @@ PATTERN_APRS_POSITION = re.compile(r"^(?P<time>(([0-1]\d|2[0-3])[0-5]\d[0-5]\dh|
|
|||
PATTERN_APRS_STATUS = re.compile(r"^(?P<time>(([0-1]\d|2[0-3])[0-5]\d[0-5]\dh|([0-2]\d|3[0-1])([0-1]\d|2[0-3])[0-5]\dz))\s(?P<comment>.*)$")
|
||||
PATTERN_APRS_SERVER = re.compile(r"^# aprsc (?P<version>[a-z0-9\.\-]+) (?P<timestamp>\d+ [A-Za-z]+ \d+ \d{2}:\d{2}:\d{2} GMT) (?P<server>[A-Z0-9]+) (?P<ip_address>\d+\.\d+\.\d+\.\d+):(?P<port>\d+)$")
|
||||
|
||||
PATTERN_FANET_POSITION_COMMENT = re.compile("""
|
||||
(?:id(?P<id>[\dA-F]+)\s)?
|
||||
(?:(?P<climb_rate>[+-]\d+)fpm)?
|
||||
""", re.VERBOSE | re.MULTILINE)
|
||||
|
||||
PATTERN_LT24_POSITION_COMMENT = re.compile("""
|
||||
id(?P<id>\d+)\s
|
||||
(?P<climb_rate>[+-]\d+)fpm\s
|
||||
|
|
|
@ -27,6 +27,9 @@ class TestStringMethods(unittest.TestCase):
|
|||
def test_aprs_receiver_beacons(self):
|
||||
self.parse_valid_beacon_data_file(filename='aprs_receiver.txt', beacon_type='receiver')
|
||||
|
||||
def test_aprs_fanet_beacons(self):
|
||||
self.parse_valid_beacon_data_file(filename='fanet.txt', beacon_type='fanet')
|
||||
|
||||
def test_ogn_flarm_beacons(self):
|
||||
self.parse_valid_beacon_data_file(filename='ogn_flarm.txt', beacon_type='flarm')
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import unittest
|
||||
|
||||
from ogn.parser.utils import ms2fpm
|
||||
from ogn.parser.aprs_comment.fanet_parser import FanetParser
|
||||
|
||||
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
def test_regular_beacon(self):
|
||||
message = FanetParser.parse_position("id1E1103CE -02fpm")
|
||||
|
||||
self.assertEqual(message['id'], "1E1103CE")
|
||||
self.assertAlmostEqual(message['climb_rate'] * ms2fpm, -2, 0.1)
|
||||
|
||||
def test_pseudo_status_beacon(self):
|
||||
message = FanetParser.parse_position("")
|
||||
|
||||
self.assertIsNone(message['id'])
|
||||
self.assertIsNone(message['climb_rate'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,8 @@
|
|||
# With OGN software 0.2.7 receivers have the dstcall "OGNFNT"
|
||||
#
|
||||
FNT1103CE>OGNFNT,qAS,FNB1103CE:/183727h5057.94N/00801.00Eg355/002/A=001042 !W10! id1E1103CE +03fpm
|
||||
FNT1103CE>OGNFNT,qAS,FNB1103CE:/183729h5057.94N/00801.00Eg354/001/A=001042 !W10! id1E1103CE +07fpm
|
||||
FNT1103CE>OGNFNT,qAS,FNB1103CE:/183731h5057.94N/00801.00Eg354/001/A=001042 !W10! id1E1103CE +05fpm
|
||||
FNT1103CE>OGNFNT,qAS,FNB1103CE:/183734h5057.94N/00801.00Eg354/001/A=001042 !W30! id1E1103CE -10fpm
|
||||
FNT1103CE>OGNFNT,qAS,FNB1103CE:/183736h5057.94N/00801.00Eg354/001/A=001042 !W40! id1E1103CE -02fpm
|
||||
FNB1103CE>OGNFNT,TCPIP*,qAC,GLIDERN3:/183738h5057.95NI00801.00E&/A=001042
|
Ładowanie…
Reference in New Issue