Text based MultiWiiConf-like tool for the command line

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Text based MultiWiiConf-like tool for the command line

Post by phenolic »

This is a command line text based tool for configuring MultiWii. It also provides a full scripting environment for whatever fancy future use. I needed this because MultiWiiConf wouldn't run at all on my old laptop and on my newer laptop it was really slow and too fat. :P I also wanted a way to save and restore my PID settings that MultiWii keeps erasing when I load different versions and I wanted to be able to very accurately set my PID settings where the GUI has problems getting it right every time.

I just started working on this and it's currently in a very alpha state but it works. Source code is available on the project page and binaries are available that run on Linux, OS X, and Windows. Most have no dependencies on external libraries or anything, simply run it. :)

As a quick test/intro you can run:

Code: Select all

open("COM7")
ident()
pid()
box()


Substitute COM7 for your serial port or use something like /dev/ttyUSB0 on Linux.

I'm working on the documentation. help() will show a list of commands and help("commandname") will display help for that command. The commands consist of basically all the MSP_* commands in MultiWii and other functionality. It has some initial support for my Arduino USB Linker project.

MultiWiiCL downloads and link to project page.

Donations are accepted if you feel the desire.

To be continued
Attachments
multiwiicl-linux.png
multiwiicl-winxp.png
Last edited by phenolic on Tue Mar 26, 2013 9:53 pm, edited 12 times in total.

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: MultiWiiConf command line

Post by phenolic »

{placeholder}

sismeiro
Posts: 173
Joined: Tue Feb 21, 2012 12:33 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by sismeiro »

Hi,

Thanks for you text mode MultiWiiConf. It's always good to have alternatives specially when java plays tricks with us. The scripting capability is always a nice to have.

Regards,
Luis Sismeiro

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

Very cool tool (it looks that way)!
Any chance to get it on/for OSX (basically same as Linux regarding GCC, Perl, Python, Bash... /dev/tty.SOMETHING...)?

Best Regards
Andrej

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

It should work on OSX as well. I will have to see if I can bring my OSX development environment back to a running state.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by copterrichie »

Love it, that is the great thing about DIY, you can customize things to personal choice. :)

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

I added a binary for OSX. My serial port was acting really strange in OSX. I think it's my hardware but I'm not sure. It was working though.

It's not a static binary although it only has two dependencies on system libraries. Might have issues if you're not on Mountain Lion but I don't know.

I can't test very well on OSX so I feedback is needed. :)

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

For me it does not work!

#uname -a
Darwin hostname 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

#ls /dev/ | grep "tty\."
tty.Bluetooth-Modem
tty.Bluetooth-PDA-Sync
tty.MWI_AJ2-DevB
tty.MultyWii-DevB
tty.usbserial-A700eEeB

#./MultiWiiCL
Segmentation fault: 11

Best Regards
Andrej

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

crashlander wrote:For me it does not work!


Thanks for the test. Sorry it didn't work. :( Looks like you're using Lion and the binary is for Mountain Lion. Unfortunately OSX doesn't support static binaries so this is the kind of issue that will need to be worked on.

I put up a new OSX build that might be targeted to OSX 10.6 and up. Maybe that will work. I'll see if I can get an older system running myself so I can test.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

Hello,
now I'm getting new error:

> open("/dev/tty.usbserial-A700eEeB")
MultiWii:501: Ident failed
> pid()
MultiWii:170: Serial port is not open
> open("/dev/tty.usbserial-A700eEeB")
MultiWii:501: Ident failed
>

But I'm running PatrikE AirplaneRTH code....

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

OK, at least it's running. That could be related to the weird serial port behaviour I was seeing. I'm assuming "/dev/tty.usbserial-A700eEeB" actually is the correct port?

What happens if you run MultiWiiCL then do this:

Code: Select all

open("/dev/tty.usbserial-A700eEeB", true)  -- this skips the ident check

Then leave MultiWiiCL running and in another terminal run:

Code: Select all

stty -f /dev/tty.usbserial-A700eEeB

What is the stty output? Specifically I'm interested to see if the baud rate is the correct 115200.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

Interesting it works when run with true option:

Code: Select all

