Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Feb 22, 2013 #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: Feb 22, 2013
  2. jcsd
  3. Feb 22, 2013 #2

    rcgldr

    User Avatar
    Homework Helper

    Assuming .NET requires a windows operating system, what type of hardware are you planning to use this project on?
     
  4. Feb 22, 2013 #3
    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: Feb 22, 2013
  5. Feb 22, 2013 #4

    chiro

    User Avatar
    Science Advisor

    Do you have access to drivers and an Application Programming Interface (API) for the controllers?
     
  6. Feb 22, 2013 #5
    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.
     
  7. Feb 22, 2013 #6

    chiro

    User Avatar
    Science Advisor

    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).
     
  8. Feb 22, 2013 #7

    rcgldr

    User Avatar
    Homework Helper

    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: Feb 22, 2013
  9. Mar 6, 2013 #8

    harborsparrow

    User Avatar
    Gold Member

    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!
     
  10. Mar 23, 2013 #9
    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.
     
  11. Mar 23, 2013 #10

    harborsparrow

    User Avatar
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: C,C++,C#:System programming and Application programming
  1. C Program (Replies: 3)

  2. C program (Replies: 0)

  3. C programming (Replies: 9)

Loading...