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

EV3 Ports. More...

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

Go to the source code of this file.

Data Structures

struct  EV3_PORT
 Structure of a EV3 port descriptor. More...
 

Macros

#define EV3_PORT_VAR(decl)   extern decl
 
#define EV3_PORT_VAR_INIT(decl, ...)   extern decl
 
#define EV3_PORT_INL   inline
 
#define PORT_DIR   "/sys/class/lego-port"
 
#define PORT_DESC__LIMIT_   DESC_LIMIT
 
#define PORT__NONE_   PORT_DESC__LIMIT_
 
#define EV3_PORT__NONE_   0 /* XXX: 0 is used */
 Identifiers of EV3 ports and extended ports.
 
#define EXT_PORT__NONE_   EV3_PORT__NONE_
 
#define INPUT_1   49
 
#define INPUT_2   50
 
#define INPUT_3   51
 
#define INPUT_4   52
 
#define OUTPUT_A   65
 
#define OUTPUT_B   66
 
#define OUTPUT_C   67
 
#define OUTPUT_D   68
 
#define MUX_1   49
 
#define MUX_2   50
 
#define MUX_3   51
 
#define MUX_4   52
 
#define SERVO__OFFSET_   16
 
#define SERVO_1   65
 
#define SERVO_2   66
 
#define SERVO_3   67
 
#define SERVO_4   68
 
#define SERVO_5   69
 
#define SERVO_6   70
 
#define SERVO_7   71
 
#define SERVO_8   72
 
#define NXTMMX__OFFSET_   28
 
#define NXTMMX_1   77
 
#define NXTMMX_2   78
 
#define WEDO__OFFSET_   48
 
#define WEDO_1   97
 
#define WEDO_2   98
 
#define WEDO_3   99
 
#define WEDO_4   100
 

Enumerations

enum  {
  PORT_TYPE__NONE_ = 0, HT_NXT_SMUX_PORT, LEGOEV3_INPUT_PORT, LEGOEV3_OUTPUT_PORT,
  MS_EV3_SMUX_PORT, MS_NXTMMX_OUT_PORT, WEDO_PORT, PORT_TYPE__COUNT_,
  PORT_TYPE__UNKNOWN_ = PORT_TYPE__COUNT_
}
 Identifiers of EV3 port types. More...
 
enum  {
  PORT_MODE__NONE_ = 0, HT_NXT_SMUX_PORT_ANALOG, HT_NXT_SMUX_ANALOG = HT_NXT_SMUX_PORT_ANALOG, HT_NXT_SMUX_PORT_I2C,
  HT_NXT_SMUX_I2C = HT_NXT_SMUX_PORT_I2C, LEGOEV3_INPUT_PORT_AUTO, INPUT_AUTO = LEGOEV3_INPUT_PORT_AUTO, LEGOEV3_INPUT_PORT_NXT_ANALOG,
  INPUT_NXT_ANALOG = LEGOEV3_INPUT_PORT_NXT_ANALOG, LEGOEV3_INPUT_PORT_NXT_COLOR, INPUT_NXT_COLOR = LEGOEV3_INPUT_PORT_NXT_COLOR, LEGOEV3_INPUT_PORT_NXT_I2C,
  INPUT_NXT_I2C = LEGOEV3_INPUT_PORT_NXT_I2C, LEGOEV3_INPUT_PORT_OTHER_I2C, INPUT_OTHER_I2C = LEGOEV3_INPUT_PORT_OTHER_I2C, LEGOEV3_INPUT_PORT_EV3_ANALOG,
  INPUT_EV3_ANALOG = LEGOEV3_INPUT_PORT_EV3_ANALOG, LEGOEV3_INPUT_PORT_EV3_UART, INPUT_EV3_UART = LEGOEV3_INPUT_PORT_EV3_UART, LEGOEV3_INPUT_PORT_OTHER_UART,
  INPUT_OTHER_UART = LEGOEV3_INPUT_PORT_OTHER_UART, LEGOEV3_INPUT_PORT_RAW, INPUT_RAW = LEGOEV3_INPUT_PORT_RAW, LEGOEV3_OUTPUT_PORT_AUTO,
  OUTPUT_AUTO = LEGOEV3_OUTPUT_PORT_AUTO, LEGOEV3_OUTPUT_PORT_TACHO_MOTOR, OUTPUT_TACHO_MOTOR = LEGOEV3_OUTPUT_PORT_TACHO_MOTOR, LEGOEV3_OUTPUT_PORT_DC_MOTOR,
  OUTPUT_DC_MOTOR = LEGOEV3_OUTPUT_PORT_DC_MOTOR, LEGOEV3_OUTPUT_PORT_LED, OUTPUT_LED = LEGOEV3_OUTPUT_PORT_LED, LEGOEV3_OUTPUT_PORT_RAW,
  OUTPUT_RAW = LEGOEV3_OUTPUT_PORT_RAW, MS_EV3_SMUX_PORT_UART, MS_EV3_SMUX_UART = MS_EV3_SMUX_PORT_UART, MS_EV3_SMUX_PORT_ANALOG,
  MS_EV3_SMUX_ANALOG = MS_EV3_SMUX_PORT_ANALOG, MS_NXTMMX_OUT_PORT_TACHO_MOTOR, MS_NXTMMX_TACHO_MOTOR = MS_NXTMMX_OUT_PORT_TACHO_MOTOR, WEDO_PORT_AUTO,
  WEDO_AUTO = WEDO_PORT_AUTO, PORT_MODE__COUNT_, PORT_MODE__UNKNOWN_ = PORT_MODE__COUNT_
}
 Identifiers of EV3 port "mode" attribute. More...
 

