# Problem with running command line items

**URL:** <https://discourse.julialang.org/t/problem-with-running-command-line-items/5623>\
**Category:** General Usage\
**Created:** [August 29, 2017, 5:34pm UTC](https://discourse.julialang.org/t/problem-with-running-command-line-items/5623 "2017-08-29T17:34:48Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [August 31, 2017, 2:24pm UTC](https://discourse.julialang.org/t/problem-with-running-command-line-items/5623/21 "2017-08-31T14:24:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Frank\_Applin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frank_applin/32/1654_2.png) [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)\
**Post date:** [August 31, 2017, 2:45pm UTC](https://discourse.julialang.org/t/problem-with-running-command-line-items/5623/22 "2017-08-31T14:45:00Z")

</div>

I found some c code at:  
[https://github.com/UDOOboard/serial\_libraries\_examples](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

[Previous page](https://discourse.julialang.org/t/problem-with-running-command-line-items/5623.md?page=1)
