Thanks for the suggestions, but neither appear to work. The first produces 
a nonzero pointer,

julia> p = Ptr{Int}[0]
1-element Array{Ptr{Int64},1}:
 Ptr{Int64} @0x0000000000000000


julia> ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
Ref{Ptr{Int}}),"/dev/cu.usbmodem1413",p)
0


julia> p
1-element Array{Ptr{Int64},1}:
 Ptr{Int64} @0x00007fb4d8614f70


but the allocated buffer appears to be gibberish:

julia> bytestring(ccall((:sp_get_port_name, "libserialport"), Ptr{Cchar}, (
typeof(p),), p))
"pOaĜ´\x7f"


julia> bytestring(ccall((:sp_get_port_name, "libserialport"), Ptr{Cchar}, (
Ptr{Int},), p[]))
"\x10!}\b\x01"


And unfortunately the second approach just produces a null pointer:

julia> immutable Port
           portpointer::Ptr{Void}
       end


julia> p = Port(0)
Port(Ptr{Void} @0x0000000000000000)


julia> ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
Ref{Port}),"/dev/cu.usbmodem1413",p)
0


julia> p
Port(Ptr{Void} @0x0000000000000000)


So I'm still stumped...any further help is appreciated.

Andrew


On Thursday, February 11, 2016 at 9:24:07 AM UTC-7, Lutfullah Tomak wrote:
>
> p = Ptr{Int}[0]
> ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
> Ref{Ptr{Int}}),"/dev/cu.usbmodem1413",p)
>
> or
>
> immutable Port
> portpointer::Ptr{Void}
> end
> p=Port(0)
> ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
> Ref{Port}),"/dev/cu.usbmodem1413",p)
>
>

Reply via email to