mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-29 22:24:48 +03:00 
			
		
		
		
	max44000: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
		 Jon Trulson
					Jon Trulson
				
			
				
					committed by
					
						 Mihai Tudor Panu
						Mihai Tudor Panu
					
				
			
			
				
	
			
			
			 Mihai Tudor Panu
						Mihai Tudor Panu
					
				
			
						parent
						
							d0d89b579d
						
					
				
				
					commit
					ab20e34c59
				
			| @@ -23,6 +23,8 @@ | ||||
|  */ | ||||
|  | ||||
| #include <iostream> | ||||
| #include <string> | ||||
| #include <stdexcept> | ||||
| #include <unistd.h> | ||||
| #include <stdlib.h> | ||||
|  | ||||
| @@ -36,9 +38,17 @@ MAX44000::MAX44000 (int bus, int devAddr) : m_i2cMaxControlCtx(bus) { | ||||
|     m_maxControlAddr = devAddr; | ||||
|     m_bus = bus; | ||||
|  | ||||
|     if ( !(m_i2cMaxControlCtx = mraa_i2c_init(m_bus)) )  | ||||
|       { | ||||
|         throw std::invalid_argument(std::string(__FUNCTION__) + | ||||
|                                     ": mraa_i2c_init() failed"); | ||||
|         return; | ||||
|       } | ||||
|  | ||||
|     mraa::Result ret = m_i2cMaxControlCtx.address(m_maxControlAddr); | ||||
|     if (ret != mraa::SUCCESS) { | ||||
|         fprintf(stderr, "Messed up i2c bus\n"); | ||||
|         throw std::invalid_argument(std::string(__FUNCTION__) + | ||||
|                                     ": mraa_i2c_address() failed"); | ||||
|     } | ||||
|  | ||||
|     // i2cWriteReg (MCR, 0x2C); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user