I’ve written an Analyzer in C++ with the Analyzer SDK and want to add true autobaud detection.
The available helper functions TrackMinimumPulseWidth() and GetMinimumPulseWidthSoFar() aren’t really helpful, because there may be glitches in the signal that lead to unusable baudrates. Sadly there is no API function that allows you to iterate through the shortest 100 pulses, for example. It would also be nice to get the bit value of the pulse. This requested bit level could be added as a parameter for example.
I successfully added true autobaud detection by creating a histogram for dominant and recessive pulses within a reasonable baudrate range. I then add the shortest dominant and recessive pulse together to have a better result accuracy and then calculate the baudrate based on sum of these pulse durations on the “first” run of the WorkerThread() function. I need the analyzer to be re-run again since you cannot move backwards in the data and am doing this by returning true in the NeedsRerun() function if the autobaud detection was requested in the settings. Once my autobaud detection has run I automatically deactivate it in the settings.
This approach works in Logic 1.x although with one small caveat. It only works on the inital run of the Analyzer. If for example the Analyzer is already present without autobaud detection but with a wrong baudrate and you then change the settings to activate autobaud detection it doesn’t work. The reason is that my internal variables that I use aren’t set properly. When the user chagnes the settings of an existing Analyzer, is there some callback being called where I can reset my internal variables?
In Logic 2.x my autobaud does not work at all. I think is because there is no break condition for the WorkerThread(). Since I first go through all samples until either CheckIfThreadShouldExit() triggers or DoMoreTransitionsExistInCurrentData() returns false to analyze the data I would need a way to force a re-run. Can this be accomplished somehow?