Access to EV3 ports and extended ports. More...
Data Structures | |
struct | EV3_PORT |
Structure of a EV3 port descriptor. More... | |
Macros | |
#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_PORT * | ev3_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... | |
Access to EV3 ports and extended ports.
#define PORT__NONE_ PORT_DESC__LIMIT_ |
EV3 port is not found.
#define PORT_DESC__LIMIT_ DESC_LIMIT |
Limit of EV3 port descriptors.
#define PORT_DIR "/sys/class/lego-port" |
Directory of EV3 ports.
anonymous enum |
void ev3_parse_port_name | ( | char * | name, |
uint8_t * | port, | ||
uint8_t * | extport, | ||
uint8_t * | addr | ||
) |
Parse name of the EV3 port.
name | Port name. |
port | Buffer for the EV3 port index. |
extport | Buffer for the extended port index. |
addr | Buffer for the address. |
EV3_PORT* ev3_port_desc | ( | uint8_t | sn | ) |
Get descriptor of the EV3 port.
sn | Sequence number. |
uint8_t ev3_port_desc_addr | ( | uint8_t | sn | ) |
Get I2C address from the EV3 port descriptor.
sn | Sequence number. |
uint8_t ev3_port_desc_extport | ( | uint8_t | sn | ) |
Get extended port from the EV3 port descriptor.
sn | Sequence number. |
uint8_t ev3_port_desc_port | ( | uint8_t | sn | ) |
Get EV3 port from the EV3 port descriptor.
sn | Sequence number. |
INX_T ev3_port_desc_type_inx | ( | uint8_t | sn | ) |
Get type from the EV3 port descriptor.
sn | Sequence number. |
int ev3_port_init | ( | void | ) |
Detect connected EV3 ports.
const char* ev3_port_mode | ( | INX_T | mode_inx | ) |
Get name of the specified EV3 port mode.
mode_inx | Index of the EV3 port mode. |
char* ev3_port_name | ( | uint8_t | port, |
uint8_t | extport, | ||
uint8_t | addr, | ||
char * | buf | ||
) |
Assemble name of the EV3 port.
port | EV3 port index. | |
extport | Extended port index. | |
addr | Address. | |
[out] | buf | Buffer for result. |
char* ev3_port_port_name | ( | uint8_t | sn, |
char * | buf | ||
) |
Assemble EV3 port name from the EV3 port descriptor.
sn | Sequence number. | |
[out] | buf | Buffer for result. |
const char* ev3_port_type | ( | INX_T | type_inx | ) |
Get name of the specified EV3 port type.
type_inx | Index of the EV3 port type. |
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.
port | EV3 port index. |
extport | Extended port index. |
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.
port | EV3 port. | |
extport | Extended port. | |
[out] | sn | Buffer for the sequence number. |
from | Search initial value. |
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.
type_inx | EV3 port type. | |
[out] | sn | Buffer for the sequence number. |
from | Search initial value. |
size_t get_port_address | ( | uint8_t | sn, |
char * | buf, | ||
size_t | sz | ||
) |
Read "address" attribute of the EV3 port.
sn | Sequence number. | |
[out] | buf | Buffer for result. |
sz | Buffer size. |
size_t get_port_desc | ( | uint8_t | sn, |
EV3_PORT * | desc | ||
) |
Read EV3 port attributes that are required for filling the descriptor.
sn | Sequence number. |
desc | Buffer for the descriptor. |
size_t get_port_driver_name | ( | uint8_t | sn, |
char * | buf, | ||
size_t | sz | ||
) |
Read "driver_name" attribute of the EV3 port.
sn | Sequence number. | |
[out] | buf | Buffer for result. |
sz | Buffer size. |
size_t get_port_mode | ( | uint8_t | sn, |
char * | buf, | ||
size_t | sz | ||
) |
Read "mode" attribute of the EV3 port.
sn | Sequence number. | |
[out] | buf | Buffer for result. |
sz | Buffer size. |
INX_T get_port_mode_inx | ( | uint8_t | sn | ) |
Read "mode" attribute of the EV3 port and get the index.
sn | Sequence number. |
This function gets type of the EV3 port from the descriptor.
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.
sn | Sequence number. |
type_inx | Index of the EV3 port type. |
size_t get_port_modes | ( | uint8_t | sn, |
char * | buf, | ||
size_t | sz | ||
) |
Read "modes" attribute of the EV3 port.
sn | Sequence number. | |
[out] | buf | Buffer for result. |
sz | Buffer size. |
size_t get_port_status | ( | uint8_t | sn, |
char * | buf, | ||
size_t | sz | ||
) |
Read "status" attribute of the EV3 port.
sn | Sequence number. | |
[out] | buf | Buffer for result. |
sz | Buffer size. |
INX_T get_port_type_inx | ( | uint8_t | sn | ) |
Read "driver_name" attribute and get index of the EV3 port type.
sn | Sequence number. |
size_t multi_set_port_mode | ( | uint8_t * | sn, |
char * | value | ||
) |
Write "mode" attribute of several EV3 ports.
sn | Vector of sequence numbers ending with DESC_LIMIT. |
value | Attribute value. |
size_t multi_set_port_mode_inx | ( | uint8_t * | sn, |
INX_T | mode_inx | ||
) |
Write "mode" attribute of several EV3 ports by the index.
sn | Vector of sequence numbers ending with DESC_LIMIT. |
mode_inx | Index of the EV3 port mode. |
size_t multi_set_port_set_device | ( | uint8_t * | sn, |
char * | value | ||
) |
Write "set_device" attribute of several EV3 ports.
sn | Vector of sequence numbers ending with DESC_LIMIT. |
value | Attribute value. |
size_t set_port_mode | ( | uint8_t | sn, |
char * | value | ||
) |
Write "mode" attribute of the EV3 port.
sn | Sequence number. |
value | Attribute value. |
size_t set_port_mode_inx | ( | uint8_t | sn, |
INX_T | mode_inx | ||
) |
Write "mode" attribute of the EV3 port by the index.
sn | Sequence number. |
mode_inx | Index of the EV3 port mode. |
size_t set_port_set_device | ( | uint8_t | sn, |
char * | value | ||
) |
Write "set_device" attribute of the EV3 port.
sn | Sequence number. |
value | Attribute value. |