Chapter 12: Cash Drawer Interface 12-23
sBytes = sBytes | CD7402SELECT_GPI; //solenoid bits as inputs
// write new select with solenoid bits enabled as Outputs.
result = WriteIOPort( sBytes, m_nIOPort_select );
}
else
result = FALSE;
}
}
ReleaseMutex( g_hHWPortMutex );
return result;
}
//////////////////////////////////////////////////////////////////////////////
// CDevice7402::WriteIOPort
//We use the port address obtained from QueryConf().
BOOL WriteIOPort( DWORD databytes, WORD ioport )
{
BOOL result = TRUE;
DWORD FileOffset=0x40;
DWORD DataWritten;
WaitForSingleObject( g_hHWPortMutex, INFINITE ); // TAR 95236
if ((m_nOSVersion == OS_WINDOWS_95) || (m_nOSVersion == OS_WINDOWS_CE))
{ // WIN 95 I/O write
_outpd( ioport, databytes );
} //Win95
else
{ // WIN NT I/O write
if (m_bPortDrvr == TRUE) // if Wedge NT driver opened successfully
{
//*********TIGER Write Register address dword to IOPort***************
SetFilePointer( g_hPortDrvr, ioport, (PLONG)&FileOffset, FILE_BEGIN);
m_pDC->DCPrintf( DCM_APILOW,
_T("*CDeviceNCR7402:WriteIO: databytes= %X; IOPort= %X"), databytes,
ioport );
if ( WriteFile(
g_hPortDrvr, // Handle to device
(LPSTR) &databytes,
(DWORD) 4, // Length of buffer in bytes
&DataWritten, // bytes written
NULL ) == FALSE ) // NULL means wait till I/O completes.