Back to Knowledege base

Understanding Offline State vs Error State

Distinguishing between offline detection and error conditions

Offline vs Error States

Both Offline and Error states indicate the printer cannot print, but they have different causes:

Offline State : Xi-Text detected printer is offline (variation of Halted state) : Usually hardware/connectivity issue : Often temporary and recoverable

Error State : Unrecoverable error in Xi-Text configuration or operation : Usually software/configuration issue : Requires fixing underlying problem before recovery

What Causes Offline State

Hardware not ready:

  • Printer powered off
  • Printer in standby/sleep mode
  • Printer out of paper
  • Printer paper jam
  • Printer cover open
  • Printer error condition (hardware)

Connectivity issues:

  • Cable disconnected
  • Serial port signals indicate offline
  • Network printer temporarily unreachable
  • Terminal server communication lost

Exit code detection:

Setup file configured to treat certain exit codes as offline:

bash

# In setup file:
exit setoffline 1,10-50

When network subprocess exits with these codes, printer enters offline state.

Diagnostic Approach

Step 1: Check Printer Display

View printer in spq:

bash

spq -P  # Show printers view

Look for state and message:

ptr1  <lp0>  a4.ps  offline:Out of paper
ptr2  <srv:9100>  a4.ps  offline

Messages (if shown) indicate detected condition.

Step 2: Check Physical Printer

For local printers:

  • Verify power on
  • Check paper loaded
  • Look for error lights/messages on printer panel
  • Clear any paper jams
  • Ensure covers closed
  • Check cable connections

For network printers:

  • Access printer web interface (if available)
  • Check printer control panel via terminal server
  • Verify printer status via manufacturer tools
  • Test network connectivity

Step 3: Test Device Accessibility

For serial/parallel printers:

bash

# Check device responds
sudo -u spooler cat < /dev/lp0
# Press Ctrl+C after moment

# For serial printers
stty -F /dev/ttyS0 -a
# Shows port settings and status signals

For network printers:

bash

# Test connection
telnet printserver 9100

# Or with nc
nc -v printserver 9100

If connection succeeds, printer should be reachable.

Step 4: Review System Log

Check for offline detection messages:

bash

tail -50 /var/spool/spd/spshed_reps | grep "offline"

May show:

Printer ptr1 went offline: No carrier
Printer ptr2 network connection closed unexpectedly

Resolving Offline Conditions

Hardware Issues

Printer powered off:

  • Power on printer
  • Wait for ready state
  • Start printer in Xi-Text:

bash

spstart ptr1

Out of paper:

  • Load paper
  • Clear any paper-out sensor errors
  • Start printer:

bash

spstart ptr1

Paper jam:

  • Clear jam following printer manual
  • Ensure no torn paper remains
  • Close covers fully
  • Start printer:

bash

spstart ptr1

Printer error condition:

  • Check printer display/lights for specific error
  • Resolve indicated problem (toner, drum, maintenance)
  • Clear error on printer
  • Start printer in Xi-Text

Connectivity Issues

Cable disconnected:

bash

# For serial printers, check cable at both ends
# Verify proper serial cable (not null-modem if direct)

# For parallel printers, ensure cable firmly seated
# Try different cable if available

After reconnecting:

bash

sphalt ptr1
spstart ptr1

Serial port signals:

Some printers use hardware flow control signals (DTR/DSR, RTS/CTS):

bash

# Check serial port status
stty -F /dev/ttyS0 -a

# Look for:
# - DSR (Data Set Ready)
# - CTS (Clear To Send)
# - DCD (Data Carrier Detect)

If signals indicate offline, printer hardware may not be asserting ready signals correctly.

Network printer unreachable:

bash

# Test connectivity
ping printserver

# Check if ping succeeds but port closed
telnet printserver 9100

If network reachable:

  • Printer may be rebooting
  • Printer in power save mode
  • Print server software crashed

Wait a minute and retry:

bash

spstart ptr1

If network unreachable:

  • Check network cables
  • Verify switch/router operation
  • Check printer IP address hasn't changed
  • Verify no firewall blocking

Exit Code Configuration

If setup file uses exit setoffline, network subprocess exiting with specified codes triggers offline state.

Check configuration:

bash

# View setup file
cat /usr/spool/printers/ptr1/.device
cat /usr/spool/printers/ptr1/default

# Look for:
exit setoffline 1,10-50

Test network subprocess:

bash

# Extract network command from setup
grep "network=" /usr/spool/printers/ptr1/.device

# Test manually
# Example: network exec '/usr/local/bin/printer-driver args'
/usr/local/bin/printer-driver args
echo $?  # Check exit code

If exit code in setoffline range, offline is expected behaviour.

Offline vs Error Differentiation

How to tell which state:

bash

# View printer status
splist ptr1

# Output shows state:
ptr1 <lp0> a4.ps offline    ← Offline state
ptr1 <lp0> a4.ps error      ← Error state

Or check in spq:

  • Switch to printers view (press 'o' from jobs view)
  • State column shows current state
  • Additional message may appear on right

Key differences:

AspectOfflineError
CauseHardware/connectivity issueConfiguration/software issue
RecoveryFix hardware, then startFix config, halt, then start
Log entryNetwork closed, no carrierParse error, cannot open
MessageOften blank or hardware msgOften shows specific error

Recovery Procedure

For offline state:

  1. Fix physical issue (power, paper, cables)
  2. Verify connectivity (ping for network printers)
  3. Start printer:

bash

spstart ptr1

Printer should initialise and enter idle state.

If still offline:

bash

# Halt to clear state
sphalt ptr1

# Wait a moment
sleep 2

# Start again
spstart ptr1

If repeatedly goes offline:

Check for intermittent hardware issues:

bash

# Monitor for repeated offline
watch -n 5 'splist ptr1; tail -5 /var/spool/spd/spshed_reps'

Pattern of repeatedly going offline suggests:

  • Intermittent cable connection
  • Printer power cycling
  • Network instability
  • Print server crashes

Error Messages on Offline State

Some printers provide error messages visible in Xi-Text:

bash

splist ptr1
# May show:
ptr1 <lp0> a4.ps offline:Out of paper
ptr1 <srv:9100> a4.ps offline:Paper Jam

These come from:

fberror keyword in setup:

bash

# In setup file:
fberror

Captures last line of stderr from network subprocess and displays it.

To enable error messages:

bash

# Edit setup file
vi /usr/spool/printers/ptr1/.device

# Add:
fberror

Restart printer to activate.

Preventing Offline Conditions

Regular maintenance:

  • Keep printers stocked with paper
  • Replace consumables before depletion
  • Clean printers regularly
  • Check cables periodically

Monitoring:

bash

#!/bin/bash
# monitor-printers.sh

while true; do
    for printer in $(splist | awk '{print $1}'); do
        STATE=$(splist -F "%t" $printer)
        
        if [ "$STATE" = "offline" ]; then
            echo "ALERT: $printer offline" | \
                mail -s "Printer Alert" admin@example.com
        fi
    done
    
    sleep 300  # Check every 5 minutes
done

Redundancy:

Configure multiple printers for same form type:

bash

# Add backup printer
spadd -p backup-ptr -d /dev/lp1 -f a4.ps

# Jobs automatically route to available printer

Understanding and Resolving Printer Error States
Diagnosing why printers enter error state and how to recover