C,C++,C#:System programming and Application programming

  • #1
1. Basically, I want to take a piece of hardware and do system programming by using C and C++ computer languages and I want to develop User Interface using C# in .Net framework.
So, what I intend to do is I want to use Visual Studio Integrated Development Environment 2010 and develop user interface using C#.Net and ASP.Net and to make the hardware work I will write C and C++ code in the Visual Studio Integrated Development Environment 2010 where I developed User interface using C#.Net and ASP.Net to go with the hardware.

Is it possible to do things this way? I want to use C and C++ code in C# code in one program that I am developing in Visual Studio Integrated Development Environment 2010.

2. I like .Net because it allows me to use multiple languages only to compile programs to same bytecode called Common Intermediate Language code which is the implementation of Common Language Infrastructure Specification.

Also I want to know if this Common Intermediate Language code is editable and can be run using a different assembler but not Common Language Runtime.

Thank you.
 
Last edited:

Answers and Replies

  • #2
rcgldr
Homework Helper
8,710
538
Assuming .NET requires a windows operating system, what type of hardware are you planning to use this project on?
 
  • #3
Assuming .NET requires a windows operating system, what type of hardware are you planning to use this project on?
I have a build project. It is called "Radio Frequency Controlled Robot with Metal Detection and Image Transmission".
It has:
RF Transmitter STT-433 MHz
Encoder HT640
RF Receiver STR-433 MHz
Decoder HT648L
CMOS 8-bit Microcontroller Atmel AT89S52

It runs on batteries and remote controlled. I want to design a software or user interface that looks something like the following and must be able to run from Windows 7 or Windows 8. I want to write C,C++ code with C# code in Visual Studio IDE.


controlsystem_zps83863642.png
 
Last edited:
  • #4
chiro
Science Advisor
4,790
132
Do you have access to drivers and an Application Programming Interface (API) for the controllers?
 
  • #5
Do you have access to drivers and an Application Programming Interface (API) for the controllers?
No. I want to prepare drivers in C and C++.
Basically, I am planning to write C and C++ code for drivers and build user interface using C# in Visual studio IDE and use the drivers code in C# code in Visual studio IDE. I want to know if it is possible this way.

I somehow want to involve Visual Studio IDE, C# code and C and C++ code, altogether in one place just for the sake of knowing programming.
 
  • #6
chiro
Science Advisor
4,790
132
Well the first thing you will need to do is get a copy of the Driver Development Kit for windows and then learn how to write an appropriate device driver.

Driver development is a real pain in the arse and it will probably drive you insane.

Once you develop the driver then you can write a simple API to access the driver and compile it in a static library to use in Visual Studio.

So you have a few things to do:

1) Get the DDK and learn the standard device driver interface exports and interfaces so that you provide the Windows Kernel with the data structures and code it needs.

2) Get an architecture manual for your piece of hardware and look at how it communicates with the PC with regards to hardware ports, the I/O address of the device, interrupts, and other things like if it uses say a DMA chip or other controllers.

3) Get some tools so that you can write your drivers and debug what is going on with a full output including a stack trace, memory dump, register dump, and an ability to close the session if it screws up.

4) Develop an extremely basic driver with the DDK with a basic I/O interface that app code can use, and then write all the high level code and compile it in a static lib file. You will have to look at the DDK and the Windows SDK for how to do this effectively.

Once you've done all this, you'll be able to start coding.

If you haven't done driver dev before I'd suggest you look at some sample driver code and look for the standard paradigms used. I would not recommend you just develop a driver from scratch at all.

Once you look at the structure of a driver, you'll notice fail-safe paradigms that are used to make sure you get in and out of interrupts A-OK and that nothing corrupts the driver state-space (and that everything updates and is synched ok).
 
  • #7
rcgldr
Homework Helper
8,710
538
Note that device driver development typically involves two computers, the host system, which contains the source code and remote debugger (runs on the host system), and the target system, which contains the driver and local debugger (communicates with host system debugger), and some special hooks in the target operating system, as you're able to setup the initial break at the time the operating system on the target system loads your driver.
 
Last edited:
  • #8
harborsparrow
Gold Member
555
120
C# does allow you to call "native DLL's"--I think there are two different ways to do it. Any good C# book will tell you how to call your C or C++ library from the C# GUI. It can be tricky. Good luck!
 
  • #9
C# does allow you to call "native DLL's"--I think there are two different ways to do it. Any good C# book will tell you how to call your C or C++ library from the C# GUI. It can be tricky. Good luck!
1. Is it possible to use DLL created in C in C++?
2. Is it possible to use DLL created in C++ in C?

I know DLL created in C and C++ can be used in C# because C# is known to be first component oriented language in C/C++ family.
 
  • #10
harborsparrow
Gold Member
555
120
You might be a little bit confused. C is very old (dates back to 1970's). C++ was created in the 1980's, and is a superset of C. Both C and C++ allow you to create reusable, native-executing dynamic link libraries (DLL's). If you create a DLL in C, in should be usable from C++. The other way around is trickier but should mostly work.

C# (.NET) is a more recent language that runs in a virtual machine (a.k.a., "runtime layer"), like Java (C#'s VM is called "the .NET framework"). C# can create .NET DLL's that run on the virtual machine. From within C#, you can also call "native DLL's" (those that were created using C or C++ compilers and compiled to native code), but you call them differently than if you were using a DLL created with C#.

I hope this helps. Whether any C or C++ DLL will run on a given machine depends on the operating system and libraries installed on that machine. Native DLL's are, pure and simply, tied pretty closely to the operating system.
 

Related Threads on C,C++,C#:System programming and Application programming

Replies
3
Views
2K
Replies
2
Views
13K
Replies
1
Views
2K
  • Last Post
Replies
5
Views
3K
  • Last Post
Replies
4
Views
3K
Replies
2
Views
4K
Replies
2
Views
8K
Replies
11
Views
1K
Top