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

In summary: Basically, you need a driver development kit (DDK), an architecture manual for your hardware, some tools to write your drivers, and a breakpoint at the time the operating system on the target system loads your code.
  • #1
pairofstrings
411
7
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 Langauge code which is the implementation of Common Langauge Infrastructure Specification.

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

Thank you.
 
Last edited:
Technology news on Phys.org
  • #2
Assuming .NET requires a windows operating system, what type of hardware are you planning to use this project on?
 
  • #3
rcgldr said:
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
Do you have access to drivers and an Application Programming Interface (API) for the controllers?
 
  • #5
chiro said:
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
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
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
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
harborsparrow said:
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
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.
 

What is the difference between system programming and application programming?

System programming refers to the creation of low-level software that interacts directly with hardware and the operating system, such as drivers and kernels. Application programming, on the other hand, involves creating software that runs on top of the operating system and is used to perform specific tasks or functions.

What is the role of C, C++, and C# in system programming and application programming?

C, C++, and C# are all programming languages commonly used in system programming and application programming. C is often used in system programming due to its low-level nature and efficiency in working with hardware. C++ is often used in application programming due to its object-oriented design and ability to handle larger, more complex software projects. C# is a high-level language that is commonly used in application programming, particularly for creating Windows-based applications.

What are the advantages of system programming and application programming?

System programming allows for direct control and access to hardware, making it more efficient and customizable. Application programming allows for the creation of user-friendly and visually appealing software that can perform specific tasks or functions.

What are some common applications of system programming?

Some common applications of system programming include operating systems, device drivers, and embedded systems. These types of software directly interact with hardware and are essential for the functioning of computers and other electronic devices.

What are some common applications of application programming?

Common applications of application programming include web development, mobile app development, video game development, and business software. These types of software are designed for specific purposes and are used by users to perform tasks or access information.

Similar threads

  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
29
Views
2K
  • Programming and Computer Science
Replies
8
Views
866
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
2
Views
280
  • Programming and Computer Science
Replies
9
Views
1K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top