Hi everyone,

I saw that recently a new Configurator source code appeared in the arducopter svn repo. It seems to be written in C#. For me the main flaw with the original configurator was that I couldn't run it on linux (ubuntu 10.10) , and I had to reboot in windows (which I never use)  every time I wanted to use the configurator. So when I saw the new code I though "maybe I could use it on linux with mono". So I installed monodevelop and I built the configurator. There was no error (only a warning), but when I launch ArducopterConfigurator, I can only see a windows for a few miliseconds, then I get this message in the terminal: 

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: '0' is not a valid value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'
Parameter name: Value
at System.Windows.Forms.ProgressBar.set_Value (Int32 value) [0x00000] in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in :0
at System.ComponentModel.ReflectionPropertyDescriptor.SetValue (System.Object component, System.Object value) [0x00000] in :0


I tried to determine where the exception was coming from with the debugger, but I couldn't find it.

So here are my questions:
-Is the current code actually working on a windows environment ? ( I guess it is)
-Is this error releated to the code or to my mono environment ?
-Did someone manage to make this code work on linux ?
-Where can I find more informations about this version of the configurator ? I couldn't find any in the wiki.

Sorry if this is not the right place to talk about it, but I thought this category was the most appropriate.
Thank you for your answers.

Views: 226

Reply to This

Replies to This Discussion

Hi there,

 

I'm the guy working on this - the short answer is that you are probably the first person to try running it on Mono, so I'm not surprised that it's not going 100%

 

I've intentionally written it using the older .Net framework 2.0 & winforms, so it has a chance of working on Mono (as opposed to using say WPF which is not supported)

 

It is still a work in progress so although it does kind of work, it's not ready for release just yet.

 

I don't have a handy Mono/Linux install so if you like I will consider you volunteering to be the Mono testing guy ;-)

 

Andrew

Well, I've tested a few things since my last post:

- I ran on windows the .exe I built with linux: it's running fine. I could connect to the arducopter (the orange Tx led blinked as if the regular Configurator was connected), but I couldn't see any gyro or accelero data updating: every progress bar remained at zero. I don't know if this is the expected behavior.

 

-To be sure it wasn't a mono build issue, I sent the code to a friend who has Visual Studio,and he sent me back the .exe. The .exe built with VS2010 behaves exactly the same way as the one buit by mono: same behavior on windows, same error on linux. So it's not a compiler issue. I guess it's a bug in the mono runtime, but I'm not a .NET expert, so I can't be sure.

 

-After a few tries, I could locate the origin of the problem (well, nearly ..).

As the 2nd line of the error message mentions a value ( 0 ) which is not between the Minimum and Maximum values, and the 4th mentions a "ProgressBar", I changed, for every ProgressBar, the Minimum value from 1000 to 0. Then I could launch the program and see the window (no more exception). Of course this is not a solution, but it shows where the problem is.

With this little "hack" I could even connect to my arducopter, specifing /dev/ttyUSB0 as the serial port, but there was another problem: the tabs were still "frozen", I could not change the active tab, as if the serial port was still disconnected. I guess this is another mono bug, I'll try to investigate further into that.

 

I am by no means a mono/.NET/C# expert, I'm just interested in a linux version of the Configurator. I am volunteer to test a few versions, but only during the holidays, because when school comes back ( Jan 3rd :( ) I will be way too busy to contribute to anything :( .

 

Continue your good work anyway, I'm sure I'm not the only one who might be interested in a cross-platform configurator. Maybe it could run on Mac OS too ?

 

PS: sorry if my english isn't good, it's not my native laguage and it's late here ;-)

Hi Andrew,

 

Andrew the design approach you use is MV-C or MV-P. I am still guessing. :)

 

Lim

It's more like MV-V-M, but I suppose the model resides on the APM. The only thing close to a Controller would be the Main VM, which has the Tab control for switching modes, and the comm port selection etc.

 

It would be a trivial exercise to use a WPF UI, the current view layer is winforms so we can use Mono, however I did not want to rule out a WPF layer also (its muuuuch nicer) hence the MVVM and binding. Makes writing test code a lot easier also. 

I'm hoping to get it running on Mono so I'll see how I go.
I am now using C# Express 2010. Manage to compile n run without error.

I did try it with the latest Mono on windows. Was looking good until I hit a block - the BindingSource implementation on Mono is broken. It does not subscribe to INotifyPropertyChanged events when binding to an object. It's a known bug but I don't know when it will be fixed.

In the mean time, the binding scenario is so simple in this app at the moment, that a workaround could be a custom implementation that will use INPC for binding properties.

After that the next guy likely to cause trouble is the SerialPort

 

BTW I had to up the project target framework to 3.5 to support C# 3.0 for Mono Develop.  

 

I just tried it on windows and it worked fine, even using the serial port. It didn't work on linux though, but I think my linux install might be broken.
oops, I ran it by accident using MS.NET rather than Mono. No wonder it worked...

Ok here's an update:

 

I've potentially worked around the BindingSource issue with an ugly hack that forces all the bindings to refresh when any one property changes - hack not needed or used on MS .Net.

 

The 'indicators' which were winform ProgressBars I had to chuck because Aero theme on windows tried to 'smooth' the progress with a slow animation, and also Mono did not respect the well known hack to get them to be vertical. Instead, I've made some crude indicators that are drawn manually, however they work on Mono just fine and of course can be developed to have e.g. high watermarks, integrated value text etc

 

At this point I can run it on Mono on windows, and there is just one problem remaining, that is the Mono (win32) implementation of the SerialPort seems to be 'zeroing' the first character of the received sentence for some reason. Interestingly, it doesn't seem to happen with the continuous stream of data like with the flight data. So I'm not sure where the fix needs to be or a clever work around.

 

You can now open the solution in Monodevelop, and run it. I've not tried this on *nix though, only windows. It could be that it actually works on linux at the moment, because the Mono implementation of the SerialPort would be different than for windows. I don't have a linux platform to try it.

I can confirm that it works in Linux using Ubuntu. All serial ports were detected, and the bug with the null characters didn't happen so that must be a windows thing. I'll try it on osx when I get time.

 

Good work!

Ahh excellent. I guess we can disregard Mono/Win32 as a valid configuration anyway.

 

 

RSS

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service