Motan in batch mode

I’m trying to make it possible to extract trapq data with [motion_report] in batch mode.
This would be helpful to simulate prints on printer that we don’t own, or to generate ground truth for testing tools like klipper_estimator.

My plan is to use the existing webhooks api of motion_report and the data_logger.py script. This is simpler than rewriting another serializer just for the debug mode.

There is two issues that need to be overcome:

  • In batch mode, Klipper doesn’t run the webhooks server. Also, it doesn’t wait for data_logger.py to subscribe. This can easily be resolved.
  • The trapq and stepper command histories are pulled from motion_report at regular intervals when a timer fires. In batch mode, the print_time goes by a lot faster than event_time. The histories buffers wraps around in the API_UPDATE_INTERVAL since there is too many of moves simulated during this period.

I managed to pull a complete trapq trace (with a sample here) by using a very low API_UPDATE_INTERVAL.
However this is incredibly hacky, as the timer is basically running against the CPU filling the buffers.

Does anyone have a better solution?

Hmm, I previously wrote a simulated adxl345 (that uses trapq capture to simulate what the measurements would be) and I didn’t have the issues you described (at least on the resonance test, but it has a rate of more than 500 moves / sec).

Though I observed that the data may not be flushed in batch mode, which I fixed this way. Not sure if it would affect your case.

But I agree that dumping stepper motion might be a lot trickier as there are way more events in the stepq(s).

I agree it would be useful to be able to use the motan tools from batch mode. Alas, I’m not sure the best way of doing that… If I come up with an idea, I’ll let you know.

Cheers,
-Kevin

1 Like