Data Structures | Macros | Enumerations | Functions
ev3_sensor.h File Reference

EV3 Sensors. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  EV3_SENSOR
 Structure of a sensor descriptor. More...
 

Macros

#define EV3_SENSOR_VAR(decl)   extern decl
 
#define EV3_SENSOR_VAR_INIT(decl, ...)   extern decl
 
#define EV3_SENSOR_INL   inline
 
#define SENSOR_DIR   "/sys/class/lego-sensor"
 
#define SENSOR_DESC__LIMIT_   DESC_LIMIT
 
#define SENSOR__NONE_   SENSOR_DESC__LIMIT_
 

Enumerations

enum  {
  SENSOR_TYPE__NONE_ = 0, EV3_ANALOG_XX, NXT_ANALOG, PIXY_LEGO,
  DI_DFLEX, FCL_9DOF, FCL_ADC, FCL_ALTITUDE,
  FCL_GESTURE, FCL_HUMIDITY, FCL_IR, FCL_LIGHT,
  HT_NXT_COLOR, HT_NXT_ANGLE, HT_NXT_ACCEL, HT_NXT_BAROMETRIC,
  HT_NXT_COLOR_V2, HT_NXT_EOPD, HT_NXT_FORCE, HT_NXT_GYRO,
  HT_NXT_IR_LINK, HT_NXT_IR_RECEIVER, HT_NXT_PIR, HT_NXT_COMPASS,
  HT_NXT_MAG, HT_NXT_IR_SEEK_V2, HT_NXT_SMUX, HT_SUPER_PRO,
  LEGO_EV3_US, LEGO_EV3_GYRO, LEGO_EV3_COLOR, LEGO_EV3_TOUCH,
  LEGO_EV3_IR, WEDO_HUB, WEDO_MOTION, WEDO_TILT,
  LEGO_POWER_STORAGE, LEGO_NXT_TEMP, LEGO_NXT_TOUCH, LEGO_NXT_LIGHT,
  LEGO_NXT_SOUND, LEGO_NXT_US, MI_XG1300L, MS_ABSOLUTE_IMU,
  MS_ANGLE, MS_EV3_SMUX, MS_LIGHT_ARRAY, MS_LINE_LEADER,
  MS_NXTCAM, MS_NXTCAM5, MS_NXTMMX, MS_8CH_SERVO,
  MS_PPS58_NX, MS_PIXY_ADAPTER, MS_NXT_TOUCH_MUX, SENSOR_TYPE__COUNT_,
  SENSOR_TYPE__UNKNOWN_ = SENSOR_TYPE__COUNT_
}
 Identifiers of sensor types. More...
 
