Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS error code 5: Input/output error on ubuntu #42

Open
IanButterworth opened this issue Nov 11, 2019 · 5 comments
Open

OS error code 5: Input/output error on ubuntu #42

IanButterworth opened this issue Nov 11, 2019 · 5 comments

Comments

@IanButterworth
Copy link
Member

Test errors on master. Ubuntu 18.04. User in the dialout group.

...
/dev/ttyUSB0
    Description:    xxxxxx USB Device - xxxx
    Transport type: SP_TRANSPORT_USB
OS error code 5: Input/output error
Low level API: Error During Test at /home/ian/GitHub/LibSerialPort.jl/test/runtests.jl:31
  Test threw exception
  Expression: test_low_level_api(port, baudrate) == nothing
  From /home/ian/GitHub/LibSerialPort.jl/src/wrap.jl: 141:
  
  libserialport returned SP_ERR_FAIL - Host OS reported a failure.
  Stacktrace:
   [1] error(::String) at ./error.jl:33
   [2] handle_error(::SPReturn, ::String) at /home/ian/GitHub/LibSerialPort.jl/src/wrap.jl:136
   [3] sp_open at /home/ian/GitHub/LibSerialPort.jl/src/wrap.jl:185 [inlined]
   [4] test_low_level_api(::String, ::Vararg{String,N} where N) at /home/ian/GitHub/LibSerialPort.jl/test/test-low-level-api.jl:226
   [5] top-level scope at /home/ian/GitHub/LibSerialPort.jl/test/runtests.jl:31
   [6] top-level scope at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Test/src/Test.jl:1107
   [7] top-level scope at /home/ian/GitHub/LibSerialPort.jl/test/runtests.jl:29
   [8] top-level scope at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Test/src/Test.jl:1107
   [9] top-level scope at /home/ian/GitHub/LibSerialPort.jl/test/runtests.jl:28
  
...
  
Test Summary:    | Pass  Error  Total
LibSerialPort    |    2      2      4
  Low level API  |    1      1      2
  High level API |    1      1      2
