tigoe / sACNSource

A library for sending DMX-512 messages in an sACN packet over UDP
https://tigoe.github.io/sACNSource/
MIT License
16 stars 4 forks source link

sequenceNumber is not set in packet #5

Open Trickfilm400 opened 1 year ago

Trickfilm400 commented 1 year ago

Hi, first: this library is nice, saved me a lot of work, but I have found an issue:

My application which I use for the incoming sACN data (DMXControl 3) needs to have a working sequence number, otherwise it will not accept any sACN data.

I found a bug in this library, were the sequence number stays "0", even if the internal variable is updated - but the value in the byte array packet doesn't get updated?

Here the sequence number gets incremented: https://github.com/tigoe/sACNSource/blob/f9539b2907f5f3dc8eee89eb1949a58a41d0c8b9/src/sACNSource.cpp#L177

And here is the function for this - but the internal byte Array doesn't get updated: https://github.com/tigoe/sACNSource/blob/f9539b2907f5f3dc8eee89eb1949a58a41d0c8b9/src/sACNSource.cpp#L140

I made a quick fix:

void sACNSource::setSequenceNumber(byte seqNum) {
  // update sequence number:
  _byteArray[111] = seqNum;
  _sequenceNumber = seqNum;
}

See PR for the mentioned fix


Something to Note: It may be good to reset the sequence counter to 0 if it has reached 256 or something like this to prevent buffer overflow errors if the sequence is too high

void sACNSource::setSequenceNumber(byte seqNum) {
  // update sequence number:
  _byteArray[111] = seqNum;
  _sequenceNumber = seqNum;
  if (_sequenceNumber > 256) _sequenceNumber = 0;
}