INI Handler gone!
- mwm
- Topic Author
- Offline
After writing the model file switch tweaking stuff, I'm all for this. INI files suck. I had to write an INI file handler for this, because none of the available libraries dealt with the things that deviationTx did in those files. Similarly, I'm thinking about writing an INI file GUI editor, because the ones I can find can't handle what deviation does. Well, except for emacs config mode, but that's not really a GUI editor.
My question is whether or not we can replace the INI files with something for which a standard exists? Preferably one with schema, so that we can get intelligent editors!
After looking at the INI file code, I figured any such parser would have to be larger than what's there. But since we're going to be doing this on the desktop, that shouldn't be an issue. If I'm wrong about that, maybe there's a smaller library for parsing some standard format which would let us avoid going to needing a desktop tool for dealing with model files.
Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.
My remotely piloted vehicle ("drone") is a yacht.
Please Log in or Create an account to join the conversation.
- greenfly
- Offline
Of course some sort of XML format comes to mind, But that may be too much overhead for the little 7E. Then there is JSON, but that may be difficult to hand edit. (All the nested data). Any other ideas?
I think we need to realize that model files are not exactly true INI files. That is one reason they may be difficult to work with. They are similar to an object dump that just happens to look like an INI file. There is a schema for the file in a sense... in the code that read and writes the files. Not that there is anything wrong with this approach.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
yaml would have been my choice, but parsers for it are too complicated, and took up too much room on the tx. The ini parser we use is actually very efficient, but converting it to a schema is complicated, and requires a lot of code.
The new code is a binary dump of the struct. This is both very small in file size (good for the f7) and very small in ROM usage (just a simle RLE compressor)
The downside is that the format changes every time the ABI changes, so each time you install a new firmware, you need to read each binary file, convert it to ini, then reconvert it to the new ABI.
To make that possible, I'm using emscripten, which compiles the deviation ini readers/writers into javascript. I can then load and run that javascript in Java in the deviation-uploader.
It is a really complicated process, and requires that we keep track of the ABI currently on the Tx, so we have a means to decode it. It is made more complicated because we need to know the layout on the STM32 which has different alignment rules than the PC the encoder/decoder run on.
I'm really unhappy with the solution to be honest, but I've been trying to come up with something for over a month now, and this is the 1st solution I found that I can get all the pieces to work. But because it is very complicated, it will probably take quite a while before I have it all working properly (One plus side is that I can now compile the emulator to javascript which means you can run the emulator in a browser (well, almost, the filesystem code is still broken)
Anyhow, I don't think we'll be switching away from ini anytime soon, as the solution I'm using for the 7e is not one I'd want to choose for a more capable Tx.
Please Log in or Create an account to join the conversation.
- greenfly
- Offline
For me, with my lowly 7E, I'm going to miss the hackable nature of the INI file model definition. While it is completely secondary to it's primary purpose (of persisting the model data structure) messing around with the model files is fun.
- I like to tweak the GUI section to take advantage of settings that are not editable on the 7E version.
- I like to view and compare how others have configured their models. Exchanging model files will not be as transparent.
- Some things are just faster and easier to change with a text file
Anyway...
1. Could we dump the structure but still have it be "readable" in some way? Maybe a hybrid with some portion of the file that would still be be readable? Like some kind of "standard" header that would contain Model Name, structure version, etc...
2. If not, could someone be able to leverage your emscripten work to build PC-side model editors? I'm not fluent in any cross-platform languages, but can build anything you need on the Windows side.
I'm new around here and I have not really worked with the code (yet!), so my ideas may be way off base... but maybe they might spark another idea.
Please Log in or Create an account to join the conversation.
- Richard96816
- Offline
- Posts: 208
A small bluetooth dongle for the radio and UI parts of Deviation could be moved to your phone or tablet. A nice pocketable GUI with plenty of resources.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
The Uploader shows you the file system so you can copy files to and from the tx like you do today using USB. The interface is a little different, and it is a lot slower (due to how the bootloader works), but again, it should have parity functionality to what you have now.
As for using an Android, it is already planned, but will require the UniversalTx with bluetooth dongle. I'm not sure that functiality will ever make it to the 7e either. If your Android phone can act as USB master, it is probably possible to port the Deviation Uploader to it, but that is beyond my scope.
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
And yeah, the current INI parser is pretty slim - completely context free. When I realized that, I gave up on replacing it with something that might be smaller. JSON, YAML, etc. keep the context around. They would more directly correspond to to the structures in the program, but that requires keeping around a lot of state during the process.
As for deviation not using "TRUE" INI files - exactly what does that mean? What sucks about INI files is that there is no standard. No definition about what characters are valid in names, when and where comments can appear, or how often sections and options can appear, etc. The latter is what killed all the extant Haskell libraries - they all turned the thing into a map of maps. There's no provision in them (or INI in general) for lists of things, so deviation using repeated entries to handle lists made them unusable.
I don't think deviation does anything that some other program doesn't do. It may be unique in the set of oddball things it does - but I suspect that's true of a lot of programs that use INI files in oddball ways.
Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.
My remotely piloted vehicle ("drone") is a yacht.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
1) we have multiple copies of the same section which are each processed separately (mixer definitions). A standard ini file will only use each section header once. I could have gotten around that by numbering the mixers in the ini, but there really wasn't much reason to and the numbers wouldn't mean anything since we recompact the mixers after load.
2) we depend on the order of the sections (channel, then the associated mixer) in order to effectively add extra hierarchy to the ini file.
3) we depend on the order that items appear in the section (I don't recall where but I'm pretty sure we still do). items within a section should be independent ideally.
All of the above are covered as exceptions in the wiki .
basically an ini would ideally represent a 2 level unordered hash structure:
section =>
key =>value
key =>value
key =>value
section =>
key =>value
key =>value
Please Log in or Create an account to join the conversation.
- greenfly
- Offline
PhracturedBlue wrote: We do 3 things that are non-standard:...
Thanks PB for clarifying what I meant about the INI files. I used to be a big user of the old Windows API and GetPrivateProfileString...
So the model files will reside on the TX in binary files and we will have to use the Java Uploader to move INI-based model files to and from the TX. OK, I see now.
Is there anything that I can help with? Testing? Documentation? Should I learn Java?
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
The thing is that the only "standard" is the behavior of some library. Since it's an MS library, it only runs on windows, so "some library" will vary with your platform and language. Since it's largely used for configuration information for a program and not data exchange, there's no real need for a standard. Except we now want to swap files with desktop programs. Maybe we need a C library for use with an FFI.
Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.
My remotely piloted vehicle ("drone") is a yacht.
Please Log in or Create an account to join the conversation.
- Richard96816
- Offline
- Posts: 208
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
The code to convert the ini to/from a C-structure can easily be extracted and run on the PC. You can either do it in C or now you can do it via javascript as well (just look at the sdl2 branch for code to do this).
So getting the ini into a machine parseable structure is easy. I'm not sure what you want to do with it from there, but the ini file shouldn't be a limitation
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
Given that you can count the number of people writing code to work with them on the fingers of one hand even if you've lost fingers in a helicopter accident, it's clearly not gong to be a priority.
Butt if we're going to have to break what's on the Tx even if just for the 7e, that would be the time to do it.
Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.
My remotely piloted vehicle ("drone") is a yacht.
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
And what about JSON? That should be simpler. And poking around, I can find online editors, including some that use schemas, for it. Like exavolt.github.io/onde/ and www.jsoneditoronline.org/ . I suspect that means that there are desktop editors as well, and probably similar for YAML as well.
Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.
My remotely piloted vehicle ("drone") is a yacht.
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Development
- INI Handler gone!