error in running finalizer: ErrorException("From /home/ian/GitHub/LibSerialPort.jl/src/wrap.jl: 141:

libserialport returned SP_ERR_ARG - Function was called with invalid arguments.")
ERROR: LoadError: Some tests did not pass: 2 passed, 0 failed, 2 errored, 0 broken.
in expression starting at /home/ian/GitHub/LibSerialPort.jl/test/runtests.jl:14
ERROR: Package LibSerialPort errored during testing
@ederag
Copy link

ederag commented Apr 5, 2020

Same test failures in

Ubuntu 18.10
Julia Version 1.4.0
[a05a14c7] LibSerialPort v0.3.0

Nevertheless, reading the port works:

list_ports()
  /dev/ttyUSB1

port = "/dev/ttyUSB1"

LibSerialPort.open(port, 115200) do s
           #write(s, "input")
           ret =  readuntil(s, '\n', 1.0)  #try to readline with a 1 second timeout
           @show ret
       end
ret = "1527654 310\r\n"
"1527654 310\r\n"

(after uploading the example to an arduino)

Great, thanks for this package !
Please let me know if further diagnostics would be useful.

@mgkuhn
Copy link
Collaborator

mgkuhn commented May 28, 2021

Since there have been significant changes since this issue was raised: does it still exist in v0.5.0 or master?

@ederag
Copy link

ederag commented May 28, 2021

Still OS error code 5: Input/output error, with julia-1.6.1

v0.5.0
(tests) pkg> test LibSerialPort
     Testing LibSerialPort
      Status `/tmp/jl_G2u8mt/Project.toml`
  [a05a14c7] LibSerialPort v0.5.0
  [220460dc] libserialport_jll v0.1.2+0
  [8f399da3] Libdl `@stdlib/Libdl`
  [8dfed614] Test `@stdlib/Test`
      Status `/tmp/jl_G2u8mt/Manifest.toml`
  [a05a14c7] LibSerialPort v0.5.0
  [220460dc] libserialport_jll v0.1.2+0
  [0dad84c5] ArgTools `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [f43a241f] Downloads `@stdlib/Downloads`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [ca575930] NetworkOptions `@stdlib/NetworkOptions`
  [44cfe95a] Pkg `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [fa267f1f] TOML `@stdlib/TOML`
  [a4e569a6] Tar `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [deac9b47] LibCURL_jll `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll `@stdlib/MozillaCACerts_jll`
  [83775a58] Zlib_jll `@stdlib/Zlib_jll`
  [8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll `@stdlib/p7zip_jll`
     Testing Running tests...
Usage: test-low-level-api.jl port [baudrate]
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
Usage: test-low-level-api.jl port [baudrate]
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
0
1
1
0.1.1
1
0
1
1:0:1
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
OS error code 5: Input/output error
Low level API: Error During Test at /home/ederag/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:37
  Test threw exception
  Expression: test_low_level_api(port, baudrate) == nothing
  libserialport returned SP_ERR_FAIL - Host OS reported a failure.
  Stacktrace:
   [1] error(s::String)
     @ Base ./error.jl:33
   [2] check(ret::SPReturn)
     @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/zyrgR/src/wrap.jl:299
   [3] sp_open
     @ ~/.julia/packages/LibSerialPort/zyrgR/src/wrap.jl:341 [inlined]
   [4] test_low_level_api(::String, ::Vararg{String, N} where N)
     @ Main ~/.julia/packages/LibSerialPort/zyrgR/test/test-low-level-api.jl:157
   [5] macro expansion
     @ ~/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:37 [inlined]
   [6] macro expansion
     @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [7] macro expansion
     @ ~/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:35 [inlined]
   [8] macro expansion
     @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [9] top-level scope
     @ ~/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:34
Usage: test-high-level-api.jl port baudrate
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
Usage: test-high-level-api.jl port baudrate
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
OS error code 5: Input/output error
High level API: Error During Test at /home/ederag/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:43
  Test threw exception
  Expression: test_high_level_api(port, baudrate) == nothing
  libserialport returned SP_ERR_FAIL - Host OS reported a failure.
  Stacktrace:
    [1] error(s::String)
      @ Base ./error.jl:33
    [2] check(ret::SPReturn)
      @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/zyrgR/src/wrap.jl:299
    [3] sp_open(port::Ptr{LibSerialPort.Lib.SPPort}, mode::SPMode)
      @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/zyrgR/src/wrap.jl:341
    [4] open(portname::String, baudrate::Int64; mode::SPMode, ndatabits::Int64, parity::SPParity, nstopbits::Int64)
      @ LibSerialPort ~/.julia/packages/LibSerialPort/zyrgR/src/LibSerialPort.jl:463
    [5] open
      @ ~/.julia/packages/LibSerialPort/zyrgR/src/LibSerialPort.jl:462 [inlined]
    [6] test_high_level_api(::String, ::Vararg{String, N} where N)
      @ Main ~/.julia/packages/LibSerialPort/zyrgR/test/test-high-level-api.jl:96
    [7] macro expansion
      @ ~/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:43 [inlined]
    [8] macro expansion
      @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
    [9] macro expansion
      @ ~/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:41 [inlined]
   [10] macro expansion
      @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [11] top-level scope
      @ ~/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:34
Test Summary:    | Pass  Error  Total
LibSerialPort    |    2      2      4
  Low level API  |    1      1      2
  High level API |    1      1      2
ERROR: LoadError: Some tests did not pass: 2 passed, 0 failed, 2 errored, 0 broken.
in expression starting at /home/ederag/.julia/packages/LibSerialPort/zyrgR/test/runtests.jl:20
ERROR: Package LibSerialPort errored during testing
master
(tests) pkg> add LibSerialPort#master
     Cloning git-repo `https://github.com/JuliaIO/LibSerialPort.jl.git`
    Updating git-repo `https://github.com/JuliaIO/LibSerialPort.jl.git`
   Resolving package versions...
    Updating `~/share/prog/julia/tests/Project.toml`
  [a05a14c7] ~ LibSerialPort v0.5.0  v0.5.0 `https://github.com/JuliaIO/LibSerialPort.jl.git#master`
    Updating `~/share/prog/julia/tests/Manifest.toml`
  [a05a14c7] ~ LibSerialPort v0.5.0  v0.5.0 `https://github.com/JuliaIO/LibSerialPort.jl.git#master`
Precompiling project...
  1 dependency successfully precompiled in 1 seconds (247 already precompiled)

(tests) pkg> test LibSerialPort
     Testing LibSerialPort
      Status `/tmp/jl_QrRy9N/Project.toml`
  [a05a14c7] LibSerialPort v0.5.0 `https://github.com/JuliaIO/LibSerialPort.jl.git#master`
  [220460dc] libserialport_jll v0.1.2+0
  [8f399da3] Libdl `@stdlib/Libdl`
  [8dfed614] Test `@stdlib/Test`
      Status `/tmp/jl_QrRy9N/Manifest.toml`
  [a05a14c7] LibSerialPort v0.5.0 `https://github.com/JuliaIO/LibSerialPort.jl.git#master`
  [220460dc] libserialport_jll v0.1.2+0
  [0dad84c5] ArgTools `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [f43a241f] Downloads `@stdlib/Downloads`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [ca575930] NetworkOptions `@stdlib/NetworkOptions`
  [44cfe95a] Pkg `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [fa267f1f] TOML `@stdlib/TOML`
  [a4e569a6] Tar `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [deac9b47] LibCURL_jll `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll `@stdlib/MozillaCACerts_jll`
  [83775a58] Zlib_jll `@stdlib/Zlib_jll`
  [8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll `@stdlib/p7zip_jll`
     Testing Running tests...
Usage: test-low-level-api.jl port [baudrate]
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
Usage: test-low-level-api.jl port [baudrate]
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
0
1
1
0.1.1
1
0
1
1:0:1
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
OS error code 5: Input/output error
Low level API: Error During Test at /home/ederag/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:37
  Test threw exception
  Expression: test_low_level_api(port, baudrate) == nothing
  libserialport returned SP_ERR_FAIL - Host OS reported a failure.
  Stacktrace:
   [1] error(s::String)
     @ Base ./error.jl:33
   [2] check(ret::SPReturn)
     @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/2Zjh2/src/wrap.jl:299
   [3] sp_open
     @ ~/.julia/packages/LibSerialPort/2Zjh2/src/wrap.jl:341 [inlined]
   [4] test_low_level_api(::String, ::Vararg{String, N} where N)
     @ Main ~/.julia/packages/LibSerialPort/2Zjh2/test/test-low-level-api.jl:157
   [5] macro expansion
     @ ~/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:37 [inlined]
   [6] macro expansion
     @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [7] macro expansion
     @ ~/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:35 [inlined]
   [8] macro expansion
     @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [9] top-level scope
     @ ~/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:34
Usage: test-high-level-api.jl port baudrate
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
Usage: test-high-level-api.jl port baudrate
Available ports:
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB
OS error code 5: Input/output error
High level API: Error During Test at /home/ederag/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:43
  Test threw exception
  Expression: test_high_level_api(port, baudrate) == nothing
  libserialport returned SP_ERR_FAIL - Host OS reported a failure.
  Stacktrace:
    [1] error(s::String)
      @ Base ./error.jl:33
    [2] check(ret::SPReturn)
      @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/2Zjh2/src/wrap.jl:299
    [3] sp_open(port::Ptr{LibSerialPort.Lib.SPPort}, mode::SPMode)
      @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/2Zjh2/src/wrap.jl:341
    [4] open(portname::String, baudrate::Int64; mode::SPMode, ndatabits::Int64, parity::SPParity, nstopbits::Int64)
      @ LibSerialPort ~/.julia/packages/LibSerialPort/2Zjh2/src/LibSerialPort.jl:463
    [5] open
      @ ~/.julia/packages/LibSerialPort/2Zjh2/src/LibSerialPort.jl:462 [inlined]
    [6] test_high_level_api(::String, ::Vararg{String, N} where N)
      @ Main ~/.julia/packages/LibSerialPort/2Zjh2/test/test-high-level-api.jl:96
    [7] macro expansion
      @ ~/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:43 [inlined]
    [8] macro expansion
      @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
    [9] macro expansion
      @ ~/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:41 [inlined]
   [10] macro expansion
      @ /usr/local/build/julia-1.6.1_build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [11] top-level scope
      @ ~/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:34
Test Summary:    | Pass  Error  Total
LibSerialPort    |    2      2      4
  Low level API  |    1      1      2
  High level API |    1      1      2
ERROR: LoadError: Some tests did not pass: 2 passed, 0 failed, 2 errored, 0 broken.
in expression starting at /home/ederag/.julia/packages/LibSerialPort/2Zjh2/test/runtests.jl:20
ERROR: Package LibSerialPort errored during testing

With an arduino connected on /dev/ttyUSB0, but readuntil is no longer available ?

`readuntil` missing
julia> using LibSerialPort

julia> list_ports()
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB

julia> port = "/dev/ttyUSB0"
"/dev/ttyUSB0"

julia> LibSerialPort.open(port, 115200) do s
                  #write(s, "input")
                  ret =  readuntil(s, '\n', 1.0)  #try to readline with a 1 second timeout
                  @show ret
              end
ERROR: MethodError: no method matching readuntil(::SerialPort, ::Char, ::Float64)
Closest candidates are:
  readuntil(::AbstractString, ::Any...; kw...) at io.jl:471
  readuntil(::IO, ::AbstractChar; keep) at io.jl:771
  readuntil(::IO, ::T; keep) where T at io.jl:786
  ...
Stacktrace:
 [1] (::var"#1#2")(s::SerialPort)
   @ Main ./REPL[10]:3
 [2] open(::var"#1#2", ::String, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Base ./io.jl:330
 [3] open(::Function, ::String, ::Int64)
   @ Base ./io.jl:328
 [4] top-level scope
   @ REPL[10]:1

Edit:
This time the mwe fails:

Updated mwe
julia> list_ports()
/dev/ttyUSB0
        Description:    FT232R USB UART - A800eKOI
        Transport type: SP_TRANSPORT_USB

julia> # Modify these as needed
       portname = "/dev/ttyS0"
"/dev/ttyS0"

julia> baudrate = 115200
115200

julia> # Snippet from examples/mwe.jl
       LibSerialPort.open(portname, baudrate) do sp
               sleep(2)

               if bytesavailable(sp) > 0
                   println(String(read(sp)))
               end

           write(sp, "hello\n")
           sleep(0.1)
           println(readline(sp))
       end
OS error code 5: Input/output error
ERROR: libserialport returned SP_ERR_FAIL - Host OS reported a failure.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] check(ret::LibSerialPort.Lib.SPReturn)
   @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/2Zjh2/src/wrap.jl:299
 [3] sp_open(port::Ptr{LibSerialPort.Lib.SPPort}, mode::SPMode)
   @ LibSerialPort.Lib ~/.julia/packages/LibSerialPort/2Zjh2/src/wrap.jl:341
 [4] open(portname::String, baudrate::Int64; mode::SPMode, ndatabits::Int64, parity::SPParity, nstopbits::Int64)
   @ LibSerialPort ~/.julia/packages/LibSerialPort/2Zjh2/src/LibSerialPort.jl:463
 [5] open(portname::String, baudrate::Int64)
   @ LibSerialPort ~/.julia/packages/LibSerialPort/2Zjh2/src/LibSerialPort.jl:462
 [6] open(::var"#11#12", ::String, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Base ./io.jl:328
 [7] open(::Function, ::String, ::Int64)
   @ Base ./io.jl:328
 [8] top-level scope
   @ REPL[24]:2

The arduino can be read on ttyUSB0 at 115200 bps with the arduino-1.8.15 monitor.

@laborg
Copy link

laborg commented May 31, 2021

I stumbled over this will trying to read an rfcomm0 port using v0.5.0. Still need to verify if Python has the same problem.

@mgkuhn
Copy link
Collaborator

mgkuhn commented May 31, 2021

The underlying problem behind readutil with timeout seems mainly issue #86, namely that users are currently unable to find the documentation for set_read_timeout, which contains an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants