mirror of
				https://github.com/NotAShelf/air-quality-monitor.git
				synced 2025-10-31 03:02:38 +00:00 
			
		
		
		
	handle serial port unavailable
This commit is contained in:
		
					parent
					
						
							
								a22882a169
							
						
					
				
			
			
				commit
				
					
						5c7691ba6b
					
				
			
		
					 1 changed files with 6 additions and 1 deletions
				
			
		|  | @ -17,6 +17,11 @@ class AirQualityMonitor: | |||
|     SERIAL_DEVICE = os.environ.get("SERIAL_DEVICE", "/dev/ttyUSB0") | ||||
| 
 | ||||
|     def __init__(self): | ||||
|         # if path does not exist, error and exit | ||||
|         if not os.path.exists(self.SERIAL_DEVICE): | ||||
|             raise RuntimeError(f"Serial device {self.SERIAL_DEVICE} not found.") | ||||
|         else: | ||||
|             print(f"Serial device {self.SERIAL_DEVICE} found.") | ||||
|             self.ser = serial.Serial(self.SERIAL_DEVICE) | ||||
| 
 | ||||
|     def get_measurement(self): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue