mraa icon indicating copy to clipboard operation
mraa copied to clipboard

line flag check result wrong in chardev version

Open xlla opened this issue 6 years ago • 2 comments

I have init a line, and set direction to output successful. later, when I check this line's direction by call function mraa_gpio_read_dir, it will think "Line used by kernel." and return ERROR.

in function mraa_gpio_read_dir, it will check line->flags with those macro

#define GPIOLINE_FLAG_KERNEL		(1UL 

but in mraa_gpio_chardev_dir function, it set line->flag with those macro

/* Linerequest flags */
#define GPIOHANDLE_REQUEST_INPUT	(1UL 

if I skip mraa_gpio_read_dir and check direction, just call mraa_gpio_write in this line, it will success, and program runs fine.

is this function right? it will stop init in function mraa_intel_edison_fab_c statement

if (mraa_gpio_read_dir(tristate, &tristate_dir) != MRAA_SUCCESS) {

xlla avatar Apr 03 '20 16:04 xlla

is this function right? it will stop init in function mraa_intel_edison_fab_c statement

Hi @xlla, yes the function is right but only needed with the Arduino expansion board which is now a retired product. That pin needs to be set to MRAA_GPIO_OUT to successfully init the SPI bus and ADC.

Propanu avatar Apr 12 '20 15:04 Propanu

Hi @Propanu , I am understand it's purpose,
the issus is in chardev version,
I have init a line by

tristate = mraa_gpio_init_by_name(TRI_STATE_ALL)

and set the direction by

mraa_gpio_dir(tristate, MRAA_GPIO_OUT)

then I check the direction by

 mraa_gpio_read_dir(tristate, &tristate_dir)

it will wrong and report "Line used by kernel".

xlla avatar Apr 13 '20 07:04 xlla