enum  {
  SENSOR_MODE__NONE_ = 0, EV3_ANALOG_XX_ANALOG, NXT_ANALOG_ANALOG_0, NXT_ANALOG_ANALOG_1,
  PIXY_LEGO_ALL, PIXY_LEGO_SIG1, PIXY_LEGO_SIG2, PIXY_LEGO_SIG3,
  PIXY_LEGO_SIG4, PIXY_LEGO_SIG5, PIXY_LEGO_SIG6, PIXY_LEGO_SIG7,
  DI_DFLEX_FLEX, FCL_9DOF_GYRO, FCL_9DOF_ACC, FCL_9DOF_MAGNET,
  FCL_ADC_CH1_VOLTAGE, FCL_ADC_CH2_VOLTAGE, FCL_ADC_VOLTAGE, FCL_ALTITUDE_PRESSURE,
  FCL_ALTITUDE_ALTITUDE, FCL_GESTURE_GESTURE, FCL_GESTURE_PROXIMITY, FCL_GESTURE_RGB_RAW,
  FCL_GESTURE_CLEAR, FCL_HUMIDITY_CENTIGRADE, FCL_HUMIDITY_FAHRENHEIT, FCL_HUMIDITY_HUMIDITY,
  FCL_IR_IR_DATA, FCL_LIGHT_ILLUMINANCE, HT_NXT_COLOR_COLOR, HT_NXT_COLOR_RED,
  HT_NXT_COLOR_GREEN, HT_NXT_COLOR_BLUE, HT_NXT_COLOR_RAW, HT_NXT_COLOR_NORM,
  HT_NXT_COLOR_ALL, HT_NXT_ANGLE_ANGLE, HT_NXT_ANGLE_ANGLE_ACC, HT_NXT_ANGLE_SPEED,
  HT_NXT_ACCEL_ACCEL, HT_NXT_ACCEL_ALL, HT_NXT_BAROMETRIC_PRESS, HT_NXT_BAROMETRIC_TEMP,
  HT_NXT_COLOR_V2_COLOR, HT_NXT_COLOR_V2_RED, HT_NXT_COLOR_V2_GREEN, HT_NXT_COLOR_V2_BLUE,
  HT_NXT_COLOR_V2_WHITE, HT_NXT_COLOR_V2_NORM, HT_NXT_COLOR_V2_ALL, HT_NXT_COLOR_V2_PASSIVE,
  HT_NXT_COLOR_V2_RAW, HT_NXT_EOPD_LONG, HT_NXT_EOPD_SHORT, HT_NXT_FORCE_FORCE,
  HT_NXT_GYRO_GYRO, HT_NXT_IR_LINK_IRLINK, HT_NXT_IR_RECEIVER_1_MOTOR, HT_NXT_IR_RECEIVER_8_MOTOR,
  HT_NXT_PIR_PROX, HT_NXT_COMPASS_COMPASS, HT_NXT_MAG_MAG, HT_NXT_IR_SEEK_V2_DC,
  HT_NXT_IR_SEEK_V2_AC, HT_NXT_IR_SEEK_V2_DC_ALL, HT_NXT_IR_SEEK_V2_AC_ALL, HT_NXT_SMUX_MUX,
  HT_SUPER_PRO_AIN, HT_SUPER_PRO_DIN, HT_SUPER_PRO_DOUT, HT_SUPER_PRO_DCTRL,
  HT_SUPER_PRO_STROBE, HT_SUPER_PRO_LED, HT_SUPER_PRO_AOUT_0, HT_SUPER_PRO_AOUT_1,
  LEGO_EV3_US_US_DIST_CM, US_US_DIST_CM = LEGO_EV3_US_US_DIST_CM, LEGO_EV3_US_US_DIST_IN, US_US_DIST_IN = LEGO_EV3_US_US_DIST_IN,
  LEGO_EV3_US_US_LISTEN, US_US_LISTEN = LEGO_EV3_US_US_LISTEN, LEGO_EV3_US_US_SI_CM, US_US_SI_CM = LEGO_EV3_US_US_SI_CM,
  LEGO_EV3_US_US_SI_IN, US_US_SI_IN = LEGO_EV3_US_US_SI_IN, LEGO_EV3_US_US_DC_CM, US_US_DC_CM = LEGO_EV3_US_US_DC_CM,
  LEGO_EV3_US_US_DC_IN, US_US_DC_IN = LEGO_EV3_US_US_DC_IN, LEGO_EV3_GYRO_GYRO_ANG, GYRO_GYRO_ANG = LEGO_EV3_GYRO_GYRO_ANG,
  LEGO_EV3_GYRO_GYRO_RATE, GYRO_GYRO_RATE = LEGO_EV3_GYRO_GYRO_RATE, LEGO_EV3_GYRO_GYRO_FAS, GYRO_GYRO_FAS = LEGO_EV3_GYRO_GYRO_FAS,
  LEGO_EV3_GYRO_GYRO_G_AND_A, GYRO_GYRO_G_AND_A = LEGO_EV3_GYRO_GYRO_G_AND_A, LEGO_EV3_GYRO_GYRO_CAL, GYRO_GYRO_CAL = LEGO_EV3_GYRO_GYRO_CAL,
  LEGO_EV3_COLOR_COL_REFLECT, COLOR_COL_REFLECT = LEGO_EV3_COLOR_COL_REFLECT, LEGO_EV3_COLOR_COL_AMBIENT, COLOR_COL_AMBIENT = LEGO_EV3_COLOR_COL_AMBIENT,
  LEGO_EV3_COLOR_COL_COLOR, COLOR_COL_COLOR = LEGO_EV3_COLOR_COL_COLOR, LEGO_EV3_COLOR_REF_RAW, COLOR_REF_RAW = LEGO_EV3_COLOR_REF_RAW,
  LEGO_EV3_COLOR_RGB_RAW, COLOR_RGB_RAW = LEGO_EV3_COLOR_RGB_RAW, LEGO_EV3_COLOR_COL_CAL, COLOR_COL_CAL = LEGO_EV3_COLOR_COL_CAL,
  LEGO_EV3_TOUCH_TOUCH, TOUCH_TOUCH = LEGO_EV3_TOUCH_TOUCH, LEGO_EV3_IR_IR_PROX, IR_IR_PROX = LEGO_EV3_IR_IR_PROX,
  LEGO_EV3_IR_IR_SEEK, IR_IR_SEEK = LEGO_EV3_IR_IR_SEEK, LEGO_EV3_IR_IR_REMOTE, IR_IR_REMOTE = LEGO_EV3_IR_IR_REMOTE,
  LEGO_EV3_IR_IR_REM_A, IR_IR_REM_A = LEGO_EV3_IR_IR_REM_A, LEGO_EV3_IR_IR_S_ALT, IR_IR_S_ALT = LEGO_EV3_IR_IR_S_ALT,
  LEGO_EV3_IR_IR_CAL, IR_IR_CAL = LEGO_EV3_IR_IR_CAL, WEDO_HUB_HUB, WEDO_MOTION_PROX,
  WEDO_MOTION_RAW, WEDO_TILT_TILT, WEDO_TILT_TILT_AXIS, WEDO_TILT_RAW,
  LEGO_POWER_STORAGE_IN_VOLT, LEGO_POWER_STORAGE_IN_AMP, LEGO_POWER_STORAGE_OUT_VOLT, LEGO_POWER_STORAGE_OUT_AMP,
  LEGO_POWER_STORAGE_JOULE, LEGO_POWER_STORAGE_IN_WATT, LEGO_POWER_STORAGE_OUT_WATT, LEGO_POWER_STORAGE_ALL,
  LEGO_NXT_TEMP_NXT_TEMP_C, LEGO_NXT_TEMP_NXT_TEMP_F, LEGO_NXT_TOUCH_TOUCH, LEGO_NXT_LIGHT_REFLECT,
  LEGO_NXT_LIGHT_AMBIENT, LEGO_NXT_SOUND_DB, LEGO_NXT_SOUND_DBA, LEGO_NXT_US_US_DIST_CM,
  LEGO_NXT_US_US_DIST_IN, LEGO_NXT_US_US_SI_CM, LEGO_NXT_US_US_SI_IN, LEGO_NXT_US_US_LISTEN,
  MI_XG1300L_ANGLE, MI_XG1300L_SPEED, MI_XG1300L_ACCEL, MI_XG1300L_ALL,
  MS_ABSOLUTE_IMU_TILT, MS_ABSOLUTE_IMU_ACCEL, MS_ABSOLUTE_IMU_COMPASS, MS_ABSOLUTE_IMU_MAG,
  MS_ABSOLUTE_IMU_GYRO, MS_ABSOLUTE_IMU_ALL, MS_ANGLE_ANGLE, MS_ANGLE_ANGLE2,
  MS_ANGLE_SPEED, MS_ANGLE_ALL, MS_EV3_SMUX_MUX, MS_LIGHT_ARRAY_CAL,
  MS_LIGHT_ARRAY_RAW, MS_LINE_LEADER_PID, MS_LINE_LEADER_PID_ALL, MS_LINE_LEADER_CAL,
  MS_LINE_LEADER_RAW, MS_NXTCAM_TRACK, MS_NXTCAM5_TRACK, MS_NXTMMX_STATUS,
  MS_NXTMMX_STATUS_OLD, MS_8CH_SERVO_V3, MS_8CH_SERVO_OLD, MS_PPS58_NX_RAW,
  MS_PPS58_NX_ABS_PSI, MS_PPS58_NX_ABS_MBAR, MS_PPS58_NX_ABS_KPA, MS_PPS58_NX_REL_PSI,
  MS_PPS58_NX_REL_MBAR, MS_PPS58_NX_REL_KPA, MS_PIXY_ADAPTER_TRACK, MS_NXT_TOUCH_MUX_TOUCH_MUX,
  SENSOR_MODE__COUNT_, SENSOR_MODE__UNKNOWN_ = SENSOR_MODE__COUNT_
}
 Identifiers of sensor "mode" attribute. More...
 
