How can I communicate with the TTP 10x0, 7000, 8200 in Windows NT environments?

Article ID: 49875413


Topic or Information

Communicating with TTP Series Kiosk Printers in Windows NT environment

Applies To

Zebra Kiosk Printers


NT environment (NT4, Windows 2000 or Windows XP) to get status back from the printer. The ReadFile function does not work when the printer is installed on the same port. How can I receive data back?
The source code shows an example of the interfacing of the Language Monitor call into a VC++ program.) In particular you have to look into the two C-files TTP.CPP and TTP.H. 

Load the library and then enquire the ProcAddress. In C cast the result with the expected calling structure. 

if( (hLib=LoadLibrary("TTPMON.DLL")) == NULL )
      return FALSE;

if( (proc=(BOOL(__stdcall*)( PVOID,DWORD,PVOID,DWORD,PDWORD))GetProcAddress(hLib, "LmPrinterIoControl")) == NULL )
            return FALSE;

So, in order to call the LmPrinterIoControl function you need to provide five arguments. 

The first (pInBuffer) is the input buffer (where you store the ESC command you want the printer to respond to) in this case a void buffer filled with bytes. 
The second (nInBufferSize ) is a Long Word with the size of the input buffer (in this case it will be three).
The third (pOutBuffer) is again a void buffer where the LM is placing the result (it must be big enough to hold all the results).
The fourth (nOutBufferSize) is again a Long Word with the given buffer size. 
The fifth (pBytesReturned) is a pointer to a Long Word which will receive the number of returned bytes. 

The function will give back a Boolean (bRet) saying that the inquiry was successful or not.

if (proc != NULL)
      bRet = (*proc)( pInBuffer, nInBufferSize, pOutBuffer, nOutBufferSize, pBytesReturned );

Using a structure is just a way of easily selecting different ESC commands to send to the printer. As you noticed in the structure:
TTPKEY      ttpkey[11] =
      { "x00x00x00", 3, 1, REG_BINARY, TEXT("Language Monitor")},
      { "x1bx05x01", 3, 2, REG_BINARY, TEXT("Status General")},
      { "x1bx05x02", 3, 1, REG_BINARY, TEXT("Paper Near End")},
      { "x1bx05x06", 3, 2, REG_BINARY, TEXT("Status Report")},
      { "x1bx05x07", 3, 2, REG_BINARY, TEXT("Program Version")},
      { "x1bx05x09", 3, 6, REG_BINARY, TEXT("Serial Number")},
      { "x1bx05x0a", 3, 1, REG_BINARY, TEXT("Hardware Revision")},
      { "x1bx05x63", 3, 1024, REG_BINARY, TEXT("Device ID")},
      { "x1bx05x50", 4, 4, REG_BINARY, TEXT("Get Parameter")},
      { "x1bx3F", 2, 0, REG_BINARY, TEXT("Reset Full")},
      { "x1bx40", 2, 0, REG_BINARY, TEXT("Reset Initialize")}
There are different ESC commands listed in the Technical Manual.

The actual call of the LM function is then made in PrinterIoControl where you find the above described arguments.