diff --git a/pywsjtx/extra/latlong_to_grid_square.py b/pywsjtx/extra/latlong_to_grid_square.py index 8fbff8c..4cc482f 100644 --- a/pywsjtx/extra/latlong_to_grid_square.py +++ b/pywsjtx/extra/latlong_to_grid_square.py @@ -2,7 +2,7 @@ class GPSException(Exception): def __init__(self,*args): - Exception.__init__(*args) + super(GPSException, self).__init__(*args) # From K6WRU via stackexchange : see https://ham.stackexchange.com/questions/221/how-can-one-convert-from-lat-long-to-grid-square/244#244 # Convert latitude and longitude to Maidenhead grid locators. diff --git a/samples/dump_wsjtx_packets.py b/samples/dump_wsjtx_packets.py index 4feb0d5..ee53a9d 100644 --- a/samples/dump_wsjtx_packets.py +++ b/samples/dump_wsjtx_packets.py @@ -3,7 +3,13 @@ import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import pywsjtx.extra.simple_server -s = pywsjtx.extra.simple_server.SimpleServer('127.0.0.1','2237',timeout=2.0) +#IP_ADDRESS = '224.1.1.1' +#PORT = 5007 + +IP_ADDRESS = '127.0.0.1' +PORT = 2237 + +s = pywsjtx.extra.simple_server.SimpleServer(IP_ADDRESS, PORT, timeout=2.0) while True: diff --git a/samples/grid_from_gps.py b/samples/grid_from_gps.py index 41ebb3d..3a856fb 100644 --- a/samples/grid_from_gps.py +++ b/samples/grid_from_gps.py @@ -44,7 +44,7 @@ class NMEALocation(object): else: self.valid = False - if self.grid != grid: + if grid != "" and self.grid != grid: logging.debug("NMEALocation - grid mismatch old: {} new: {}".format(self.grid,grid)) self.grid = grid if (self.grid_changed_callback): @@ -93,9 +93,12 @@ class SerialGPS(object): # dispatch the line # note that bytes are used for readline, vs strings after the decode to utf-8 if line.startswith(b'$'): - str_line = line.decode("utf-8") - for p in self.line_handlers: - p(str_line) + try: + str_line = line.decode("utf-8") + for p in self.line_handlers: + p(str_line) + except UnicodeDecodeError as ex: + logging.debug("serial_worker: {} - line: {}".format(ex,[hex(c) for c in line])) @classmethod def example_line_handler(cls, text): @@ -143,7 +146,7 @@ while True: if gps_grid != "" and the_packet.de_grid != gps_grid: print("Sending Grid Change to wsjtx-x, old grid:{} new grid: {}".format(the_packet.de_grid, gps_grid)) grid_change_packet = pywsjtx.LocationChangePacket.Builder(wsjtx_id, "GRID:"+gps_grid) - print(pywsjtx.PacketUtil.hexdump(grid_change_packet)) + logging.debug(pywsjtx.PacketUtil.hexdump(grid_change_packet)) s.send_packet(the_packet.addr_port, grid_change_packet) # for fun, change the TX5 message to our grid square, so we don't have to call CQ again # this only works if the length of the free text message is less than 13 characters.