PyTic - An Object-Oriented Python Interface for Pololu Tic Stepper Drivers

Hello Community,

I recently developed a Python package called PyTic. It is a fully-functional Python wrapper for the Pololu-Tic-Software C-API which allows users to communicate with the Tic Stepper Driver product series over USB. The package can be pip installed and is fully documented on Github. Below is a link to the repository.



Hello, Dan.

Thank you for sharing this work with the community! I made the Tic C API so that people could write wrappers like this. I’m sure some people will find this useful. I do have a few tips for how to make it better:

  • I notice you are not calling functions like tic_handle_close, tic_list_free, tic_device_free, tic_settings_free, tic_variables_free, and tic_error_free. It is important to use these functions to avoid memory leaks, especially if you want your Python program to run for a long time. The comments in tic.h have more information about when you need to call these functions. Also, it is especially important to provide access to tic_handle_close because a Tic can only have one open handle at a time in Windows and your users might want to close the handle to allow other programs to use the Tic.
  • To make the code easier to maintain, I recommend removing all the structure fields from Those fields will change in future versions of the library so your wrapper should not know about them and just treat the pointers to those structs as opaque. You can use the functions documented in tic.h if you need to read or write information from those structs. The functions in tic.h should keep working as long as the major version of the library continues to be 1, but the fields inside the structs can change in any release when we want to add new features or change internal implementation details. (That’s why we don’t put those structure definitions in externally-usable header files.) I see that you have bundled a pre-built version of libpololu-tic, so that lessens the problem.
  • Assuming you’re not going to directly call functions from libusbp, you shouldn’t need to load libusbp-1.dll explicitly. It should just get loaded because libpololu-tic-1.dll depends on it. I think Windows might find it because it is in the same directory as libpololu-tic-1.dll, but I could be wrong. If you add the directory holding those DLLs to your PATH environment variable (which is something you can do from your Python program), then Windows should definitely find it.

By the way, a few months ago I had a similar discussion with another Python developer on GitHub.

Thanks again. I have already added a link to PyTic in the “Writing PC software to control the Tic” section of the Tic user’s guide, and we are planning to post about it on our blog soon.


Hi David,

Thank you for taking the time to review my code, provide feedback, and post links to my repository on your website.

Relative to your update suggestions,

I should be able to add the tic handle manipulation relatively easily. I plan on adding 32-bit Windows support and applying these memory/handle updates in the near future.

As for the structure portion, PyTic dynamically populates its internal settings & variables interface objects and defines its c-types interactions using the information provided in the structure objects. Changing this would require a major re-write beyond what I can commit time-wise to the project. A possible solution could be developing a parser to pull and update structure information from your provided C source code and then lock a pre-bundled libpololu-tic-1.dll to maintain compatibility for future updates, but I currently do not have time to perform said actions. This will most likely be a task for future developers.

Thank you again for your time reviewing my project and sharing my work with the community. I hope future Python developers can learn from my repository and add functionality to what I’ve started.


1 Like