1

I am trying to print a document with a serial printer using the command lpr.

The model of printer that I have is Craden DP-9. I am finding the technical manual to be difficult to understand, because it assumes a certain level of familiarity with archaic line printing technology.

Setup

The printer is installed/registered in CUPs as printer1. I can talk to the printer over a USB to serial adapter from my laptop. It reliably exhibits a response to printing jobs, but the documents that come out are always scrambled in various ways.

I am reasonably certain that the printer is in good condition because the self-test document comes out perfectly.

Code

Here is the code that I am attempting to print things with.

#!/bin/bash
# Created on 2023-09-10T17:52:18-04:00
# Author: nate

set -eo pipefail

if [[ -z "$1" || ! -f "$1" ]] ; then
    echo "Please provide an input file."
    exit 0
fi

tempfile="$(mktemp)"
trap "rm -f $tempfile" EXIT

WIDTH="90"
LINES="60"
MARGIN="0"

cat "$1" \
    | unix2dos\
    | tee "$tempfile"\
    | lpr -P printer1 -o raw

cat "$tempfile"

When I run this bash script to print the source code of the script itself:

./print.sh ./print.sh

Here is a scan of the resulting document:

Here is a scan of the resulting document.

A scan of the self-test document, containing debug information:

A scan of the self-test document, containing debug information.

My question

  • Why is the beginning of the document scrambled?
  • For those more familiar with these types of line printers than I am, what are the typical avenues for debugging this type of line printer problem?

Any help is appreciated!

Edit: output of lpoptions

copies=1 device-uri=serial:/dev/ttyUSB0?baud=38400+bits=8+parity=none+flow=soft finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 print-color-mode=monochrome printer-commands=AutoConfigure,Clean,PrintSelfTestPage printer-info printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='IBM ProPrinterII Foomatic/ibmpro (recommended)' printer-state=3 printer-state-change-time=1694275126 printer-state-reasons=none printer-type=8564740 printer-uri-supported=ipp://localhost/printers/printer1
7
  • I don't see why you post here the script. This should be irrelevant: If you just print the document using lpr from the command line, the printout looks the same, doesn't it? Commented Sep 13, 2023 at 6:30
  • 1
    @user1934428 actually it is not the same, because the script invokes unix2dos. Anyway, we should know the configuration of lpr. For example, the conversion of unix single LF to CR-LF should be a duty of lpr (or cups). Commented Sep 13, 2023 at 6:43
  • 1
    You can do all the actions of the scripts manually, and safe the result into a file. Then you print the file from the command line. If the output then looks bad, it is not a programming problem, but a problem on how you have configured your printer. In this case, the question is off-topic here, but could be asked at Super User. Commented Sep 13, 2023 at 6:45
  • I posted this trivial script because it was necessary to have some document to show what the input/output of the print job looks like Commented Sep 13, 2023 at 20:42
  • Added the output of lpoptions, please let me know any other information that would be useful Commented Sep 13, 2023 at 20:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.