sensord: rm light sensor (#29503)
	
		
	
				
					
				
			
							parent
							
								
									3eef63af9b
								
							
						
					
					
						commit
						f5071411cb
					
				
				 7 changed files with 6 additions and 95 deletions
			
			
		| @ -1,17 +0,0 @@ | ||||
| #include "file_sensor.h" | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| FileSensor::FileSensor(std::string filename) : file(filename) {} | ||||
| 
 | ||||
| int FileSensor::init() { | ||||
|   return file.is_open() ? 0 : 1; | ||||
| } | ||||
| 
 | ||||
| FileSensor::~FileSensor() { | ||||
|   file.close(); | ||||
| } | ||||
| 
 | ||||
| bool FileSensor::has_interrupt_enabled() { | ||||
|   return false; | ||||
| } | ||||
| @ -1,19 +0,0 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| #include <fstream> | ||||
| #include <string> | ||||
| 
 | ||||
| #include "cereal/gen/cpp/log.capnp.h" | ||||
| #include "system/sensord/sensors/sensor.h" | ||||
| 
 | ||||
| class FileSensor : public Sensor { | ||||
| protected: | ||||
|   std::ifstream file; | ||||
| 
 | ||||
| public: | ||||
|   FileSensor(std::string filename); | ||||
|   ~FileSensor(); | ||||
|   int init(); | ||||
|   bool has_interrupt_enabled(); | ||||
|   virtual bool get_event(MessageBuilder &msg, uint64_t ts = 0) = 0; | ||||
| }; | ||||
| @ -1,27 +0,0 @@ | ||||
| #include "light_sensor.h" | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| #include "common/timing.h" | ||||
| #include "system/sensord/sensors/constants.h" | ||||
| 
 | ||||
| LightSensor::LightSensor(std::string filename) : FileSensor(filename) {} | ||||
| 
 | ||||
| bool LightSensor::get_event(MessageBuilder &msg, uint64_t ts) { | ||||
|   uint64_t start_time = nanos_since_boot(); | ||||
|   file.clear(); | ||||
|   file.seekg(0); | ||||
| 
 | ||||
|   int value; | ||||
|   file >> value; | ||||
| 
 | ||||
|   auto event = msg.initEvent().initLightSensor(); | ||||
|   event.setSource(cereal::SensorEventData::SensorSource::RPR0521); | ||||
|   event.setVersion(1); | ||||
|   event.setSensor(SENSOR_LIGHT); | ||||
|   event.setType(SENSOR_TYPE_LIGHT); | ||||
|   event.setTimestamp(start_time); | ||||
|   event.setLight(value); | ||||
| 
 | ||||
|   return true; | ||||
| } | ||||
| @ -1,9 +0,0 @@ | ||||
| #pragma once | ||||
| #include "file_sensor.h" | ||||
| 
 | ||||
| class LightSensor : public FileSensor { | ||||
| public: | ||||
|   LightSensor(std::string filename); | ||||
|   bool get_event(MessageBuilder &msg, uint64_t ts = 0); | ||||
|   int shutdown() { return 0; } | ||||
| }; | ||||
					Loading…
					
					
				
		Reference in new issue