Skip to content

Commit

Permalink
#1 Moved SatInfo to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
arnegue committed Mar 17, 2024
1 parent e00c289 commit 6be33cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions seatalk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
from seatalk.s53_course_over_ground import CourseOverGround
from seatalk.s54_gmt_time import GMT_Time
from seatalk.s56_date import Date
from seatalk.s57_sat_info import SatInfo
23 changes: 23 additions & 0 deletions seatalk/s57_sat_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from seatalk.seatalk_datagram import SeatalkDatagram


class SatInfo(SeatalkDatagram):
"""
57 S0 DD Sat Info: S number of sats, DD horiz. dilution of position, if S=1 -> DD=0x94
Corresponding NMEA sentences: GGA, GSA
"""
seatalk_id = 0x57
data_length = 0

def __init__(self, amount_satellites=None, horizontal_dilution=None):
SeatalkDatagram.__init__(self)
self.amount_satellites = amount_satellites
self.horizontal_dilution = horizontal_dilution

def process_datagram(self, first_half_byte, data):
self.amount_satellites = first_half_byte
self.horizontal_dilution = data[0]

def get_seatalk_datagram(self):
first_byte = (self.amount_satellites << 4) | self.data_length
return bytearray([self.seatalk_id, first_byte, self.horizontal_dilution])
21 changes: 0 additions & 21 deletions seatalk/seatalk_datagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,27 +345,6 @@ def __init__(self, increment_decrement=0, key=None):
_KeyStroke.__init__(self, increment_decrement=increment_decrement, key=key)


class SatInfo(SeatalkDatagram):
"""
57 S0 DD Sat Info: S number of sats, DD horiz. dilution of position, if S=1 -> DD=0x94
Corresponding NMEA sentences: GGA, GSA
"""
seatalk_id = 0x57
data_length = 0

def __init__(self, amount_satellites=None, horizontal_dilution=None):
SeatalkDatagram.__init__(self)
self.amount_satellites = amount_satellites
self.horizontal_dilution = horizontal_dilution

def process_datagram(self, first_half_byte, data):
self.amount_satellites = first_half_byte
self.horizontal_dilution = data[0]

def get_seatalk_datagram(self):
first_byte = (self.amount_satellites << 4) | self.data_length
return bytearray([self.seatalk_id, first_byte, self.horizontal_dilution])


class PositionDatagram(SeatalkDatagram):
"""
Expand Down

0 comments on commit 6be33cc

Please sign in to comment.