File copy to serial port blocked RRS feed

  • Question

  • I ran into a strange issue recently working on some printing code that basically just copies a .prn file to the serial port to print.  The document would either not print at all, or start printing, but then immediately stop after the first page or so.  It varied from document to document, but it always seemed to be consistent for the same document.

    This behavior was duplicated on both Win10 and Win7 machines.  I was also able to duplicate the behavior outside the code by just sending a command line copy command.

    After looking at everything I could think of, the only thing I could determine was that something on the machine was stopping the transmission of the file to the printer.

    Even though it doesn't involve the Windows print system, and it took a while to arrive at it, I was eventually able to get it to work by simply creating a dummy printer in Windows pointed to the same serial port.  After that all the documents printed just fine.

    My hypothesis is that something is looking for a device defined in the registry on that port, and blocking it if it's not found.  But I'm not sure what that would be.

    Has anyone seen this behavior or know what might be causing that?

    Monday, July 13, 2020 6:31 PM


All replies

  • Hello Marbry,

    Thanks for posting here.

    Could help confirm the following information to narrow down this issue?

    1. Are you developing in Win32 C++ application?
    2. Can you show more detailed information about "blocked"? Which API hangs or timeout or any error message?
    3. If you can show a mini and reproducible sample we can do a further investigation.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 14, 2020 1:27 AM
  • It is an MFC C++ application, but as I said, I can duplicate the issue outside the code from the command line so I don't see the code itself being the issue.  It's doing a simple copy.

    There is no hang or error message, it simply stops printing or doesn't start printing in the first place.

    To recreate,

    1.  Connect a printer to LPT1, do not map in Windows

    2.  Create a .prn file for that printer that's at least 5-6 pages long

    3.  If it exists, I would assume you'd need to remove any Windows printer mappings for that port (may need to clean registry if lingering printer entries for port)  

    4.  From the command line, copy file to port like "copy filename.prn /b LPT1:"

    Wednesday, July 15, 2020 3:07 PM
  • And by blocked, I mean the transmission end sends successfully, or at least thinks it did, and there is no error on the printer.

    So this leads me to believe that there is something in-between that is interfering with the transmission of data to the port.

    Wednesday, July 15, 2020 3:20 PM
  • Is LPT1 a legacy parallel port or something USB, or add-on PCI card?

    (by the way, your original post says "serial port". LPT is parallel port).

    -- pa

    Wednesday, July 15, 2020 9:17 PM
  • Hello,

    since it is not a source code problem as you said, you could ask here about hardware problems:



    Regards, Guido

    Thursday, July 16, 2020 6:12 AM