Search code examples
operating-systemdriverhardwaremodbus

Adress external Hardware directly without driver?


Is it possible to access external hardware without using a driver, i.e. not having the driver abstraction layer in between program and external device?

Can you use a device by implementing your own driver-like controlling/handling directly in your program code?

I'm trying to understand a program that implements a Modbus protocol and some very specific Modbus configurations. Now I don't know how exactly it communicates with the Modbus devices. It looks to me that this is very similar to what a driver does.

But can it even communicate DIRECTLY with the device without having a driver installed?


Solution

  • Yes, there are several micro-kernel OS's that always configure this way -- drivers are entirely implemented outside of the kernel. The first thing you likely need is to get access to the device's registers; typically performed with mmap(), you may need to dig around a bit to find the right settings for cacheability, etc... Second problem is interrupts. Unless you are running something like QNX, you won't have a way to have interrupts signal your program directly. You will probably have to turn them off and poll the device periodically.

    If you are using linux and need io ports (inb, outb, etc...) man ioperm for more information.