Replies: 8 comments 13 replies
-
I think a Python binding for libavrdude is good to have. My question is why using SWIG? The more popular ways now seem to be using ctypes or cython. Example from the projects I am involved in. From my testing, libftdi's built-in SWIG based binding is the most problematic. pyusb -- ctypes |
Beta Was this translation helpful? Give feedback.
-
Not so sure if you have some inputs here as well. Thanks. |
Beta Was this translation helpful? Give feedback.
-
The comments by @ndim here may be related. Maybe now it is time to clean up libavrdude, probably @stefanrueger, @ndim and you can help on this front.
|
Beta Was this translation helpful? Give feedback.
-
I still think it is OK to fix the build system first and look at the API/ABI later.
If that means encapsulating some of the properties of parts by the use of get_...() functions and hiding access to components this is doable. If the end-goal is to not expose the internal structure of PROGRAMMER, AVRPART or AVRMEM in the API, that's also doable. This kind of means replacing What has happened in the past is that, for example, a new part came out with an "unusual" property that the page size for erasing is 4 times bigger than the page size for writing. AVRDUDE needed to find a way to describe a part as having this property and extended the AVRPART structure by a component But, and this is the crucial bit here, this should by and large be independent of the build process. So, I'd argue to get this [the build system] right first. |
Beta Was this translation helpful? Give feedback.
-
Actually, the SWIG wrapper (as I have it now) isn't using the library itself, but it recompiles everything statically – in order to eventually supply a shared lib for Python. I think it might even be able to use the existing shared lib to build upon though, it's just that the CMake stuff was easier for me to do that way (I'm absolutely unfamilar with CMake).
That's what many others did in the past (and still do), but I think it's really a crock rather than a solution. You'd have to parse all the messages shown, and unless you implement a kind of pseudo TTY wrapper (as e.g. Arduino does), there's no chance for things like a progress indication that really integrates into that wrapper. All that once eventually got us to the idea of segregating frontend and backend in a clearer manner than it used to be before.
The SWIG wrapper just wraps the list access functions (which came from Brian Dean, and have always been there since the start of AVRDUDE), and just offers a few helper functions (basically typecast), to access things like programmer, parts, or memory regions. That is kind of a compromise between effort (for the wrapper) and not having to add anything to the backend at all. The completely new abstraction library is certainly a good idea, but I wouldn't want to do it without a potential "customer" since I assume it is really quite some effort (and then still requires [some] additional effort for non-C wrappers). |
Beta Was this translation helpful? Give feedback.
-
Another thing, there could be a licensing concerns as well. For those choosing to spawning the For example, AVRDUESS is using GPL. But technically different license can be used. As of now, libavrdude will be covered by GPL without linking exception. Technically speaking, LGPL will be a more suitable license if we want to allow more users to use it. A new library may be able to use LGPL (or GPL with linking exception). As of now, this is a moot point though as there are not well known projects using libarvdude. |
Beta Was this translation helpful? Give feedback.
-
This commit is a typical example: Using the |
Beta Was this translation helpful? Give feedback.
-
Btw., just for a test, I turned the CMake library computation into a shared lib, and I could successfully use that shared lib in the SWIG wrapper from Python. I don't think this is really the way to go right now, but it works. If someone is interested:
|
Beta Was this translation helpful? Give feedback.
-
I just opened a WIP (work in progress) pull request for a SWIG Python wrapper for libavrdude.
I've been toying with that idea all the way back when we started segregating libavrdude from the actual frontend code, years ago. However, I never found enough time to really materialize the idea in any way. Now that there are so many nice developers driving the progress of AVRDUDE (thanks!), I could lean back a bit, and get back to that idea.
I confess: I imagined it would be easier … there's a lot of legwork needed, to wrap everything that would be useful from the Python level. Fortunately, a lot of things are basically opaque stuff that is only required inside libavrdude itself, so it does not need to be wrapped.
Everything is now in a state were I would consider it to be "hello world": config files can be read, the list of AVR devices can be walked, and for each device, the possible memory regions can be examined.
I think SWIG might also benefit a lot from turning as many
#define
s intoenum
literals as possible, as they are typed, and can therefor be wrapped automatically.Any suggestions or even code contributions (to my branch) are welcome!
Beta Was this translation helpful? Give feedback.
All reactions