$MultiWiiCL
MultiWii Command Line 0.0.3  Copyright (C) 2013 Chris Osgood
Type help() to get started
> open("/dev/tty.usbserial-A700eEeB",true)
> pid()
        ROLL   P=3.3, I=0.030, D=023
       PITCH   P=3.3, I=0.030, D=023
         YAW   P=6.8, I=0.045, D=000
         ALT   P=6.4, I=0.025, D=024
         Pos   P=1.1, I=0.000, D=000
        PosR   P=2.0, I=0.008, D=045
        NavR   P=1.4, I=0.020, D=080
       LEVEL   P=9.0, I=0.010, D=100
         MAG   P=4.0, I=0.000, D=000
         VEL   P=0.0, I=0.000, D=000
> ident()
{capability=0,msp_version=0,version=220,multitype=3}
> quit()
$ ./MultiWiiCL
MultiWii Command Line 0.0.3  Copyright (C) 2013 Chris Osgood
Type help() to get started
> open("/dev/tty.usbserial-A700eEeB")
MultiWii:501: Ident failed
> open("/dev/tty.usbserial-A700eEeB",true)
> ident()
{capability=0,msp_version=0,version=220,multitype=3}
> pid()
        ROLL   P=3.3, I=0.030, D=023
       PITCH   P=3.3, I=0.030, D=023
         YAW   P=6.8, I=0.045, D=000
         ALT   P=6.4, I=0.025, D=024
         Pos   P=1.1, I=0.000, D=000
        PosR   P=2.0, I=0.008, D=045
        NavR   P=1.4, I=0.020, D=080
       LEVEL   P=9.0, I=0.010, D=100
         MAG   P=4.0, I=0.000, D=000
         VEL   P=0.0, I=0.000, D=000
>


And stty output

Code: Select all

#stty -f /dev/tty.usbserial-A700eEeB
speed 115200 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb clocal
min     
0       


Regards
Andrej

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

crashlander wrote:Interesting it works when run with true option:


Great! I probably just need to make the initial exchange more robust, which shouldn't be too hard.

Thanks for testing it :)

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Text based MultiWiiConf-like tool for the command line

Post by Hamburger »

Interesting - what licence, where is the source?

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Hamburger wrote:Interesting - what licence, where is the source?


No source yet, I haven't decided on a license. This tool is not based on any previous code.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Text based MultiWiiConf-like tool for the command line

Post by Hamburger »

In the MWii world, if it is not open source with a suitable licence, for me it does not exist.
Ymmv

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Hamburger wrote:In the MWii world, if it is not open source with a suitable licence, for me it does not exist.
Ymmv


I never said it wouldn't be open source. All my stuff has been open source. ;)

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

I pushed a new version for all platforms. I'm starting to refine some of the details like converting flags to human readable text and such.

The serial port might work better on OSX but it's hard for me to tell on my half working system.

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Well it runs on Android but there doesn't appear to be any way to get to a serial port from the NDK. Who designs this stuff. :D :roll:

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by copterrichie »

phenolic wrote:Well it runs on Android but there doesn't appear to be any way to get to a serial port from the NDK. Who designs this stuff. :D :roll:


An Android with Bluetooth maybe.

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

