napperley
03/08/2025, 10:06 PMstruct gpiod_chip;
struct gpiod_line;
struct gpiod_chip_iter;
struct gpiod_line_iter;
struct gpiod_line_bulk;
napperley
03/08/2025, 10:10 PMCPointer<*>
type, and converting it via the reinterpret
function in the relevant function, e.g.:
private fun toggleGpioPin(chip: CPointer<*>, line: CPointer<*>) {
var value = 0
while (true) {
sleep(1u)
value = if (value == 0) 1 else 0
if (gpiod_line_set_value(line.reinterpret(), value) == -1) {
gpiod_chip_close(chip.reinterpret())
throw IllegalStateException("Cannot set value for GPIO pin")
}
}
}
Adam S
03/09/2025, 7:52 PMimport cnames.structs.gpiod_chip
). cname structs are unrelated to cinterop, and the Kotlin compiler will just pretend that there's a struct with that name, but it might fail at runtime
https://kotlinlang.org/docs/native-c-interop.html#forward-declarationsnapperley
03/10/2025, 4:12 AMnapperley
03/10/2025, 4:19 AMAdam S
03/10/2025, 7:45 AMAdam S
03/10/2025, 7:45 AMcnames.structs
?