0 votes

I want to retrieve the ArtNet data from a lighting control program (I use QLC+ for this).
I use the Godot UDP server listening on port 6454, but the only data I get is Art-Net, which should be followed by a null character (Wikipedia) and more data but the null character and all data after it are not decoded.
(I used udp_network.get_packet().get_string_from_ascii())

Is it possible to decode this better?

in Engine by (168 points)
edited by

1 Answer

+2 votes
Best answer

Hi.
when you read a string in c language a null is the string terminator. Maybe getstringfrom_ascii method reads bytes until it reads a null byte wich will mark the end of a string.

What does this print? ... if only the content of the string is submited the size equal

var packet = udp_network.get_packet()
print(packet.packet.get_string_from_ascii())
print(packet.udp_network.get_packet().size())
by (3,932 points)
selected by

Thanks for your help!

I had to delete the package. in both print function because an error occurred but the output should still be correct.

My Output is this:
1. Line: Art-Net
2. Line: 530

As i expected ... you read only 7bytes from 530 bytes available.

Try something like this to read all strings from the pool array:

var pool:PoolByteArray = ("this is a test string").to_ascii()
pool.append(0)
pool.append_array(("this is another string to test").to_ascii())

var packet_contents:Array
var last:int = 0
for i in pool.size():
    if pool[i] == 0 or i == pool.size()-1:
        var tmp = pool.subarray(last,i).get_string_from_ascii( )
        print("string end found at "+str(i))
        print("content: "+tmp)
        packet_contents.append(tmp)
        last = i+1
print("--------------")
print(packet_contents)

In the end I get this output (the content line is empty almost every time):
-------------- [Art-Net, , P, ♫☺, , , ☻, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ]

P.S.: How can I write the output in a box like yours?

Hi
i dont know the protocol and your expected values. Maybe the empty comma seperated values ar'nt ascii chars but integer values!?

sorry i was so stupid, of course there are also numbers.
Is the only way to get numbers .hex_encode()?
How did you made the Codebox in your answer?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.