Functions

 EV3_PORT_VAR (EV3_PORT ev3_port[PORT_DESC__LIMIT_])
 Vector of EV3 port descriptors (filled by ev3_port_init).
 
size_t get_port_address (uint8_t sn, char *buf, size_t sz)
 Read "address" attribute of the EV3 port. More...
 
size_t get_port_driver_name (uint8_t sn, char *buf, size_t sz)
 Read "driver_name" attribute of the EV3 port. More...
 
size_t get_port_mode (uint8_t sn, char *buf, size_t sz)
 Read "mode" attribute of the EV3 port. More...
 
size_t set_port_mode (uint8_t sn, char *value)
 Write "mode" attribute of the EV3 port. More...
 
size_t multi_set_port_mode (uint8_t *sn, char *value)
 Write "mode" attribute of several EV3 ports. More...
 
size_t get_port_modes (uint8_t sn, char *buf, size_t sz)
 Read "modes" attribute of the EV3 port. More...
 
size_t set_port_set_device (uint8_t sn, char *value)
 Write "set_device" attribute of the EV3 port. More...
 
size_t multi_set_port_set_device (uint8_t *sn, char *value)
 Write "set_device" attribute of several EV3 ports. More...
 
size_t get_port_status (uint8_t sn, char *buf, size_t sz)
 Read "status" attribute of the EV3 port. More...
 
const char * ev3_port_type (INX_T type_inx)
 Get name of the specified EV3 port type. More...
 
INX_T get_port_type_inx (uint8_t sn)
 Read "driver_name" attribute and get index of the EV3 port type. More...
 
size_t get_port_desc (uint8_t sn, EV3_PORT *desc)
 Read EV3 port attributes that are required for filling the descriptor. More...
 
EV3_PORTev3_port_desc (uint8_t sn)
 Get descriptor of the EV3 port. More...
 
INX_T ev3_port_desc_type_inx (uint8_t sn)
 Get type from the EV3 port descriptor. More...
 
uint8_t ev3_port_desc_port (uint8_t sn)
 Get EV3 port from the EV3 port descriptor. More...
 
uint8_t ev3_port_desc_extport (uint8_t sn)
 Get extended port from the EV3 port descriptor. More...
 
uint8_t ev3_port_desc_addr (uint8_t sn)
 Get I2C address from the EV3 port descriptor. More...
 
char * ev3_port_port_name (uint8_t sn, char *buf)
 Assemble EV3 port name from the EV3 port descriptor. More...
 
bool ev3_search_port_type (INX_T type_inx, uint8_t *sn, uint8_t from)
 Search of a sequence number of the specified EV3 port type. More...
 
bool ev3_search_port_plugged_in (uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from)
 Search of a sequence number the EV3 port by plug-in attributes. More...
 
const char * ev3_port_mode (INX_T mode_inx)
 Get name of the specified EV3 port mode. More...
 
INX_T get_port_mode_inx_of_type (uint8_t sn, INX_T type_inx)
 Read "mode" attribute of the specified EV3 port type and get the index. More...
 
INX_T get_port_mode_inx (uint8_t sn)
 Read "mode" attribute of the EV3 port and get the index. More...
 
size_t set_port_mode_inx (uint8_t sn, INX_T mode_inx)
 Write "mode" attribute of the EV3 port by the index. More...
 
size_t multi_set_port_mode_inx (uint8_t *sn, INX_T mode_inx)
 Write "mode" attribute of several EV3 ports by the index. More...
 
int ev3_port_init (void)
 Detect connected EV3 ports. More...
 
uint8_t ev3_search_port (uint8_t port, uint8_t extport)
 Search of a port sequence number by the EV3 port and the extended port. More...
 
void ev3_parse_port_name (char *name, uint8_t *port, uint8_t *extport, uint8_t *addr)
 Parse name of the EV3 port. More...
 
char * ev3_port_name (uint8_t port, uint8_t extport, uint8_t addr, char *buf)
 Assemble name of the EV3 port. More...
 

Detailed Description

EV3 Ports.

(ev3_port.yu-h)

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