• I'm using Waveform to rapidly read a sequence of data, very successfully. The code is like this:

    wfrm = new Waveform(5)
    wfrm.on('finish', callback)
    setInterval(() => {
      wfrm.startInput(A0, 50)
    }, 500)
    
    function callback(buf) {
      // do something with buf
    }
    

    Every 500 ms a 'task' is started to do an A/D converesion, 5 times, at 50 Hz.
    When ready the callback evaluates the passed Uint8Array (argument 'buf') very quickly -> no problem at all.
    Sometimes, however, there are errors

    Uncaught Error: Waveform is already running
    Uncaught InternalError: Timeout on ADC
    

    Sometimes the callback has to do more, including an HTTP call. This might take longer than the repat interval of 500 ms an cause these errors.
    Does a long running callback (longer than 500 ms) really make the Waveform complain at the next startInput, as I'm thinking?
    Is there a way to effectively make the callback appear as completed although parts of the code still need to be executed - like process.nextTick?

About

Avatar for Steffen @Steffen started