Wish List (generally ignored ;-), Brainstorming
Post Reply
morgwai
Posts: 8
Joined: 17 Nov 2007, 04:12
Contact:

introducing more structure to the config file

Post by morgwai » 14 Nov 2008, 01:25

Hi,

What really annoys me in modeswitch is the fact that I either have to edit config file everytime I change the device or I have to have multiple config files (one per device and select it with -c option).

I was thinking about possibility of having multiple configurations in one file labeled somehow so I can specify using some command line option which to use. For example either windows ini file format could be used or xml for config file. As xml parsers are quite heavyweight the first option seems better.

Let me provide a basic example:
assuming the following config file:

Code: Select all

[config1]

DefaultVendor=  0x05c6
DefaultProduct= 0x1000
TargetVendor=   0x0af0
TargetProduct=  0x6600
MessageEndpoint=0x05
MessageContent="55534243123456780000000000000601000000000000000000000000000000"

[config2]

DefaultVendor=  0x05c6
DefaultProduct= 0x1000
TargetVendor=   0x0af0
TargetProduct=  0x6901
MessageEndpoint=0x05
MessageContent="55534243123456780000000000000601000000000000000000000000000000"
I could issue

Code: Select all

# usb_modeswitch -L config1
to use the first configuration and similarly for config2.

To make it backward compatible program would use first found configuration if no -L flag is provided.

What do you think?

Thanks

Morg

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 16 Nov 2008, 00:47

To be honest, I'm hesitating to support that idea.

I think it would open up all kinds of possibilities for errors if lines are not properly commented in or out.
If I would try and catch all these possible errors it would add to overall complexity, and I am - by instinct and experience - not comfortable with that. And the vast majority of users will never need to switch more than one device.

If I were in your situtation I'd stick with the multiple config file solution. I can organize them in any way I want and instead of saying "usb_modeswitch -L config1" for example issue "usb_modeswitch -c /etc/config1"; is that really less convenient? To change or add devices I'd have to edit the files anyway.

Of course I'd scrap all those comments and other devices from the files in the way you did it.

morgwai
Posts: 8
Joined: 17 Nov 2007, 04:12
Contact:

Post by morgwai » 18 Nov 2008, 20:25

So the idea behind it is that most users won't have to edit config file at all (they would only use -L cmd line flag). This would probably decrease the actual number of errors caused by wrong config file.

Also it would significantly ease up packaging for general purpose distributions. In current situation I would have to include all these config files for all devices.

What's on my mind is to build configuration tool over usb_modeswitch that would allow picking device from the list ;) It is of course possible to build it with current config schema, but the modification I proposed would make it a bit easier.

Please let me know if this convinces you.

Thanks

Morg

Post Reply