Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows Visual-Studio Linux , +
I have to develop an application, which implements an windows API for CAN Device and test a System wich is connected wich and CANUSB with the host PC.
I can use C++ or C#.
The application must be run on both Linux and Windows PC.
 
Questions:
 
Is this possible?
 
Which enviroment can i use for this: Visual Studio or Eclipce CDT?
 
Thank you for your help Smile | :)
Posted 20-Sep-11 21:48pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Absolutely possible. The most smooth way I know is using Mono on Linux.
 
See:
http://en.wikipedia.org/wiki/Mono_%28software%29[^],
http://www.mono-project.com/[^].
 
Mono provides good implementation of CLR and very tight compatibility with .NET. It implements all the standard library and some non-standard ones, importantly System.Windows.Forms, but unfortunately not WPF. I run on Linux all my Forms applications built on Windows, without recompilation. Never faced any problems with Forms starting from the time when .NET version 3.5 was introduced. Also, I recommend to target applications to .NET Framework v.3.5 even now.
 
Now, the cross-platform IDE is available, called MonoDevelop, see:
http://en.wikipedia.org/wiki/MonoDevelop[^],
http://monodevelop.com/[^].
It is available for both Windows and Linux, but you don't have to use it.
 
This IDE is pretty good and it does all it has to, but not as good as Visual Studio. So, I use very little of MonoDevelop, only for debugging of platform-specific codes. In fact, I develop on Windows with Visual Studio even platform-specific non-Windows part of codes; with .NET this is quite possible unless you don't debug it, so I use MonoDevelop mostly for debugging. I also develop on Max OS X these days, where CLR development is much more difficult then in Linux, and still work mostly on Windows and Visual Studio, having to debug the code on other platforms pretty rarely — I manage to get it to work just using Windows.
 
You can also develop using C++/CLI for all the platforms.
 
Such possibilities are really amazing and were never available earlier.
 
Beyond .NET, CLR and Mono, there are other ways to develop cross-platform UI. Unlike CLR, they all require recompilation on each platform. They are based on cross-platform Qt framework (formerly form Trolltech, now supported by Nokia) or GTK+ toolkit, both available on Windows, Linux, Max OS X and other platforms. See:
http://en.wikipedia.org/wiki/Qt_%28framework%29[^],
http://qt.nokia.com/[^],
http://en.wikipedia.org/wiki/GTK[^],
http://www.gtk.org/[^].
 
I'm not really experienced with Qt or GTK+, just minimally tried them out.
 
I listed all the cross-platform UI possibilities involving C++ or C# I know at the moment.
I did not mention Java or Free Pascal because you inquired only on C++ and C#.
 
—SA
  Permalink  
v6
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi, many CAN USB adaptors come with nasty DLLS that you need to 'PInvoke' (like peek/poke). They were not designed for modern languages that use managed code. You have to write/use a 'C# wrapper' to access the DLL. You can NOT add them to your VS2010 and start using them.
When you distribute your application - the user has to install USB hardware drivers, then install DLLs (which fills the windows system directory with all kinds of rubbish), then your application. The application talks to the DLL which talks to the USB driver which talks to the hardware. Yuck.

So.. If you want a solution that uses a very simple USB hardware device driver (from FTDI) and a c# library (instead of the dreaded DLL) that is actually referenced (or linked?) as managed code in your project.. AND is provided in source code form.. And is open source.. And can be compiled as 64bit code.. Then this is the solution you should be looking at
http://sourceforge.net/projects/canusb/
(Note: You will need to take the project from SVN/CVS as the zip file may be old..)
It also happens to be one of the cheapest CAN hardware devices out there..
The library can also be compiled with Mono instead of VS2010
Some keywords:
CAN USB adaptor C# library 64bit CANUSB Managed code .NET library with no DLL nonsense!

I hated working with DLLs.. callbacks from an unmanaged code that bloats the system directory.. that needs permissions to install.. can’t be recompiled and so on..
If you are working with C#, then it’s the right way to do it..
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid