How to get ArtNet data with the Godot udp_server?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamemap

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?

:bust_in_silhouette: Reply From: klaas

Hi.
when you read a string in c language a null is the string terminator. Maybe get_string_from_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())

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

Gamemap | 2021-08-12 04:59

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)

klaas | 2021-08-12 09:24

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?

Gamemap | 2021-08-12 11:15

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

klaas | 2021-08-12 11:21

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?

Gamemap | 2021-08-12 16:20