Schnittstellenverwaltung für u.a NMEA0183 verbessert
This commit is contained in:
		
							parent
							
								
									b06d88d0ec
								
							
						
					
					
						commit
						aefd01e0f9
					
				|  | @ -11,6 +11,14 @@ mouseptr = on | |||
| win_x = -1 | ||||
| win_y = -1 | ||||
| 
 | ||||
| [can] | ||||
| enabled = false | ||||
| interface = can0 | ||||
| 
 | ||||
| [nmea0183] | ||||
| enabled = false | ||||
| port = /dev/ttyV1 | ||||
| 
 | ||||
| [bme280] | ||||
| enabled = false | ||||
| port = 1 | ||||
|  | @ -21,7 +29,6 @@ enabled = false | |||
| port = /dev/ttyACM0 | ||||
| 
 | ||||
| [opencpn] | ||||
| port = /dev/ttyV1 | ||||
| navobj = ~/.opencpn/navobj.xml | ||||
| config = ~/.opencpn/opencpn.conf | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										35
									
								
								obp60v.py
								
								
								
								
							
							
						
						
									
										35
									
								
								obp60v.py
								
								
								
								
							|  | @ -8,6 +8,9 @@ Zwei Displayvarianten | |||
|   2. Fullscreen Display skaliert mit 1,6 ergibt 640x480 | ||||
|      mit Platz für große Touch-Flächen am rechten Rand | ||||
| 
 | ||||
| Das Gerät kann Daten von NMEA2000 und NMEA0183 empfangen, sowie von | ||||
| einem lokal angeschlossenen GPS-Empfänger. | ||||
| 
 | ||||
| NMEA2000 | ||||
|   deviceclass: 120 - Display | ||||
|   devicefunction: 130 - Display | ||||
|  | @ -120,9 +123,9 @@ cfg = { | |||
|     'bme280': False | ||||
| } | ||||
| 
 | ||||
| def rxd_n2k(): | ||||
| def rxd_n2k(device): | ||||
|     setthreadtitle("N2Klistener") | ||||
|     bus = can.Bus(interface='socketcan', channel='can0', bitrate=250000); | ||||
|     bus = can.Bus(interface='socketcan', channel=device, bitrate=250000); | ||||
|     wip = False | ||||
|     sc = 0 | ||||
|     nf = 0 | ||||
|  | @ -196,7 +199,7 @@ def rxd_0183(devname): | |||
|     try: | ||||
|         ser = serial.Serial(devname, 115200, timeout=3) | ||||
|     except serial.SerialException as e: | ||||
|         print("OpenCPN serial port not available") | ||||
|         print("NMEA0183 serial port not available") | ||||
|         return | ||||
|     setthreadtitle("0183listener") | ||||
|     while not shutdown: | ||||
|  | @ -218,6 +221,8 @@ def rxd_0183(devname): | |||
|         elif msg.sentence_type == 'RTE': | ||||
|             # Route | ||||
|             print(msg.fields) | ||||
|         else: | ||||
|             print(msg) | ||||
|     ser.close() | ||||
| 
 | ||||
| def datareader(histpath, history): | ||||
|  | @ -625,6 +630,14 @@ if __name__ == "__main__": | |||
|         cfg['win_x'] = -1 | ||||
|         cfg['win_y'] = -1 | ||||
| 
 | ||||
|     cfg['can'] = config.getboolean('can', 'enabled') | ||||
|     if cfg['can']: | ||||
|         cfg['can_intf'] = config.get('can', 'interface') | ||||
| 
 | ||||
|     cfg['nmea0183'] = config.getboolean('nmea0183', 'enabled') | ||||
|     if cfg['nmea0183']: | ||||
|         cfg['0183_port'] = config.get('nmea0183', 'port') | ||||
| 
 | ||||
|     cfg['gps'] = config.getboolean('gps', 'enabled') | ||||
|     if cfg['gps']: | ||||
|         cfg['gps_port'] = config.get('gps', 'port') | ||||
|  | @ -638,27 +651,29 @@ if __name__ == "__main__": | |||
|         history = History("press", 75) | ||||
|         boatdata.addHistory(history, "press") | ||||
| 
 | ||||
|     cfg['ocpn_port'] = config.get('opencpn', 'port') | ||||
| 
 | ||||
|     if cfg['simulation']: | ||||
|         boatdata.enableSimulation() | ||||
| 
 | ||||
|     profile = init_profile(config, cfg, boatdata) | ||||
| 
 | ||||
|     if not cfg['simulation']: | ||||
|         t_rxd_n2k = threading.Thread(target=rxd_n2k) | ||||
|     # Schnittstellen aktivieren | ||||
|     if cfg['can']: | ||||
|         t_rxd_n2k = threading.Thread(target=rxd_n2k, args=(cfg['can_intf'],)) | ||||
|         t_rxd_n2k.start() | ||||
|         t_rxd_0183 = threading.Thread(target=rxd_0183, args=(cfg['ocpn_port'],)) | ||||
|     if cfg['nmea0183']: | ||||
|         t_rxd_0183 = threading.Thread(target=rxd_0183, args=(cfg['0183_port'],)) | ||||
|         t_rxd_0183.start() | ||||
| 
 | ||||
|     if not cfg['simulation']: | ||||
|         t_data = threading.Thread(target=datareader, args=(cfg['histpath'], history)) | ||||
|         t_data.start() | ||||
| 
 | ||||
|     app = Frontend(cfg, owndevice, boatdata, profile) | ||||
|     app.run() | ||||
|     shutdown = True | ||||
|     if not cfg['simulation']: | ||||
|     if cfg['can']: | ||||
|         t_rxd_n2k.join() | ||||
|     if cfg['nmea0183']: | ||||
|         t_rxd_0183.join() | ||||
|     if not cfg['simulation']: | ||||
|         t_data.join() | ||||
|     print("Another fine product of the Sirius Cybernetics Corporation.") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue