mathertel / DMXSerial

An Arduino library for sending and receiving DMX packets.
BSD 3-Clause "New" or "Revised" License
320 stars 76 forks source link

noDataSince() overflow #56

Open benjaminauer opened 2 years ago

benjaminauer commented 2 years ago

typecasting the returned unsigned long shows that it returns an overflown unsigned long it seems that the calculation in the function is interrupted and this is resulting to cause the substraction giving out a negative number, although im not really experienced. Code is run on Arduino Micro

unsigned long dmx_last_packet;
void loop() {
    dmx_last_packet = DMXSerial.noDataSince();
    if(dmx_last_packet>2000) {
        count++;
        printf("\nADIOS:%i",count);
        printf("=%ld OR %lu",(long signed) dmx_last_packet,dmx_last_packet);

        if(count>100) {
            led_debug.setOnSingle();
            for(;;) {}
        }
    }
}

console output:


ADIOS:1=-217 OR 4294967079
ADIOS:2=-218 OR 4294967078
Yorams commented 2 years ago

I have exact the same issue using an Arduino Every. I wil take a look at the method. I'm not that experienced to, but maybe i can make something out of it.