An interface which establishes the communication between the GUIs and the ECU of the sensor skin. More...
#include <skin_driver.h>
Public Member Functions | |
bool | conf_int_challback (skin_driver::skin_serv::Request &req, skin_driver::skin_serv::Response &res) |
Configuration interface callback. | |
void | dyn_rec_callback (skin_driver::MyStuffConfig &config, uint32_t level) |
Dynamic reconfigure challback. | |
SKINMEAS | GetOneMeas (void) |
Read one SKINMEAS measurement. | |
Skin () | |
A constructor to initialize values and to establish the connection with the sensor skin. | |
~Skin () | |
A destructor to reset values and to close the opened sub20 device. | |
Public Attributes | |
bool | binit_skin_ok_ |
Skin is successfully initialized. | |
int | isensor_number_ |
Number of sensor elements connected to the ECU of the sensor skin. | |
Private Member Functions | |
void | convert_data_2_uint64_array (char *inp_buf_data, uint64_t *outp_sen_data) |
Converts a char array into an uint64_t array. | |
bool | write2ram (uint8_t *start_adr, uint8_t steps, uint8_t number_of_bytes, uint8_t write_data, bool sens_num_change) |
Write the provided data into the RAM of the sensor skin. | |
Private Attributes | |
bool | bI2CDeviceFound_ |
Verify if I2C device exists. | |
bool | bsub20found_ |
Verify if sub20 device with connection to skin exists. | |
bool | bSubDeviceConfigured_ |
Verify if subdevice is configured. | |
bool | bSubDeviceOpen_ |
Verify if subdevice is opened. | |
sub_handle | fd_ |
Handle for subdevice. | |
std::string | strSerial_ |
Serial number of SUB20 device. | |
sub_device | subdev_ |
An interface which establishes the communication between the GUIs and the ECU of the sensor skin.
The class Skin handles the communication with the sensor skin and the GUIs.
It reads the sensor values as well as the log files from the sensor skin and publishes them on the topic "skin_data". Apart from that the class also writes data in the ECU of the skin when a service request is send.
Definition at line 100 of file skin_driver.h.
Skin::Skin | ( | ) |
A constructor to initialize values and to establish the connection with the sensor skin.
The constructor of the class "Skin" scans all connected USB devices and looks for a SUB20 device with connection to a sensor skin. If a SUB20 device with a connection to a sensor skin is found the number of connected sensor elements will be determine. To determin the number of sensor elements the constructor reads the value "Limit" of each sensor element until the end of chain marker (Limit == 254) is found. This marker is an indicator for the first unused sensor element address.
Definition at line 54 of file skin_driver.cpp.
Skin::~Skin | ( | ) |
A destructor to reset values and to close the opened sub20 device.
Definition at line 250 of file skin_driver.cpp.
bool Skin::conf_int_challback | ( | skin_driver::skin_serv::Request & | req, | |
skin_driver::skin_serv::Response & | res | |||
) |
Configuration interface callback.
This function calls the function "write2ram".
Definition at line 466 of file skin_driver.cpp.
void Skin::convert_data_2_uint64_array | ( | char * | inp_buf_data, | |
uint64_t * | outp_sen_data | |||
) | [private] |
Converts a char array into an uint64_t array.
The function "convert_data_2_uint64_array" receives a char array of size 1536 and returns an uint64 array of size 192.
inp_buf_data | Received char array | |
outp_sen_data | Returned uint64 array |
Definition at line 357 of file skin_driver.cpp.
void Skin::dyn_rec_callback | ( | skin_driver::MyStuffConfig & | config, | |
uint32_t | level | |||
) |
Dynamic reconfigure challback.
Definition at line 433 of file skin_driver.cpp.
SKINMEAS Skin::GetOneMeas | ( | void | ) |
Read one SKINMEAS measurement.
The function "GetOneMeas" reads the data of the connected sensor elements as well as the log files from the RAM of the sensor skin.
To read data from the RAM of the sensor skin a special communication pattern has to be used.
Communication pattern: 1.) Memory address write Start|Slave Adr. (Bit1-7) + Bit0 = 0|Mem. Addr. MSB|Mem. Addr. LSB|Stop
2.) Wait for 50ms
3.) Data read Start|Slave Adr. (Bit1-7) + Bit0 = 1|Data[0]|Data[1]|... |Stop
Definition at line 262 of file skin_driver.cpp.
bool Skin::write2ram | ( | uint8_t * | start_adr, | |
uint8_t | steps, | |||
uint8_t | number_of_bytes, | |||
uint8_t | write_data, | |||
bool | sens_num_change | |||
) | [private] |
Write the provided data into the RAM of the sensor skin.
"write2ram" writes in a loop the value "write_data" in the memory address "start_adr" and increments the memory address "start_adr" by "steps". This loop is repeated "number_of_bytes" times. If the flag "sens_num_change" is true and "write_data" equals 254 the function also deletes the old end of chain marker and updates the number of sensor elements.
start_adr | Memory address of first byte in which the function writes a value | |
steps | The function will increment the address "start_adr" (a copy of "start_adr") by "steps" after one "write to RAM" transaction | |
number_of_bytes | Number of bytes which the function should write into the RAM | |
write_data | Data which should be written into the RAM | |
sens_num_change | If "sens_num_change" is true and "write_data" equals 254 the node "skin_driver" will delete the old end of chain marker |
Definition at line 378 of file skin_driver.cpp.
bool Skin::bI2CDeviceFound_ [private] |
Verify if I2C device exists.
Definition at line 201 of file skin_driver.h.
bool Skin::binit_skin_ok_ |
Skin is successfully initialized.
Definition at line 155 of file skin_driver.h.
bool Skin::bsub20found_ [private] |
Verify if sub20 device with connection to skin exists.
Definition at line 203 of file skin_driver.h.
bool Skin::bSubDeviceConfigured_ [private] |
Verify if subdevice is configured.
Definition at line 199 of file skin_driver.h.
bool Skin::bSubDeviceOpen_ [private] |
Verify if subdevice is opened.
Definition at line 197 of file skin_driver.h.
sub_handle Skin::fd_ [private] |
Handle for subdevice.
Definition at line 194 of file skin_driver.h.
Number of sensor elements connected to the ECU of the sensor skin.
Definition at line 153 of file skin_driver.h.
std::string Skin::strSerial_ [private] |
Serial number of SUB20 device.
Definition at line 205 of file skin_driver.h.
sub_device Skin::subdev_ [private] |
Definition at line 195 of file skin_driver.h.