-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Hi @Alexander-Barth and co,
Carrying on from a discussion from Discourse, the merge b48be39 did help me get a bit further with opening an SPI interface, but I am still receiving an error:
julia> using PiGPIO
julia> p = Pi()
[ Info: Successfully connected!
Pi("localhost", 8888, true, PiGPIO.SockLock(Sockets.TCPSocket(RawFD(17) open, 0 bytes waiting), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (2, 547614619512, 547614189232))), PiGPIO.CallbackThread(PiGPIO.SockLock(Sockets.TCPSocket(RawFD(17) open, 0 bytes waiting), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (2, 547614619512, 547614189232))), PiGPIO.SockLock(Sockets.TCPSocket(RawFD(18) paused, 0 bytes waiting), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (0, 547589698944, 0))), true, true, 0, 0x00000000, Any[]))
julia> PiGPIO.spi_^C
julia> h = PiGPIO.spi_open(p, 1, 100000, Int32(0))
ERROR: MethodError: no method matching iterate(::IOBuffer)
Closest candidates are:
iterate(::Pipe, ::Int64)
@ Base stream.jl:1263
iterate(::Pipe)
@ Base stream.jl:1262
iterate(::Base.MethodSpecializations)
@ Base reflection.jl:1148
...
Stacktrace:
[1] _pigpio_command_ext(sl::PiGPIO.SockLock, cmd::Int64, p1::Int64, p2::Int64, p3::Int64, extents::IOBuffer, rl::Bool)
@ PiGPIO ~/.julia/packages/PiGPIO/1FebP/src/pi.jl:128
[2] _pigpio_command_ext(sl::PiGPIO.SockLock, cmd::Int64, p1::Int64, p2::Int64, p3::Int64, extents::IOBuffer)
@ PiGPIO ~/.julia/packages/PiGPIO/1FebP/src/pi.jl:126
[3] spi_open(self::Pi, spi_channel::Int64, baud::Int64, spi_flags::Int32)
@ PiGPIO ~/.julia/packages/PiGPIO/1FebP/src/spiSerial.jl:93
[4] top-level scope
@ REPL[5]:1After debugging, I can observe that the error occurs within this PiGPIO.jl function:
Lines 115 to 138 in e34746d
| """ | |
| Runs an extended pigpio socket command. | |
| * `sl`: command socket and lock. | |
| * `cmd`: the command to be executed. | |
| * `p1`: command parameter 1 (if applicable). | |
| * `p2`: command parameter 2 (if applicable). | |
| * `p3`: total size in bytes of following extents | |
| * `extents`: additional data blocks | |
| """ | |
| function _pigpio_command_ext(sl, cmd, p1, p2, p3, extents, rl=true) | |
| ext = IOBuffer() | |
| Base.write(ext, Array(reinterpret(UInt8, [cmd, p1, p2, p3]))) | |
| for x in extents | |
| write(ext, string(x)) | |
| end | |
| lock(sl.l) | |
| write(sl.s, ext) | |
| msg = reinterpret(Cuint, sl.s)[4] | |
| if rl | |
| unlock(sl.l) | |
| end | |
| return res | |
| end |
In particular, I know it is this loop:
for x in extents
write(ext, string(x))
end As it is trying to iterate over a IOBuffer -- but I am unsure what it is trying to actually do or access. I tested old Julia versions starting from 1.0 and I have concluded this is just buggy code. There was not a point in time post-1.0 Julia that I could find which allows iteration over an IOBuffer.
Any thoughts here? Thanks!
~ tcp 🌳
Metadata
Metadata
Assignees
Labels
No labels