natcl / Artnet

An Art-Net library for Teensy, Arduino and ESP boards
Other
340 stars 92 forks source link

Checking the Art-Net ID with a length of 9. #13

Closed ghost closed 7 years ago

ghost commented 7 years ago

Checking the Art-Net ID with a length of 9 is not correct because the ID is 8 characters long including the zero termination. All packets will be dropped because the last byte of 9 will probably never match.

Array of 8 characters, the final character is a null termination. Value = ‘A’ ‘r’ ‘t’ ‘-‘ ‘N’ ‘e’ ‘t’ 0x00

nanu-c commented 7 years ago

In the ArtPoll packet definition (http://www.artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf) the ID is an

Array of 8 characters, the final character is a null termination. Value = ‘A’ ‘r’ ‘t’ ‘-‘ ‘N’ ‘e’ ‘t’ 0x00

So you are right

ghost commented 7 years ago

the loop is from index zero to kess the 9: 0...8 Index 8 is undefined: ‘A’ [0] ‘r’ [1] ‘t’ [2] ‘-‘ [3] ‘N’ [4] ‘e’ [5] ‘t’ [6] 0x00 [7] ??? [8]

nanu-c commented 7 years ago

Then make a pull request please, but for me it was never a problem.

ghost commented 7 years ago

Your code:

// Check that packetID is "Art-Net" else ignore for (byte i = 0 ; i < 9 ; i++) { if (artnetPacket[i] != ART_NET_ID[i]) return 0; }

should be IMHO:

// Check that packetID is "Art-Net" else ignore for (byte i = 0 ; i < 8 ; i++) { if (artnetPacket[i] != ART_NET_ID[i]) return 0; }

ghost commented 7 years ago

Why should I make a pull request? Just change the 9 into a 8...

I'm not using this library but someone complained that it does not work with Rocrail: http://forum.rocrail.net/viewtopic.php?f=117&t=12727

Index 8 is the first byte of the opcode as you also wrote in your source: opcode = artnetPacket[8] | artnetPacket[9] << 8;

nanu-c commented 7 years ago

Actually i am not the owner of this repository so i am not able to change it

ghost commented 7 years ago

Attach is a patch.

fixcheckingid.diff.zip

natcl commented 7 years ago

Thanks. Fixed by commit 5cc30a4