Macros | Functions
ev3_sensor.c File Reference

EV3 Sensors. More...

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "modp_numtoa.h"
#include "crc32.h"
#include "ev3.h"
#include "ev3_port.h"
#include "ev3_sensor.h"

Macros

#define EV3_SENSOR_IMPLEMENT
 
#define PATH_PREF_LEN   29
 
#define DESC_SPOT   "///"
 
#define PATH_ADDRESS   "/sys/class/lego-sensor/sensor" DESC_SPOT "address"
 
#define PATH_BIN_DATA   "/sys/class/lego-sensor/sensor" DESC_SPOT "bin_data"
 
#define PATH_BIN_DATA_FORMAT   "/sys/class/lego-sensor/sensor" DESC_SPOT "bin_data_format"
 
#define PATH_COMMAND   "/sys/class/lego-sensor/sensor" DESC_SPOT "command"
 
#define PATH_COMMANDS   "/sys/class/lego-sensor/sensor" DESC_SPOT "commands"
 
#define PATH_DIRECT   "/sys/class/lego-sensor/sensor" DESC_SPOT "direct"
 
#define PATH_DECIMALS   "/sys/class/lego-sensor/sensor" DESC_SPOT "decimals"
 
#define PATH_DRIVER_NAME   "/sys/class/lego-sensor/sensor" DESC_SPOT "driver_name"
 
#define PATH_FW_VERSION   "/sys/class/lego-sensor/sensor" DESC_SPOT "fw_version"
 
#define PATH_MODE   "/sys/class/lego-sensor/sensor" DESC_SPOT "mode"
 
#define PATH_MODES   "/sys/class/lego-sensor/sensor" DESC_SPOT "modes"
 
#define PATH_NUM_VALUES   "/sys/class/lego-sensor/sensor" DESC_SPOT "num_values"
 
#define PATH_POLL_MS   "/sys/class/lego-sensor/sensor" DESC_SPOT "poll_ms"
 
#define PATH_UNITS   "/sys/class/lego-sensor/sensor" DESC_SPOT "units"
 
#define PATH_VALUE0   "/sys/class/lego-sensor/sensor" DESC_SPOT "value0"
 
#define PATH_VALUE1   "/sys/class/lego-sensor/sensor" DESC_SPOT "value1"
 
#define PATH_VALUE2   "/sys/class/lego-sensor/sensor" DESC_SPOT "value2"
 
#define PATH_VALUE3   "/sys/class/lego-sensor/sensor" DESC_SPOT "value3"
 
#define PATH_VALUE4   "/sys/class/lego-sensor/sensor" DESC_SPOT "value4"
 
#define PATH_VALUE5   "/sys/class/lego-sensor/sensor" DESC_SPOT "value5"
 
#define PATH_VALUE6   "/sys/class/lego-sensor/sensor" DESC_SPOT "value6"
 
#define PATH_VALUE7   "/sys/class/lego-sensor/sensor" DESC_SPOT "value7"
 
#define PATH_TEXT_VALUE   "/sys/class/lego-sensor/sensor" DESC_SPOT "text_value"
 
#define PATH_VALUE   "/sys/class/lego-sensor/sensor" DESC_SPOT "value"
 

Functions

size_t get_sensor_address (uint8_t sn, char *buf, size_t sz)
 Read "address" attribute of the sensor. More...
 
size_t get_sensor_bin_data (uint8_t sn, byte *buf, size_t sz)
 Read "bin_data" attribute of the sensor. More...
 
size_t set_sensor_bin_data (uint8_t sn, byte *value, size_t sz)
 Write "bin_data" attribute of the sensor. More...
 
size_t multi_set_sensor_bin_data (uint8_t *sn, byte *value, size_t sz)
 Write "bin_data" attribute of several sensors. More...
 
size_t get_sensor_bin_data_format (uint8_t sn, char *buf, size_t sz)
 Read "bin_data_format" attribute of the sensor. More...
 
size_t set_sensor_command (uint8_t sn, char *value)
 Write "command" attribute of the sensor. More...
 
size_t multi_set_sensor_command (uint8_t *sn, char *value)
 Write "command" attribute of several sensors. More...
 
size_t get_sensor_commands (uint8_t sn, char *buf, size_t sz)
 Read "commands" attribute of the sensor. More...
 
size_t get_sensor_direct (uint8_t sn, char *buf, size_t sz)
 Read "direct" attribute of the sensor. More...
 
size_t set_sensor_direct (uint8_t sn, char *value)
 Write "direct" attribute of the sensor. More...
 
size_t multi_set_sensor_direct (uint8_t *sn, char *value)
 Write "direct" attribute of several sensors. More...
 
size_t get_sensor_decimals (uint8_t sn, dword *buf)
 Read "decimals" attribute of the sensor. More...
 
size_t get_sensor_driver_name (uint8_t sn, char *buf, size_t sz)
 Read "driver_name" attribute of the sensor. More...
 
size_t get_sensor_fw_version (uint8_t sn, char *buf, size_t sz)
 Read "fw_version" attribute of the sensor. More...
 
