Article Preview
Buy Now
COLUMN
Port Input/Output
Accessing the hardware ports
Issue: 4.4 (March/April 2006)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software Realbasic Plugins.
Article Description: No description available.
Article Length (in bytes): 6,953
Starting Page Number: 42
Article Number: 4418
Related Web Link(s):
http://www.logix4u.net
Excerpt of article text...
A friend is currently doing REALbasic applications to replace older Turbo Pascal applications. One of the missing things in REALbasic is direct hardware control. In a multitasking operating system, a single application cannot control the hardware itself. All hardware components are taken by the operating system and can only be used through high level functions in case permissions are granted. Still, sometimes your application may need to read one of the hardware ports. This type of port is something like an array. 65536 ports exist and the first has the number 0. You can read and write to a port and the CPU will send the signal around on the motherboard of your PC. One of the components may answer and if so you'll get the value. If no one answers, you may get rubbish.
You can also write to a port to send data to a device. For example, the serial keyboard connector on your PC has a controller chip which answers on port &h060. There you can read the key code of the last key pressed.
The inpout32 library
There is a library to allow normal applications to read and write port values. This library is called inpout32 and can be downloaded from
http://www.logix4u.net . There you will find more details and license information. This library is free for non-commerical use.When the library is loaded, it loads a special kernel mode driver from itself to do the port access. Please be aware that both writing to and reading from the ports can cause hardware problems. You can damage a PC with wrong values! For example, if you increase the refresh rate of the display above the safe range, you can cause damage to the display. If you limit yourself to use only some fixed ports you can be quite safe. Having the user enter the port numbers is a big security risk!
...End of Excerpt. Please purchase the magazine to read the full article.