14 #ifdef EV3_PORT_IMPLEMENT 15 #define EV3_PORT_VAR( decl ) \ 17 #define EV3_PORT_VAR_INIT( decl, ... ) \ 23 #define EV3_PORT_VAR( decl ) \ 25 #define EV3_PORT_VAR_INIT( decl, ... ) \ 28 #if __GNUC__ && !__GNUC_STDC_INLINE__ 29 #define EV3_PORT_INL \ 32 #define EV3_PORT_INL \ 54 #define PORT_DIR "/sys/class/lego-port" 67 #define PORT_DESC__LIMIT_ DESC_LIMIT 69 #define PORT__NONE_ PORT_DESC__LIMIT_ 74 EV3_PORT_VAR( EV3_PORT ev3_port[ PORT_DESC__LIMIT_ ] ); 99 HT_NXT_SMUX_PORT_ANALOG, HT_NXT_SMUX_ANALOG = HT_NXT_SMUX_PORT_ANALOG,
100 HT_NXT_SMUX_PORT_I2C, HT_NXT_SMUX_I2C = HT_NXT_SMUX_PORT_I2C,
101 LEGOEV3_INPUT_PORT_AUTO, INPUT_AUTO = LEGOEV3_INPUT_PORT_AUTO,
102 LEGOEV3_INPUT_PORT_NXT_ANALOG, INPUT_NXT_ANALOG = LEGOEV3_INPUT_PORT_NXT_ANALOG,
103 LEGOEV3_INPUT_PORT_NXT_COLOR, INPUT_NXT_COLOR = LEGOEV3_INPUT_PORT_NXT_COLOR,
104 LEGOEV3_INPUT_PORT_NXT_I2C, INPUT_NXT_I2C = LEGOEV3_INPUT_PORT_NXT_I2C,
105 LEGOEV3_INPUT_PORT_OTHER_I2C, INPUT_OTHER_I2C = LEGOEV3_INPUT_PORT_OTHER_I2C,
106 LEGOEV3_INPUT_PORT_EV3_ANALOG, INPUT_EV3_ANALOG = LEGOEV3_INPUT_PORT_EV3_ANALOG,
107 LEGOEV3_INPUT_PORT_EV3_UART, INPUT_EV3_UART = LEGOEV3_INPUT_PORT_EV3_UART,
108 LEGOEV3_INPUT_PORT_OTHER_UART, INPUT_OTHER_UART = LEGOEV3_INPUT_PORT_OTHER_UART,
109 LEGOEV3_INPUT_PORT_RAW, INPUT_RAW = LEGOEV3_INPUT_PORT_RAW,
110 LEGOEV3_OUTPUT_PORT_AUTO, OUTPUT_AUTO = LEGOEV3_OUTPUT_PORT_AUTO,
111 LEGOEV3_OUTPUT_PORT_TACHO_MOTOR, OUTPUT_TACHO_MOTOR = LEGOEV3_OUTPUT_PORT_TACHO_MOTOR,
112 LEGOEV3_OUTPUT_PORT_DC_MOTOR, OUTPUT_DC_MOTOR = LEGOEV3_OUTPUT_PORT_DC_MOTOR,
113 LEGOEV3_OUTPUT_PORT_LED, OUTPUT_LED = LEGOEV3_OUTPUT_PORT_LED,
114 LEGOEV3_OUTPUT_PORT_RAW, OUTPUT_RAW = LEGOEV3_OUTPUT_PORT_RAW,
115 MS_EV3_SMUX_PORT_UART, MS_EV3_SMUX_UART = MS_EV3_SMUX_PORT_UART,
116 MS_EV3_SMUX_PORT_ANALOG, MS_EV3_SMUX_ANALOG = MS_EV3_SMUX_PORT_ANALOG,
117 MS_NXTMMX_OUT_PORT_TACHO_MOTOR, MS_NXTMMX_TACHO_MOTOR = MS_NXTMMX_OUT_PORT_TACHO_MOTOR,
118 WEDO_PORT_AUTO, WEDO_AUTO = WEDO_PORT_AUTO,
148 extern size_t get_port_mode( uint8_t sn,
char *buf,
size_t sz );
337 #define EV3_PORT__NONE_ 0 338 #define EXT_PORT__NONE_ EV3_PORT__NONE_ 340 #define INPUT_1 49 // '1' 341 #define INPUT_2 50 // '2' 342 #define INPUT_3 51 // '3' 343 #define INPUT_4 52 // '4' 345 #define OUTPUT_A 65 // 'A' 346 #define OUTPUT_B 66 // 'B' 347 #define OUTPUT_C 67 // 'C' 348 #define OUTPUT_D 68 // 'D' 350 #define MUX_1 49 // '1' 351 #define MUX_2 50 // '2' 352 #define MUX_3 51 // '3' 353 #define MUX_4 52 // '4' 354 #define SERVO__OFFSET_ 16 355 #define SERVO_1 65 // 'A' 356 #define SERVO_2 66 // 'B' 357 #define SERVO_3 67 // 'C' 358 #define SERVO_4 68 // 'D' 359 #define SERVO_5 69 // 'E' 360 #define SERVO_6 70 // 'F' 361 #define SERVO_7 71 // 'G' 362 #define SERVO_8 72 // 'H' 363 #define NXTMMX__OFFSET_ 28 364 #define NXTMMX_1 77 // 'M' 365 #define NXTMMX_2 78 // 'N' 366 #define WEDO__OFFSET_ 48 367 #define WEDO_1 97 // 'a' 368 #define WEDO_2 98 // 'b' 369 #define WEDO_3 99 // 'c' 370 #define WEDO_4 100 // 'd' 387 extern void ev3_parse_port_name(
char *name, uint8_t *port, uint8_t *extport, uint8_t *addr );
397 extern char *
ev3_port_name( uint8_t port, uint8_t extport, uint8_t addr,
char *buf );
406 #undef EV3_PORT_VAR_INIT void ev3_parse_port_name(char *name, uint8_t *port, uint8_t *extport, uint8_t *addr)
Parse name of the EV3 port.
Definition: ev3_port.c:374
size_t get_port_mode(uint8_t sn, char *buf, size_t sz)
Read "mode" attribute of the EV3 port.
Definition: ev3_port.c:46
INX_T get_port_mode_inx(uint8_t sn)
Read "mode" attribute of the EV3 port and get the index.
Definition: ev3_port.c:329
Definition: ev3_port.h:89
const char * ev3_port_mode(INX_T mode_inx)
Get name of the specified EV3 port mode.
Definition: ev3_port.c:220
size_t get_port_driver_name(uint8_t sn, char *buf, size_t sz)
Read "driver_name" attribute of the EV3 port.
Definition: ev3_port.c:38
size_t set_port_set_device(uint8_t sn, char *value)
Write "set_device" attribute of the EV3 port.
Definition: ev3_port.c:77
size_t get_port_status(uint8_t sn, char *buf, size_t sz)
Read "status" attribute of the EV3 port.
Definition: ev3_port.c:92
const char * ev3_port_type(INX_T type_inx)
Get name of the specified EV3 port type.
Definition: ev3_port.c:100
int ev3_port_init(void)
Detect connected EV3 ports.
Definition: ev3_port.c:344
Definition: ev3_port.h:119
uint8_t ev3_port_desc_extport(uint8_t sn)
Get extended port from the EV3 port descriptor.
Definition: ev3_port.c:168
char * ev3_port_port_name(uint8_t sn, char *buf)
Assemble EV3 port name from the EV3 port descriptor.
Definition: ev3_port.c:178
char * ev3_port_name(uint8_t port, uint8_t extport, uint8_t addr, char *buf)
Assemble name of the EV3 port.
Definition: ev3_port.c:446
size_t multi_set_port_set_device(uint8_t *sn, char *value)
Write "set_device" attribute of several EV3 ports.
Definition: ev3_port.c:85
size_t multi_set_port_mode_inx(uint8_t *sn, INX_T mode_inx)
Write "mode" attribute of several EV3 ports by the index.
Definition: ev3_port.c:339
INX_T ev3_port_desc_type_inx(uint8_t sn)
Get type from the EV3 port descriptor.
Definition: ev3_port.c:158
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.
Definition: ev3_port.c:198
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.
Definition: ev3_port.c:273
size_t get_port_modes(uint8_t sn, char *buf, size_t sz)
Read "modes" attribute of the EV3 port.
Definition: ev3_port.c:69
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.
Definition: ev3_port.c:510
uint8_t ev3_port_desc_addr(uint8_t sn)
Get I2C address from the EV3 port descriptor.
Definition: ev3_port.c:173
EV3_PORT * ev3_port_desc(uint8_t sn)
Get descriptor of the EV3 port.
Definition: ev3_port.c:152
size_t get_port_address(uint8_t sn, char *buf, size_t sz)
Read "address" attribute of the EV3 port.
Definition: ev3_port.c:30
INX_T type_inx
Definition: ev3_port.h:60
uint8_t extport
Definition: ev3_port.h:62
Structure of a EV3 port descriptor.
Definition: ev3_port.h:59
uint8_t port
Definition: ev3_port.h:61
size_t get_port_desc(uint8_t sn, EV3_PORT *desc)
Read EV3 port attributes that are required for filling the descriptor.
Definition: ev3_port.c:136
size_t multi_set_port_mode(uint8_t *sn, char *value)
Write "mode" attribute of several EV3 ports.
Definition: ev3_port.c:62
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.
Definition: ev3_port.c:183
INX_T get_port_type_inx(uint8_t sn)
Read "driver_name" attribute and get index of the EV3 port type.
Definition: ev3_port.c:120
uint8_t addr
Definition: ev3_port.h:63
size_t set_port_mode_inx(uint8_t sn, INX_T mode_inx)
Write "mode" attribute of the EV3 port by the index.
Definition: ev3_port.c:334
size_t set_port_mode(uint8_t sn, char *value)
Write "mode" attribute of the EV3 port.
Definition: ev3_port.c:54
uint8_t ev3_port_desc_port(uint8_t sn)
Get EV3 port from the EV3 port descriptor.
Definition: ev3_port.c:163