How to read response from printer in language monitor

Terry Chou 1 Reputation point
2022-12-16T03:01:52.647+00:00

I'm developing a printer driver(unidrv), and writing a language monitor to get some information from my printer.
My language monitor is modified from pjlmon.dll example. It get the response correctly from printer with USB port. However, It doesn't work properly with TCP/IP and COM port.

With COM port, I've used sniffer software. I found when I call "fn.pfnWritePort" port monitor function, it will close COM port finally. This cause I can't get the response by "fn.pfnReadPort" port monitor function.

With TCP/IP, there are two cases.

  1. when I call WriteCommand() and ReadCommand() function in PJLMonGetPrinterDataFromPort() language monitor function, I get error code 6 after "fn.pfnWritePort" port monitor function and error code 50 after "fn.pfnReadPort" port monitor function.
  2. when I call WriteCommand() and ReadCommand() function in PJLMonStartDocPort() language monitor function, I can successfully call WriteCommand() and see the packets in WireShark, but still get error code 50 after "fn.pfnReadPort" port monitor function.

How should I read the response from printer in my language monitor via TCP/IP and COM?

Windows for business | Windows Client for IT Pros | Devices and deployment | Other
Windows for business | Windows Server | User experience | Print jobs
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2022-12-16T17:23:42.463+00:00

    Hello there,

    If you specifically need to get information from TCP/IP you might need to look into transceive (Xcv) interface.

    The article below describes the transceive (Xcv) interface for the standard TCP/IP port monitor (TCPMON). This interface, which is implemented using XcvData and XcvDataPort function calls, enables those using it to configure a TCP/IP printer port or to obtain information about a TCP/IP printer port configuration. The Xcv interface described in this section is specific to TCP/IP ports. Other Xcv interfaces might be available for other port types.

    More info here https://learn.microsoft.com/en-us/windows-hardware/drivers/print/tcpmon-xcv-interface

    Microsoft provides a language monitor, Pjlmon.dll, which supports printer job language (PJL), and provides bidirectional communication for PJL printers.

    Language monitors https://learn.microsoft.com/en-us/windows-hardware/drivers/print/language-monitors

    ------------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer–


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.