00001 /* 00002 * Copyright (c) 2010, Bosch LLC 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of Bosch LLC nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 //\Author Joerg Wagner, Bosch LLC 00031 00032 #ifndef SKINDRIVER_H_ 00033 #define SKINDRIVER_H_ 00034 00035 #include <stdint.h> 00036 #include <libsub.h>//sub20_driver 00037 00038 #include <skin_driver/skin_serv.h>//service 00039 00040 //dynamic reconfigure 00041 #include <dynamic_reconfigure/server.h> 00042 #include <skin_driver/MyStuffConfig.h> 00043 00044 00046 namespace skinc_def { 00047 //Define I2C communication parameters 00049 const int I2CAdr= 1; 00050 const int I2C_Mem_Adr = 2; 00051 00052 //Define Skin Hardware parameters 00054 const uint8_t readadr_hi = 1; 00056 const uint8_t readadr_lo = 0; 00057 00058 //address of log files 00060 const uint8_t readadr_log_hi = 0x00; 00062 const uint8_t readadr_log_lo = 0xC1; 00063 00064 //Default values 00066 const uint8_t stat_thres_default = 10; 00067 00068 //constants 00070 const int max_sensor_number = 192; 00072 const int anz_byte_per_sensor = 8; 00074 const int I2C_communication_frequency = 100000; 00075 const int write_one_byte = 1; 00077 const int end_of_chain_marker = 254; 00078 } 00079 00081 struct SKINMEAS { 00083 bool bMeasAvailable; 00085 uint64_t sensor_data[skinc_def::max_sensor_number]; 00087 uint8_t dyn_thres_cv; 00089 uint8_t status; 00090 }; 00091 00093 00100 class Skin { 00101 public: 00103 00110 Skin(); 00111 00113 ~Skin(); 00114 00116 //Methodes: 00118 00120 00135 SKINMEAS GetOneMeas(void); 00136 00138 00143 bool conf_int_challback(skin_driver::skin_serv::Request& req, skin_driver::skin_serv::Response& res); 00144 00146 void dyn_rec_callback(skin_driver::MyStuffConfig &config, uint32_t level); 00147 00149 //Variables 00151 00153 int isensor_number_; 00155 bool binit_skin_ok_; 00156 00157 private: 00159 //Methodes: 00161 00163 00176 bool write2ram(uint8_t* start_adr, uint8_t steps, uint8_t number_of_bytes, uint8_t write_data, bool sens_num_change); 00177 00179 00186 void convert_data_2_uint64_array(char* inp_buf_data, uint64_t* outp_sen_data); 00187 00189 //Variables for 00190 //Xdimax Sub20-Device 00192 00194 sub_handle fd_; 00195 sub_device subdev_; 00197 bool bSubDeviceOpen_; 00199 bool bSubDeviceConfigured_; 00201 bool bI2CDeviceFound_; 00203 bool bsub20found_; 00205 std::string strSerial_; 00206 00207 };//class 00208 00209 00210 00211 #endif /* SKINDRIVER_H_ */