-->
Page 1 of 1

UDP Server Question?

PostPosted: Fri Nov 06, 2015 4:16 am
by ArtWhaley
I'm trying to use a nodeMCU dev board with the most recent firmware to decode UDP packets from a lighting controller.

Viewing the packet in Wireshark I can confirm that it's all there - I'm getting 572 bytes and they're all correct and in the right place. When I run a UDP server on the nodMCU... I only see the protocol's ID field as plain text... 8 of the 572 bytes.

https://gyazo.com/6fb293c02d4a56d6ece9e7c3514a0b52 shows the wireshark packet... and here's my code:

Code: Select alls=net.createServer(net.UDP)
s:on("receive",function(s,c) print(c) end)
s:listen(5568)



What gets printed is simply "Art-Net" once per packet received. Do I need to do something differently to get or view the full binary data from the packet?

Re: UDP Server Question?

PostPosted: Sun Nov 08, 2015 10:41 am
by TerryE
c contains a mostly non-printable string , so when you print it you only see the printable characters. You can use crypto.toHex() if you are running a dev build or a roll-your-own like something like:
Code: Select allfunction strToHex(s)
  local bytes = {}
  for i=1,s:len()  do
    bytes[#bytes+1] = ('%2x'):format(s:byte(i,i))
  end
  return table.concat(bytes, ' ')
end