enum  {
  SENSOR_COMMAND__NONE_ = 0, HT_NXT_ANGLE_RESET, HT_NXT_ANGLE_CAL, HT_NXT_SMUX_HALT,
  HT_NXT_SMUX_DETECT, HT_NXT_SMUX_RUN, WEDO_HUB_OUT_OFF, WEDO_HUB_OUT_ON,
  WEDO_HUB_CLEAR_ERR, MI_XG1300L_RESET, MI_XG1300L_ACCEL_2G, MI_XG1300L_ACCEL_4G,
  MI_XG1300L_ACCEL_8G, MS_ABSOLUTE_IMU_BEGIN_COMP_CAL, MS_ABSOLUTE_IMU_END_COMP_CAL, MS_ABSOLUTE_IMU_ACCEL_2G,
  MS_ABSOLUTE_IMU_ACCEL_4G, MS_ABSOLUTE_IMU_ACCEL_8G, MS_ABSOLUTE_IMU_ACCEL_16G, MS_ANGLE_RESET,
  MS_LIGHT_ARRAY_CAL_WHITE, MS_LIGHT_ARRAY_CAL_BLACK, MS_LIGHT_ARRAY_SLEEP, MS_LIGHT_ARRAY_WAKE,
  MS_LIGHT_ARRAY_60HZ, MS_LIGHT_ARRAY_50HZ, MS_LIGHT_ARRAY_UNIVERSAL, MS_LINE_LEADER_CAL_WHITE,
  MS_LINE_LEADER_CAL_BLACK, MS_LINE_LEADER_SLEEP, MS_LINE_LEADER_WAKE, MS_LINE_LEADER_INV_COL,
  MS_LINE_LEADER_RST_COL, MS_LINE_LEADER_SNAP, MS_LINE_LEADER_60HZ, MS_LINE_LEADER_50HZ,
  MS_LINE_LEADER_UNIVERSAL, MS_NXTCAM_TRACK_ON, MS_NXTCAM_TRACK_OFF, MS_NXTCAM_TRACK_OBJ,
  MS_NXTCAM_TRACK_LINE, MS_NXTCAM_SORT_SIZE, MS_NXTCAM_SORT_COL, MS_NXTCAM5_TRACK_OBJ,
  MS_NXTCAM5_TRACK_FACE, MS_NXTCAM5_MULTI_MOVIE, MS_NXTCAM5_MOVIE, MS_NXTCAM5_PICTURE,
  MS_NXTCAM5_TRACK_EYE, MS_NXTCAM5_TRACK_QR, MS_NXTCAM5_TRACK_LINE, MS_PPS58_NX_ZERO,
  MS_PIXY_ADAPTER_SORT_SIZE, MS_PIXY_ADAPTER_SORT_COL, SENSOR_COMMAND__COUNT_, SENSOR_COMMAND__UNKNOWN_ = SENSOR_COMMAND__COUNT_
}
 Identifiers of sensor "command" attribute. More...
 
enum  {
  IR_REMOTE__NONE_ = 0, RED_UP = 1, RED_DOWN = 2, BLUE_UP = 3,
  BLUE_DOWN = 4, RED_UP_BLUE_UP = 5, RED_UP_BLUE_DOWN = 6, RED_DOWN_BLUE_UP = 7,
  RED_DOWN_BLUE_DOWN = 8, BEACON_MODE_ON = 9, RED_UP_RED_DOWN = 10, BLUE_UP_BLUE_DOWN = 11
}
 Identifiers of LEGO_EV3_IR sensor values for IR_REMOTE mode.
 

Functions

 EV3_SENSOR_VAR (EV3_SENSOR ev3_sensor[SENSOR_DESC__LIMIT_])
 Vector of sensor descriptors (filled by ev3_sensor_init).
 
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-h)

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