That's what I mean, there is no way to access the bluetooth stuff from the NDK, it's Java only. :( I believe all devices have some sort of bluetooth library but it can be different for every device so not that useful to use directly. Not sure why they didn't just use a normal bluetooth kernel module.

User avatar
ezio
Posts: 827
Joined: Sun Apr 01, 2012 11:03 pm
Location: Paris
Contact:

Odp: Text based MultiWiiConf-like tool for the command line

Post by ezio »

Hamburger wrote:In the MWii world, if it is not open source with a suitable licence, for me it does not exist.
Ymmv

And it starts again.
When I started to write my app everybody wanted it as open source. But since then nobody has put a single line of code. so what is the point ?

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Odp: Text based MultiWiiConf-like tool for the command l

Post by Hamburger »

ezio wrote:
Hamburger wrote:In the MWii world, if it is not open source with a suitable licence, for me it does not exist.
Ymmv

And it starts again.
When I started to write my app everybody wanted it as open source. But since then nobody has put a single line of code. so what is the point ?

So long as you keep fulfilling all users' requests at that high pace, it may simply not be neccessary :) I am sure there's others (like Sebbi) who have had a thorough look over of your code if possible. The above stated is my position. Other users may choose differently. Some of my reasons (you sure know already)

+ avoid sneaking in of closed source into the open source ecosystem of MWii. It is just so nice to have access to everything and not become dependant on something closed.
+ chance to survive once the original author decides to abandon project
+ avoid lockout through later change in usage terms
+ possible access, participation, spin-offs
+ see and learn
+ quality

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Those are the same reasons I prefer open source as well. I mean this is a hobby, everyone should be able to hack on everything.

fiendie
Posts: 151
Joined: Fri Apr 20, 2012 4:22 pm

Re: Odp: Text based MultiWiiConf-like tool for the command l

Post by fiendie »

Hamburger wrote:
ezio wrote:
Hamburger wrote:In the MWii world, if it is not open source with a suitable licence, for me it does not exist.
Ymmv

And it starts again.
When I started to write my app everybody wanted it as open source. But since then nobody has put a single line of code. so what is the point ?

So long as you keep fulfilling all users' requests at that high pace, it may simply not be neccessary :) I am sure there's others (like Sebbi) who have had a thorough look over of your code if possible. The above stated is my position. Other users may choose differently. Some of my reasons (you sure know already)

+ avoid sneaking in of closed source into the open source ecosystem of MWii. It is just so nice to have access to everything and not become dependant on something closed.
+ chance to survive once the original author decides to abandon project
+ avoid lockout through later change in usage terms
+ possible access, participation, spin-offs
+ see and learn
+ quality

Agreeing with Hamburger here.
If you want to write closed source software, don't piggy-back an open source project ;)
Of course there is a more polite way to say this especially to someone with phenolic's track record.

@ezio
Not everything pays off immediately but only now others have the chance to contribute something in the first place.
And even if nobody does you should be feeling good about having done the right thing (tm) ;)

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Text based MultiWiiConf-like tool for the command line

Post by Hamburger »

phenolic wrote:Those are the same reasons I prefer open source as well. I mean this is a hobby, everyone should be able to hack on everything.

thank you

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

Hello!
Any option to change default baud rate?
I would like to run it over APC220 that can push 19200bps max.

Regards
Andrej

BTW: You mentioned option for scripting! Is it possible to run it from CMD- line in non-interactive mode with parameters eg.

Code: Select all

$MultiWiiCL rc


EDIT: I find out option to execute chunk but...

Code: Select all

./MultiWiiCL -e 'open("/dev/tty.usbmodem621",true) rc()'
./MultiWiiCL: MultiWii:293: No response or invalid response
stack traceback:
   [C]: in function 'error'
   MultiWii:293: in function 'sendCmd'
   MultiWii:742: in function 'rc'
   (command line):1: in main chunk
   [C]: at 0x0100001260


EDIT2: Talking to myself... :) ...and using Lua sleep it works now, but still missing baud rate setup.

Code: Select all

./MultiWiiCL -e 'open("/dev/tty.usbmodem621",true); os.execute("sleep 8") ; rc()'
{1500,1500,1500,1500,1500,1500,1500,1500}

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Try:

Code: Select all

open("/dev/tty.usbmodem621",true, 19200)


There is a built in sleep function but it's currently kind of hard to get to. Try luaserial.sleep(milliseconds). In the next version I'm thinking that will be a global "sleep" function.

There is probably no reason to use the sleep if you don't skip the ident. It's fairly robust and will retry several times. So maybe just:

Code: Select all

open("/dev/tty.usbmodem621",false, 19200)
rc()



You can also run scripts from a file. Like 'MultiWiiCL <filename>'.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

Nope...

Code: Select all

open("/dev/tty.SLAB_USBtoUART",true,19200)
> rc()
MultiWii:293: No response or invalid response


and than

Code: Select all

tty -f /dev/tty.SLAB_USBtoUART 
speed 115200 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb clocal
min     
0


And in my case ident right after connect (included in open) still doesn't work that is why I must include at least 6 seconds delay to get it working (over USB connection).
Regards Andrej

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Edit:
I'll make a 0.0.5 version later than fixes that and maybe makes the initial open ident better. I forgot that I have been using changes since 0.0.4 that fix some of that.
Last edited by phenolic on Fri Mar 22, 2013 11:53 am, edited 2 times in total.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Text based MultiWiiConf-like tool for the command line

Post by crashlander »

Yep... on MacOSX 10.7

Code: Select all

MultiWii Command Line 0.0.4  Copyright (C) 2013 Chris Osgood


EDIT: I can force speed with outside program and than it works

Code: Select all

