/////////////////////////////// // ModLapLinkInterface2.h // Nate Jenkins /////////////////////////////// #ifndef _MODLAPLINKINTERFACE2_H_ #define _MODLAPLINKINTERFACE2_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include // For console printing control in respective functions #define DEBUG_GETPORT #define DEBUG_RELEASEPORT // Bit Help Defs #define __BIT__7 0x80 #define __BIT__6 0x40 #define __BIT__5 0x20 #define __BIT__4 0x10 #define __BIT__3 0x08 #define __BIT__2 0x04 #define __BIT__1 0x02 #define __BIT__0 0x01 #define BIT7(e) ( (__BIT__7 & e) ? 1 : 0 ) #define BIT6(e) ( (__BIT__6 & e) ? 1 : 0 ) #define BIT5(e) ( (__BIT__5 & e) ? 1 : 0 ) #define BIT4(e) ( (__BIT__4 & e) ? 1 : 0 ) #define BIT3(e) ( (__BIT__3 & e) ? 1 : 0 ) #define BIT2(e) ( (__BIT__2 & e) ? 1 : 0 ) #define BIT1(e) ( (__BIT__1 & e) ? 1 : 0 ) #define BIT0(e) ( (__BIT__0 & e) ? 1 : 0 ) #define NIBBLE3(s) ((s>>12)&0x0F) #define NIBBLE2(s) ((s>> 8)&0x0F) #define NIBBLE1(s) ((s>> 4)&0x0F) #define NIBBLE0(s) ((s )&0x0F) // Possible Error Codes #define ERRORBASE 1400 #define NOERRORS 1401 #define NOPORT 1402 #define ALREADYHAVEPORT 1403 #define WILLNOTOPEN 1404 #define WILNOTCLAIM 1405 #define NIBBLENOTWRITTEN 1406 #define NIBBLENOTREAD 1407 #define BYTENOTREAD 1408 #define WILNOTEXCL 1409 #define NOTREADYYET 1410 // Device Node of Choice #define ONEANDONLYPARPORT "/dev/parport" #define _USE_LINUX_PARPORT_N8_ #ifndef _USE_LINUX_PARPORT_N8_ // define port usage in DOS #define READ_DATA_REG() not_defined_yet() // define port usage in DOS #define READ_STAT_REG() not_defined_yet() // define port usage in DOS #define READ_CTRL_REG() not_defined_yet() // define port usage in DOS #define WRITE_DATA_REG() not_defined_yet() // define port usage in DOS #define WRITE_CTRL_REG() not_defined_yet() #else // define port usage in Linux #define READ_DATA_REG() if( ioctl( m_nPort, PPRDATA, &m_ucByte ) ) \ { \ printf("*** Error: Raw Data not readable\n"); \ m_nError = BYTENOTREAD; \ } \ else \ { \ m_ucDATA = m_ucByte; \ m_nError = NOERRORS; \ } // define port usage in Linux #define READ_STAT_REG() if( ioctl( m_nPort, PPRSTATUS, &m_ucByte ) ) \ { \ printf("*** Error: Raw Status not readable\n"); \ m_nError = BYTENOTREAD; \ } \ else \ { \ m_ucSTAT = m_ucByte; \ m_nError = NOERRORS; \ } // define port usage in Linux #define READ_CTRL_REG() if( ioctl( m_nPort, PPRCONTROL, &m_ucByte ) ) \ { \ printf("*** Error: Raw Control not readable\n");\ m_nError = BYTENOTREAD; \ } \ else \ { \ m_ucCTRL = m_ucByte; \ m_nError = NOERRORS; \ } // define port usage in Linux #define WRITE_DATA_REG() if( ioctl( m_nPort, PPWDATA, &m_ucByte ) ) \ { \ printf("*** Error: Raw Data not writable\n"); \ m_nError = BYTENOTREAD; \ } \ else \ { \ m_ucDATA = m_ucByte; \ m_nError = NOERRORS; \ } // define port usage in Linux #define WRITE_CTRL_REG() if( ioctl( m_nPort, PPWCONTROL, &m_ucByte ) ) \ { \ printf("*** Error: Raw Control not writable\n");\ m_nError = BYTENOTREAD; \ } \ else \ { \ m_ucCTRL = m_ucByte; \ m_nError = NOERRORS; \ } #endif class CModLapLinkInterface2 { public: CModLapLinkInterface2(); ~CModLapLinkInterface2(); int GetPort( int nPrtNo ); int ReleasePort( void ); private: int m_nPort; int m_nError; unsigned char m_ucByte; unsigned char m_ucDATA; unsigned char m_ucSTAT; unsigned char m_ucCTRL; public: int GetD( unsigned char * ucData ); int GetS( unsigned char * ucData ); int GetC( unsigned char * ucData ); int SetD( unsigned char ucData ); int SetC( unsigned char ucData ); }; #endif //////////////////////////////////////////////////////////////////////////////