Making a LCDproc driver Introduction LCDproc is meant to be modular, it is relatively easy to add new input and output drivers to LCDproc. Actually, there are a few things that you can do to make your life easier, they are listed here. This chapter will explain you the major steps and few gotchas of adding your own driver to LCDproc. Enjoy! Shared files specific for drivers Driving an LCD display is not easy; you need to address ports, to send bytes in a certain order, to respect timing, and unfortunaly no two operating system let you do this in the same way. But don't dispair! There's hope! Someone in a galaxy far far away, has allready done the dirty job for you! This dirty job has been put in shared files. These shared files are full cross platform and are automagically configured by the configure script. You only need to include them and use their functions to benefit from them. These files are provided only for drivers, others are provided for all of LCDproc. These files are located in the shared directory, they have a dedicated chapter in this book. port.h : Parallel port I/O The file port.h, located in the server/drivers/ directory provide Input/Output and port permissions for the PC compatible parallel port, also known as the LPT port. Of course, these functions will only work if the computer where LCDproc runs has parallel port! In these situations, the configure script will see this and disable drivers that need a parallel port. port.h file defines 6 static inline functions for port I/O: Read a byte from port static inline int port_in unsigned short int port Returns the content of the byte. Write a char(byte) 'val' to port static inline void port_out unsigned short int port unsigned char val Returns nothing (void). Get access to a specific port static inline int port_access unsigned short int port Returns 0 if successful, -1 if failed. Close access to a specific port static inline int port_deny unsigned short int port Returns 0 if successful, -1 if failed. Get access to multiple sequential ports static inline int port_access_full unsigned short int port unsigned short int count Returns 0 if successful, -1 if failed. Close access to multiple sequential ports static inline int port_deny_full unsigned short int port unsigned short int count Returns 0 if successful, -1 if failed. Example use #include "port.h" /* Get access to these 3 ports: 0x378 (CONTROL), 0x379 (STATUS) and 0x37A (DATA) */ if ( -1 == port_access_multiple(0x378,3) ) { /* Access denied, do something */ } /* Write a 'A' to the control port */ ort_out(0x378, 'A'); /* Read from the status port */ char status = port_in(0x379); /* Close the 3 ports */ port_deny_multiple(0x378,3);