size_t get_sensor_mode (uint8_t sn, char *buf, size_t sz)
 Read "mode" attribute of the sensor. More...
 
size_t set_sensor_mode (uint8_t sn, char *value)
 Write "mode" attribute of the sensor. More...
 
size_t multi_set_sensor_mode (uint8_t *sn, char *value)
 Write "mode" attribute of several sensors. More...
 
size_t get_sensor_modes (uint8_t sn, char *buf, size_t sz)
 Read "modes" attribute of the sensor. More...
 
size_t get_sensor_num_values (uint8_t sn, dword *buf)
 Read "num_values" attribute of the sensor. More...
 
size_t get_sensor_poll_ms (uint8_t sn, dword *buf)
 Read "poll_ms" attribute of the sensor. More...
 
size_t set_sensor_poll_ms (uint8_t sn, dword value)
 Write "poll_ms" attribute of the sensor. More...
 
size_t multi_set_sensor_poll_ms (uint8_t *sn, dword value)
 Write "poll_ms" attribute of several sensors. More...
 
size_t get_sensor_units (uint8_t sn, char *buf, size_t sz)
 Read "units" attribute of the sensor. More...
 
size_t get_sensor_value0 (uint8_t sn, float *buf)
 Read "value0" attribute of the sensor. More...
 
size_t get_sensor_value1 (uint8_t sn, float *buf)
 Read "value1" attribute of the sensor. More...
 
size_t get_sensor_value2 (uint8_t sn, float *buf)
 Read "value2" attribute of the sensor. More...
 
size_t get_sensor_value3 (uint8_t sn, float *buf)
 Read "value3" attribute of the sensor. More...
 
size_t get_sensor_value4 (uint8_t sn, float *buf)
 Read "value4" attribute of the sensor. More...
 
size_t get_sensor_value5 (uint8_t sn, float *buf)
 Read "value5" attribute of the sensor. More...
 
size_t get_sensor_value6 (uint8_t sn, float *buf)
 Read "value6" attribute of the sensor. More...
 
size_t get_sensor_value7 (uint8_t sn, float *buf)
 Read "value7" attribute of the sensor. More...
 
size_t get_sensor_text_value (uint8_t sn, char *buf, size_t sz)
 Read "text_value" attribute of the sensor. More...
 
size_t get_sensor_value (uint8_t inx, uint8_t sn, int *buf)
 Read "value" attribute of the sensor. More...
 
const char * ev3_sensor_type (INX_T type_inx)
 Get name of the specified sensor type. More...
 
INX_T get_sensor_type_inx (uint8_t sn)
 Read "driver_name" attribute and get index of the sensor type. More...
 
size_t get_sensor_desc (uint8_t sn, EV3_SENSOR *desc)
 Read sensor attributes that are required for filling the descriptor. More...
 
EV3_SENSORev3_sensor_desc (uint8_t sn)
 Get descriptor of the sensor. More...
 
INX_T ev3_sensor_desc_type_inx (uint8_t sn)
 Get type from the sensor descriptor. More...
 
uint8_t ev3_sensor_desc_port (uint8_t sn)
 Get EV3 port from the sensor descriptor. More...
 
uint8_t ev3_sensor_desc_extport (uint8_t sn)
 Get extended port from the sensor descriptor. More...
 
uint8_t ev3_sensor_desc_addr (uint8_t sn)
 Get I2C address from the sensor descriptor. More...
 
char * ev3_sensor_port_name (uint8_t sn, char *buf)
 Assemble EV3 port name from the sensor descriptor. More...
 
bool ev3_search_sensor (INX_T type_inx, uint8_t *sn, uint8_t from)
 Search of a sequence number of the specified sensor type. More...
 
bool ev3_search_sensor_plugged_in (uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from)
 Search of a sequence number the sensor by plug-in attributes. More...
 
const char * ev3_sensor_mode (INX_T mode_inx)
 Get name of the specified sensor mode. More...
 
INX_T get_sensor_mode_inx_of_type (uint8_t sn, INX_T type_inx)
 Read "mode" attribute of the specified sensor type and get the index. More...
 
INX_T get_sensor_mode_inx (uint8_t sn)
 Read "mode" attribute of the sensor and get the index. More...
 
size_t set_sensor_mode_inx (uint8_t sn, INX_T mode_inx)
 Write "mode" attribute of the sensor by the index. More...
 
size_t multi_set_sensor_mode_inx (uint8_t *sn, INX_T mode_inx)
 Write "mode" attribute of several sensors by the index. More...
 
const char * ev3_sensor_command (INX_T command_inx)
 Get name of the specified sensor command. More...
 
size_t set_sensor_command_inx (uint8_t sn, INX_T command_inx)
 Write "command" attribute of the sensor by the index. More...
 
size_t multi_set_sensor_command_inx (uint8_t *sn, INX_T command_inx)
 Write "command" attribute of several sensors by the index. More...
 
int ev3_sensor_init (void)
 Detect connected sensors. More...
 

Detailed Description

EV3 Sensors.

(ev3_sensor.yu-c)

Author
Vitaly Kravtsov (in4li.nosp@m.o@gm.nosp@m.ail.c.nosp@m.om)