pythonprinting

Form feed timeout when printing to Kyocera FS-2000D using Python


I have the following Python code running on Ubuntu 24.04 LTS:

import sharedVars as sv

printToPar = "/dev/usb/lp0"
def resultprnt():
    with open(printToPar, "w") as lPrint, open("test.txt", 'w') as log_file:
        def send_to_printer(command):
            log_file.write(command)# command sent logged
            lPrint.write(command)
            lPrint.flush()# Wait until all data is sent
        send_to_printer("(Test TEST TEST)\n\r")
        send_to_printer("E\n")
        send_to_printer(chr(12))

if __name__ == "__main__":
    sv.clearScreen()
    print("Test start...")
    resultprnt()

Initially, the printer status shows ready. After sending the strings, the printer says waiting.... and then after some time, it says form feed timeout.

The printer can indeed work when sending postscript files but I would also like it to support other printers that don't support postscript files. Hence, my approach above.

I've tried with and without chr(12) but I still get form feed timeout. I consulted the FS-200D manual but couldn't find any guidance on triggering the printer to print via characters. Any ideas on what else I should try?


Solution

  • Most printers can accept plain text. The reason why the printer couldn't accept the plain text was because it's emulation was set to KPDL.

    To enable the printer to adapt to any file format sent to it, the printer's emulation should be set to KPDL(auto).

    No issue with the python code.