Hi,
I’m integrating a Fez Domino with an RFID reader module. The module uses a proprietary 2 wire serial protocol - so not I2C or SPI - and this has to be implemented through bit-banging two pins.
I’m trying to write an emulator component for it first but I’m stuck. I can’t use the I2C or SPI ports in the emulation, which would be somewhat easier.
How can I communicate from the emulator component back to the firmware? I really don’t want to rewrite the communications protocol on the two pins to emulate the actual hardware and would rather like to use a higher level of abstraction.
My initial idea was to implement an interface in the emulator class that would raise a TagScanned event in the managed driver. The firmware would have the logic to catch this event and handle it. Trouble is I can’t seem to get it right to raise an event from the emulator to be caught by the firmware. The eventhandler types are different between the emulator and the firmware.
Am I missing something obvious? What is the correct way to create emulated hardware abstracted from a port?
I want to write a driver that will raise an event. When running on the real hardware the driver will read RFID and raise this event (TagScanned) for my Controller class to catch and respond. This is a typical MVC pattern. The Controller class runs in the firmware.
When running on the emulator, I want to replace the RFID driver with an emulated driver. When the user presses a button (on the UI form) on the emulator screen, it must raise the same event (TagScanned) and be caught by the Controller class. This simulated RFID component now lives in the Windows Form emulator project and does not care about the two pins that connect to the RFID or the 8 pins that connect to the LCD.
Maybe the problem is that I don’t understand the emulator architecture. I don’t quite see how the emulated components replace the real ones. Please have a look at the diagram and tell me if I’m on the wrong track here.
It is not easy to emulate real hardware in software. I am not saying it is hard to program but it is hard to express.
The easiest way is to not dig in the emulator sources and instead just make a class that look like the one you run the real hardware but instead of the bottom layer using hardware, emulate that anyway you like