Hi,
Maybe you don't need to know how to write drivers. If I understand well you need somthing to simulate device. Have you tried adding another layer of abstraction?
Add an interface:
interface IParallelPort
{
void Output(int address, int value);
int Input(int address);
}
When device is plugged implement it the normal way
class RealPort : IParallelPort
{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
private static extern void Out32(int address, int value);
[DllImport("inpout32.dll", EntryPoint = "Inp32")]
private static extern int Inp32(int address);
void IParallelPort.Output(int address, int value)
{
Out32(address, value);
}
int IParallelPort.Input(int address)
{
return Inp32(address);
}
}
For testing use fake class:
class FakePort : IParallelPort
{
void IParallelPort.Output(int address, int value)
{
}
int IParallelPort.Input(int address)
{
}
}
Use factory method to switch between those two ports.
Hope it helps.