diff --git a/src/OSC.jl b/src/OSC.jl index 4816d8b..e9525ca 100644 --- a/src/OSC.jl +++ b/src/OSC.jl @@ -57,8 +57,8 @@ has_reserved(typeChar::Char) = typeChar in "isbfhtdSrmc" nreserved(args::ASCIIString) = sum(map(has_reserved, collect(args))) function argType(msg::OscMsg, nargument::Int)#::Char - @assert(nargument < narguments(msg)); - return strip_args(names(msg))[nargument+1] + @assert(nargument > 0 && nargument <= narguments(msg)); + return strip_args(names(msg))[nargument] end align(pos) = pos+(4-(pos-1)%4) @@ -82,7 +82,7 @@ function arg_off(msg::OscMsg, idx::Int)#::Int #ignore any leading '[' or ']' while(args[argc] in "[]") argc += 1 end - while(idx != 0) + while(idx != 1) bundle_length::Uint32 = 0; arg = args[argc] argc += 1 @@ -309,8 +309,8 @@ function showField(io::IO, msg::OscMsg, arg_id) 'F' false; 'N' Nothing] dict = Dict{Char, Any}(map[:,1][:],map[:,2][:]) dict['I'] = Inf - typeChar::Char = argType(msg, arg_id-1) - value = msg[arg_id-1] + typeChar::Char = argType(msg, arg_id) + value = msg[arg_id] if(issubtype(typeof(value), Array)) value = value' end diff --git a/test/runtests.jl b/test/runtests.jl index 9e09404..3b4746c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -61,21 +61,21 @@ function test_it_fat() #println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), buffer[1:len])...)) #println("argument string is=", rtosc_argument_string(buffer)) - @test msg[0] == i - @test msg[1] == f - @test msg[2] == s - @test OSC.stringify(msg[3]) == b - @test msg[4] == h - @test msg[5] == t - @test msg[6] == d - @test msg[7] == S - @test msg[8] == c - @test msg[9] == r - @test msg[10] == m - @test OSC.argType(msg,11) == 'T' - @test OSC.argType(msg,12) == 'F' - @test OSC.argType(msg,13) == 'N' - @test OSC.argType(msg,14) == 'I' + @test msg[1] == i + @test msg[2] == f + @test msg[3] == s + @test OSC.stringify(msg[4]) == b + @test msg[5] == h + @test msg[6] == t + @test msg[7] == d + @test msg[8] == S + @test msg[9] == c + @test msg[10] == r + @test msg[11] == m + @test OSC.argType(msg,12) == 'T' + @test OSC.argType(msg,13) == 'F' + @test OSC.argType(msg,14) == 'N' + @test OSC.argType(msg,15) == 'I' end function test_it_osc_spec()