I don’t have any really great ideas, but one thing I’d suggest is to start smaller: can you open the device read-only, or do you get the inappropriate ioctl error on that?
I found some c code at:
https://github.com/UDOOboard/serial_libraries_examples
I modified one of the examples and called my version readSerialStream. It just reads a single value [at a time] from the looping Arduino code and prints it to the console. The Arduino code is just reading an analog value from a mic and printing the value to the serial port. I, also, pass it the port name. So, in Julia, I wrote the following function:
function getvalue_analog_from_serial(portname::String)
return readchomp(./readSerialStream $portname
)
end
It’s used in the following function. I get the value from the Arduino’s serial stream, check it, and if it’s above a certain value I blink and LED on the Udoo X86 and I return a value back to the master who made the remote call.
function checking_mic_sensor_on_arduino(pinLED::String, portname::String)
value::Int = 0
prv::String = “”
export_pin(pinLED)
sleep(1)
setdirection_pin(pinLED, "out")
while (true)
an = getvalue_analog_from_serial(portname)
#println("an: ", an)
value = parse(Int, an)
sleep(1)
if value >= 525
prv = "U86"
for n = 1:5
setvalue_pin(pinLED, "1")
sleep(.5)
setvalue_pin(pinLED, "0")
sleep(.5)
end
break
end
end
unexport_pin(pinLED)
sleep(1)
return prv
end