Some buf fixes and small enhancements
This commit is contained in:
		
							parent
							
								
									be20826ab5
								
							
						
					
					
						commit
						7d8ce221fd
					
				
							
								
								
									
										97
									
								
								nmea0183.py
								
								
								
								
							
							
						
						
									
										97
									
								
								nmea0183.py
								
								
								
								
							|  | @ -2,7 +2,8 @@ | ||||||
| NMEA0183 verarbeiten | NMEA0183 verarbeiten | ||||||
| 
 | 
 | ||||||
| TODO Multi-Sentence verarbeiten | TODO Multi-Sentence verarbeiten | ||||||
|   TXT |   TXT Textmeldungen (Alarm) | ||||||
|  |   RTE Routendaten | ||||||
|   AIS-Sentences mit Binärdaten |   AIS-Sentences mit Binärdaten | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
|  | @ -33,7 +34,7 @@ NMEA0183: Parse-Error: !AIVDM,1,1,,A,H3ti3hPpDhiT0    """ | ||||||
|     print(msg.fields) |     print(msg.fields) | ||||||
|     print(msg.data) |     print(msg.data) | ||||||
|     #boatdata.setValue("LAT", msg.latitude) |     #boatdata.setValue("LAT", msg.latitude) | ||||||
|      | 
 | ||||||
| def GGA(boatdata, msg): | def GGA(boatdata, msg): | ||||||
|     # Time, position, and fix related data |     # Time, position, and fix related data | ||||||
|     # msg.num_sats |     # msg.num_sats | ||||||
|  | @ -160,7 +161,33 @@ def RMB(boatdata, msg): | ||||||
|     # Recommended Minimum Navigation Information |     # Recommended Minimum Navigation Information | ||||||
|     # Informationen bzgl. Erreichen des nächsten Wegepunkts |     # Informationen bzgl. Erreichen des nächsten Wegepunkts | ||||||
|     # |     # | ||||||
|  |     # (('Status', 'status'), | ||||||
|  |     # ('Cross Track Error', 'cross_track_error'), | ||||||
|  |     #('Cross Track Error, direction to corrent', 'cte_correction_dir'), | ||||||
|  |     #('Origin Waypoint ID', 'origin_waypoint_id'), | ||||||
|  |     # ('Destination Waypoint ID', 'dest_waypoint_id'), | ||||||
|  |     #('Destination Waypoint Latitude', 'dest_lat'), | ||||||
|  |     #('Destination Waypoint Lat Direction', 'dest_lat_dir'), | ||||||
|  |     # ('Destination Waypoint Longitude', 'dest_lon'), | ||||||
|  |     #('Destination Waypoint Lon Direction', 'dest_lon_dir'), | ||||||
|  |     #('Range to Destination', 'dest_range'), | ||||||
|  |     #('True Bearing to Destination', 'dest_true_bearing'), | ||||||
|  |     #('Velocity Towards Destination', 'dest_velocity'), | ||||||
|  |     #('Arrival Alarm', 'arrival_alarm')) | ||||||
|     print("-> RMB") |     print("-> RMB") | ||||||
|  |     if not msg.status == 'A': | ||||||
|  |         return | ||||||
|  |     lat_fac = 1 if msg.dest_lat_dir == 'N' else -1 | ||||||
|  |     lat_deg = int(msg.dest_lat[0:2]) | ||||||
|  |     lat_min = float(msg.dest_lat[2:]) | ||||||
|  |     lon_fac = 1 if msg.dest_lon_dir == 'E' else -1 | ||||||
|  |     lon_deg = int(msg.dest_lon[0:3]) | ||||||
|  |     lon_min = float(msg.dest_lon[3:]) | ||||||
|  |     boatdata.setValue("WPLat", lat_fac * lat_deg + lat_min / 60) | ||||||
|  |     boatdata.setValue("WPLon", lon_fac * lon_deg + lon_min / 60) | ||||||
|  |     boatdata.setValue("WPname", msg.dest_waypoint_id) | ||||||
|  |     boatdata.setValue("DTW", float(msg.dest_range)) | ||||||
|  |     boatdata.setValue("BTW", float(msg.dest_true_bearing)) | ||||||
| 
 | 
 | ||||||
| def RMC(boatdata, msg): | def RMC(boatdata, msg): | ||||||
|     # Recommended Minimum Navigation Information |     # Recommended Minimum Navigation Information | ||||||
|  | @ -200,10 +227,28 @@ def RSA(boatdata, msg): | ||||||
|     if msg.rsa_port_status == 'A': |     if msg.rsa_port_status == 'A': | ||||||
|         boatdata.setValue("PRPOS", msg.rsa_port) |         boatdata.setValue("PRPOS", msg.rsa_port) | ||||||
| 
 | 
 | ||||||
|  | rte_curr = 0 | ||||||
|  | rte_max = 0 | ||||||
|  | rte_wpl = [] | ||||||
|  | 
 | ||||||
| def RTE(boatdata, msg): | def RTE(boatdata, msg): | ||||||
|     # Route |     # Route: List of Waypoints | ||||||
|  |     # num_in_seq, sen_num, start_type, active_route_id | ||||||
|  |     global rte_curr, rte_max | ||||||
|  |     nmax = int(msg.sen_num) | ||||||
|  |     n = int(msg.num_in_seq) | ||||||
|  |     if nmax > 1: | ||||||
|  |         if rte_curr == 0 and n == 1: | ||||||
|  |             # neue Nachricht | ||||||
|  |             pass | ||||||
|  |         else: | ||||||
|  |             # Fortsetzung | ||||||
|  |             pass | ||||||
|  |     else: | ||||||
|  |         pass | ||||||
|     print("-> RTE") |     print("-> RTE") | ||||||
|     print(msg.fields) |     print(msg.fields) | ||||||
|  |     print(msg.waypoint_list) | ||||||
| 
 | 
 | ||||||
| txt_msg = '' | txt_msg = '' | ||||||
| txt_type = None | txt_type = None | ||||||
|  | @ -259,16 +304,17 @@ def VPW(boatdata, msg): | ||||||
| def VTG(boatdata, msg): | def VTG(boatdata, msg): | ||||||
|     # Track made good and speed over ground |     # Track made good and speed over ground | ||||||
|     """ |     """ | ||||||
| (('True Track made good', 'true_track', <class 'float'>),  | (('True Track made good', 'true_track', <class 'float'>), | ||||||
| ('True Track made good symbol', 'true_track_sym'),  | ('True Track made good symbol', 'true_track_sym'), | ||||||
| ('Magnetic Track made good', 'mag_track', <class 'decimal.Decimal'>), | ('Magnetic Track made good', 'mag_track', <class 'decimal.Decimal'>), | ||||||
|  ('Magnetic Track symbol', 'mag_track_sym'),  | ('Magnetic Track symbol', 'mag_track_sym'), | ||||||
|  ('Speed over ground knots', 'spd_over_grnd_kts', <class 'decimal.Decimal'>), | ('Speed over ground knots', 'spd_over_grnd_kts', <class 'decimal.Decimal'>), | ||||||
|   ('Speed over ground symbol', 'spd_over_grnd_kts_sym'), | ('Speed over ground symbol', 'spd_over_grnd_kts_sym'), | ||||||
|    ('Speed over ground kmph', 'spd_over_grnd_kmph', <class 'float'>), | ('Speed over ground kmph', 'spd_over_grnd_kmph', <class 'float'>), | ||||||
|     ('Speed over ground kmph symbol', 'spd_over_grnd_kmph_sym'),  | ('Speed over ground kmph symbol', 'spd_over_grnd_kmph_sym'), | ||||||
|     ('FAA mode indicator', 'faa_mode')) | ('FAA mode indicator', 'faa_mode')) | ||||||
| ['', 'T', '', 'M', '0.117', 'N', '0.216', 'K', 'A']    """ | ['', 'T', '', 'M', '0.117', 'N', '0.216', 'K', 'A'] | ||||||
|  |     """ | ||||||
|     print("-> VTG") |     print("-> VTG") | ||||||
|     # msg.true_track true_track_sym |     # msg.true_track true_track_sym | ||||||
|     # msg.mag_track mag_track_sym |     # msg.mag_track mag_track_sym | ||||||
|  | @ -290,15 +336,38 @@ def VWR(boatdata, msg): | ||||||
|     boatdata.setValue("AWS", msg.wind_speed_ms) |     boatdata.setValue("AWS", msg.wind_speed_ms) | ||||||
| 
 | 
 | ||||||
| def WPL(boatdata, msg): | def WPL(boatdata, msg): | ||||||
|  |     # Waypoint | ||||||
|  |     # lat, lat_dir | ||||||
|  |     # lon, lon_dir | ||||||
|  |     # waypoint_id (name) | ||||||
|     print("-> WPL") |     print("-> WPL") | ||||||
|     print(msg.fields) |     print(msg.fields) | ||||||
| 
 | 
 | ||||||
|  |     lat_fac = 1 if msg.lat_dir == 'N' else -1 | ||||||
|  |     lat_deg = int(msg.lat[0:2]) | ||||||
|  |     lat_min = float(msg.lat[2:]) | ||||||
|  |     #boatdata.setValue("LAT", lat_fac * lat_deg + lat_min / 60) | ||||||
|  |     lon_fac = 1 if msg.lon_dir == 'E' else -1 | ||||||
|  |     lon_deg = int(msg.lon[0:3]) | ||||||
|  |     lon_min = float(msg.lon[3:]) | ||||||
|  |     #boatdata.setValue("LON", lon_fac * lon_deg + lon_min / 60) | ||||||
|  | 
 | ||||||
|  |     # Prüfe, ob der Wegepunkt schon existiert | ||||||
|  |     if msg.waypoint_id in boatdata.wps: | ||||||
|  |         # Wegepunkt aktualisieren | ||||||
|  |         pass | ||||||
|  |     else: | ||||||
|  |         # neuen Wegepunkt anlegen | ||||||
|  |         # boatdata.wps[waypoint_id] | ||||||
|  |         pass | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def VWT(boatdata, msg): | def VWT(boatdata, msg): | ||||||
|     # True Wind Speed and Angle |     # True Wind Speed and Angle | ||||||
|     if msg.direction == "R": |     if msg.direction == "R": | ||||||
|         angle = msg.wind_angle_vessel |         angle = msg.wind_angle_vessel | ||||||
|     else: |     else: | ||||||
|         angle = 360 - msg.wind_angle_vessel  |         angle = 360 - msg.wind_angle_vessel | ||||||
|     boatdata.setValue("TWA", angle) |     boatdata.setValue("TWA", angle) | ||||||
|     boatdata.setValue("TWS", msg.wind_speed_meters) |     boatdata.setValue("TWS", msg.wind_speed_meters) | ||||||
| 
 | 
 | ||||||
|  | @ -377,6 +446,6 @@ decoder = { | ||||||
|     "XTE": XTE, |     "XTE": XTE, | ||||||
|     "XTR": XTR, |     "XTR": XTR, | ||||||
|     "ZDA": ZDA, |     "ZDA": ZDA, | ||||||
|      | 
 | ||||||
|     "VDM": VDM |     "VDM": VDM | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -27,5 +27,6 @@ class OneValue(Page): | ||||||
|         if self.ref1.value: |         if self.ref1.value: | ||||||
|             ctx.show_text(self.ref1.format()) |             ctx.show_text(self.ref1.format()) | ||||||
|         else: |         else: | ||||||
|             ctx.show_text(self.placeholder) |             #print(dir(self.bd)) | ||||||
|  |             ctx.show_text("---") # self.bd.getPlaceholder()) | ||||||
|         ctx.stroke() |         ctx.stroke() | ||||||
|  |  | ||||||
|  | @ -17,21 +17,21 @@ class SkyView(Page): | ||||||
|     def __init__(self, pageno, cfg, boatdata): |     def __init__(self, pageno, cfg, boatdata): | ||||||
|         super().__init__(pageno, cfg, boatdata) |         super().__init__(pageno, cfg, boatdata) | ||||||
| 
 | 
 | ||||||
|     def pol2cart(azimuth, elevation): |     def pol2cart(azimut, elevation): | ||||||
|         ''' |         ''' | ||||||
|         Polar to Cartesian coordinates within the horizon circle. |         Polar to Cartesian coordinates within the horizon circle. | ||||||
|         azimuth in radians |         azimuth in radians | ||||||
|         x = math.sin(azimuth) * elevation * self.radius |         x = math.sin(azimut) * elevation * self.radius | ||||||
|         y = math.cos(azimuth) * elevation * self.radius |         y = math.cos(azimut) * elevation * self.radius | ||||||
|         ''' |         ''' | ||||||
|         pass |         pass | ||||||
|         # (x, y) = self.pol2cart(sat.az, sat.el) |         # (x, y) = self.pol2cart(sat.az, sat.el) | ||||||
|          | 
 | ||||||
|     def draw(self, ctx): |     def draw(self, ctx): | ||||||
| 
 | 
 | ||||||
|         # Name |         # Name | ||||||
|         ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD) |         ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD) | ||||||
|         #ctx.set_font_size(32)  |         #ctx.set_font_size(32) | ||||||
|         #self.draw_text_center(ctx, 200, 40, "Satellite Info") |         #self.draw_text_center(ctx, 200, 40, "Satellite Info") | ||||||
| 
 | 
 | ||||||
|         # Spezialseite |         # Spezialseite | ||||||
|  | @ -70,7 +70,7 @@ class SkyView(Page): | ||||||
|             ctx.show_text(f"{s:02d}") |             ctx.show_text(f"{s:02d}") | ||||||
|             ctx.rectangle(305, y-12, 85, 14) |             ctx.rectangle(305, y-12, 85, 14) | ||||||
|             ctx.stroke() |             ctx.stroke() | ||||||
|              | 
 | ||||||
|         ctx.set_line_width(1.0) |         ctx.set_line_width(1.0) | ||||||
|         for s in self.bd.sat.values(): |         for s in self.bd.sat.values(): | ||||||
|             x = cx + math.sin(s.azimuth) * s.elevation * r |             x = cx + math.sin(s.azimuth) * s.elevation * r | ||||||
|  | @ -82,4 +82,4 @@ class SkyView(Page): | ||||||
| 
 | 
 | ||||||
|         # Satellitenliste mit SNR-Balken sortiert nach nummer |         # Satellitenliste mit SNR-Balken sortiert nach nummer | ||||||
|         for prn_num in sorted(self.bd.sat): |         for prn_num in sorted(self.bd.sat): | ||||||
|             print(prn_num)            |             print(prn_num) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue