3

I have been assigned a task where I am to emulate one of my company's hardware devices.

I am to use the device firmware written in unmanaged C++ Not necessarily all of the code, but stuff like communication protocols and such is working perfectly in the device and I would like to reuse that code.

I am to write the software primarily in C# .NET 4.

I am having a hard time cracking this nut. At the very least, I would like input on where to start this task.

I know C# very well and I've worked a bit with C++ also.

The firmware runs on a chip in the device, which has a fairly complex operating system. It is kinda hard to explain without showing some code, but I cannot do that.

Anyway, I would happily see some input on this. Also I am not sure if I should write a simulator or an emulator.

The hardware has different interfaces including RS-232, GSM data packets and BlueTooth. The most important is to make the RS-232 and GSM work.

The hardware code is fairly well written, layered and structured, so I guess it is possible to just replace the communication API's with my own code.

TLDN: I am to copy/simulate/emulate the behavior of a hardware device, but it seems a very large project and I am not sure where to start. Input is greatly appreciated. Thank you.

Community
  • 1
  • 1
Søren Lorentzen
  • 868
  • 1
  • 11
  • 26
  • One normally starts at the beginning. Some people start at the end, but then it gets confusing. SCNR. – Tony The Lion Oct 10 '12 at 11:50
  • 4
    Just a thought - did you end up with this task because everyone else has refused it? – Martin James Oct 10 '12 at 11:50
  • @MartinJames No, I ended up with this task because it was assigned to me. :-) – Søren Lorentzen Oct 10 '12 at 11:51
  • In my mind, there is no such thing as refusing a programming task ;-) – Søren Lorentzen Oct 10 '12 at 11:52
  • 1
    God i would fell in love is the project leader assignes the task to me. I love such tasks which are really hard. – Felix K. Oct 10 '12 at 11:52
  • As do I. But this is something I have never coded before :P – Søren Lorentzen Oct 10 '12 at 11:57
  • The best emulators/simulators consist of plugging in an actual hardware device, esp. with a controller with a threaded OS and multiple comms interfaces with varying response times etc. I really do wish you the best of luck with this endeavour, but can't help thinking that this is a task you give someone who you want to resign – Martin James Oct 10 '12 at 13:33
  • @FelixK. - I think you are err.. 'very brave' if you would wish this kind of task. It's a nicely-wrapped parcel, but I can hear it ticking.. – Martin James Oct 10 '12 at 13:35
  • @MartinJames I'm bored by tasks where i see the all the code in front of my eyes and i just need to type it down. This is was actually happens in the most cases and because of the fact that i'm bored i'm starting surfing ( e.h. here on SO ) and finish the task in the last 4 days. So i'm trying to find tasks which are really hard and challenging. – Felix K. Oct 10 '12 at 13:49
  • 'hard and challenging' fine. The only reasonable use I can think of for such a simulator/emulator is to provide a demo version of the host controller ,and even that is fraught with problems: 'Hey - your server worked OK with your simulator - why does it not work correctly with the hardware we just bought for $$$$?'. – Martin James Oct 10 '12 at 14:10

3 Answers3

3

My thought is basically to separate and extract the logic layers of the device, and think about compiling them into executable on your emulating environment. You'll need to do the hardware part and communication part, which are higher and lower levels. Communication part might be easy, just implement the interface and let your emulator user interact with the simulated device. For the hardware device emulating part, if they are general purposed, you can consider using existing project models such as QEMU devices.

In short, the more important work is to know what's the company specific logic and what's common device logic, then you know where to find the code to reuse. After that, glue them together.

admiring_shannon
  • 904
  • 6
  • 16
2

This is going to be completely project-specific. The basic idea is to find the right place to draw the line on each device. You don't want to actually simulate actual RS-232 bits and then have to measure them to get the data back. Generally, for anything you would have to code, use the actual code where possible. But any code that does something you'd just have to undo, don't use. Draw the line at clean interfaces if possible, then just re-implement the code (or hardware) on the "down" side of the line.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278
1

The firmware runs on a chip in the device, which has a fairly complex operating system. It is kinda hard to explain without showing some code, but I cannot do that.

You know how the device works. You know what the output for a given input is. You need to determine what features you need to replicate.

The hardware has different interfaces including RS-232, GSM data packets and BlueTooth. The most important is to make the RS-232 and GSM work.

You start by creating an application that can communicate over the RS-232 and GSM protocols. Once you do this you can use the already written library functions to get the expected output.

Anyway, I would happily see some input on this. Also I am not sure if I should write a simulator or an emulator.

You need to determine what your boss wants exactly. We can't help you make this decision based on the vague requirements you outlined for us.

Security Hound
  • 2,577
  • 3
  • 25
  • 42