stty -f /dev/tty.SLAB_USBtoUART speed 19200

Peter
Posts: 82
Joined: Mon Jun 11, 2012 2:09 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by Peter »

Looks promising! Please remember the last serial port in a config file. So that you only have to call open.
And/or add a commandline parameter like --port /dev/ttyUSB0.

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Peter wrote:Looks promising! Please remember the last serial port in a config file. So that you only have to call open.
And/or add a commandline parameter like --port /dev/ttyUSB0.


Yes as a user of the tool I want that feature too. It's coming in the next version hopefully. :)

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Released version 0.0.5. Pushed source code. Moved binary releases to another page since GitHub no longer supports these.

This version has serial port handling changes (better on OS X?) and various other low level improvements. I added limited support for tab completion of commands (might expand on this later). It also now remembers your "open" settings between sessions and will reuse those if a simple "open()" with no parameters is issued.

Next version will have an option to "open" automatically on startup.

benedikt
Posts: 11
Joined: Thu Sep 05, 2013 12:37 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by benedikt »

Configuration of my quads via scripts? Sounds great!

Im trying to connect to a HobbyKing Pocket Quad running MultiWii 2.3.
Im getting this:

Code: Select all

WARNING: unsupported version of MultiWii detected


So I checked the MultiWiiCL source code (thanks for being open source!) and found the version check:

Code: Select all

            if version < 210 or version > 229 then
               print("WARNING: unsupported version of MultiWii detected")
            end


MW 2.3 has version code 230. The quickest way to pass this test was to reconfigure my firmware to report a different version number.
And.. I can connect:

Code: Select all

> open '/dev/tty.usbmodem1a1321'
> ident()
{msp_version=0,capability=BIND_CAPABLE,version=228,multitype=QUADX}
> box()
               AUX1     AUX2     AUX3     AUX4
               L M H    L M H    L M H    L M H
         nil   MultiWii:897: bad argument #1 to 'band' (number expected, got string)


Didnt test any further yet, but it looks indeed unsupported :?

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

Yes, I have a queue of project updates I have been working through. Eventually I'll get to this one.

Some things might work fine depending on if any serial commands were changed between version 2.29 and 2.30. The warning doesn't affect any functionality but yes it looks like an error there, something must have changed with the boxes. I will have to look at it at some point.

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

I just tried the latest 2.30 version and it seems to work (so far) but maybe there is a bug or something depending on the config or settings.

Can you send me your config.h? Also, what is your box configuration?

benedikt
Posts: 11
Joined: Thu Sep 05, 2013 12:37 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by benedikt »

thanks for looking into this!
I attached a screenshot of my settings, and the config.h (renamed to .zip because the forum doesnt accept .h or .txt)

and here is the output of pid():

Code: Select all

> pid()
MultiWii:871: attempt to index local 'v' (a number value)
>
Attachments
config.h.zip
(64.98 KiB) Downloaded 137 times
Screen Shot 2013-11-24 at 12.15.08 pm.png

User avatar
phenolic
Posts: 81
Joined: Fri Sep 21, 2012 10:31 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by phenolic »

benedikt wrote:thanks for looking into this!
I attached a screenshot of my settings, and the config.h (renamed to .zip because the forum doesnt accept .h or .txt)


Thanks!

What version of MultiWii are you using? I have not been able to compile any version I have with that config. I tried the latest from subversion and the official MultiWii 2.3. I notice in the GUI config it says protocol version 228 which doesn't seem to match what MultiWiiCL returned. :?

benedikt
Posts: 11
Joined: Thu Sep 05, 2013 12:37 pm

Re: Text based MultiWiiConf-like tool for the command line

Post by benedikt »

sorry, the 228 comes from me cheating the system..
This is MW 2.3, I just changed the version info to pass your version check.
It is a customized version for the HK Pocket Quad, I got from here: http://www.rcgroups.com/forums/member.php?u=302980

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Text based MultiWiiConf-like tool for the command line

Post by Hamburger »

not sure if it fits your requirements, but for a text based interface to configure MWii, you could enable LCD_TTY (or LCD_VT100) and LCD_CONFIG and run a terminal program against the serial port. Navigation is done either with your tx sticks or computer's keys.
Not ment to be fancy at all, but almost always up to date, because the logic of what to display is part of MWii - only the displaying portion is left to the terminal program.

Post Reply