I am looking at the example libgpiod gpiogetcxx.cpp from github https://github.com/brgl/libgpiod/blob/master/bindings/cxx/examples/gpiogetcxx.cpp i sort of confuse on
The line_bulk::request(const line_request& config, const ::std::vector<int> default_vals) taking line_request structure as reference parameter as shown in below.
struct line_request
{
/**
* @brief Request types.
*/
enum : int {
DIRECTION_AS_IS = 1,
/**< Request for values, don't change the direction. */
DIRECTION_INPUT,
/**< Request for reading line values. */
DIRECTION_OUTPUT,
/**< Request for driving the GPIO lines. */
EVENT_FALLING_EDGE,
/**< Listen for falling edge events. */
EVENT_RISING_EDGE,
/**< Listen for rising edge events. */
EVENT_BOTH_EDGES,
/**< Listen for all types of events. */
};
GPIOD_API static const ::std::bitset<32> FLAG_ACTIVE_LOW;
/**< Set the active state to 'low' (high is the default). */
GPIOD_API static const ::std::bitset<32> FLAG_OPEN_SOURCE;
/**< The line is an open-source port. */
GPIOD_API static const ::std::bitset<32> FLAG_OPEN_DRAIN;
/**< The line is an open-drain port. */
GPIOD_API static const ::std::bitset<32> FLAG_BIAS_DISABLE;
/**< The line has neither pull-up nor pull-down resistor enabled. */
GPIOD_API static const ::std::bitset<32> FLAG_BIAS_PULL_DOWN;
/**< The line has a configurable pull-down resistor enabled. */
GPIOD_API static const ::std::bitset<32> FLAG_BIAS_PULL_UP;
/**< The line has a configurable pull-up resistor enabled. */
::std::string consumer;
/**< Consumer name to pass to the request. */
int request_type;
/**< Type of the request. */
::std::bitset<32> flags;
/**< Additional request flags. */
};
I dont understand the following code
lines.request({
argv[0],
::gpiod::line_request::DIRECTION_INPUT,
0
});
-
i observed that it seemed like the code populate the structure member in very random order,am i correct? i assumed argv[0] correspond to ::std::string consumer,DIRECTION_INPUT correspond to the enum, i not really get what the 0 try to do.
-
I don't see any declaration of structure variable such as line_request obj in the code using csope, i was wonder why this code will not encounter invalid initialization during compilation
-
what happens to other structure members that do not involve in initialization? will it become zero by default?
Aucun commentaire:
Enregistrer un commentaire