감열식 프린터는 두 번째 출력 데이터를 tty 포트로 보낸 후에만 인쇄합니다.

감열식 프린터는 두 번째 출력 데이터를 tty 포트로 보낸 후에만 인쇄합니다.

POS 컴퓨터에 PCI 시리얼 카드를 설치하고 그 안에 오래된 열전사 프린터를 설치해 보았습니다. 테스트 명령 ls > /dev/ttyS4는 잘 작동하지만 두 번째로 보낸 후에만 가능합니다. 내 ERP 시스템에서 제대로 작동하려면 처음부터 제대로 작동해야 합니다.

추신: 사용자가 이미 그룹 다이얼아웃에 있습니다.

root@pdv3:/home/pdv3# lspci -v
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
        Subsystem: ASRock Incorporation 4th Gen Core Processor DRAM Controller
        Flags: bus master, fast devsel, latency 0
        Capabilities: [e0] Vendor Specific Information: Len=0c <?>
        Kernel driver in use: hsw_uncore

00:02.0 VGA compatible controller: Intel Corporation 4th Generation Core Processor Family Integrated Graphics Controller (rev 06) (prog-if 00 [VGA controller])
        Subsystem: ASRock Incorporation 4th Generation Core Processor Family Integrated Graphics Controller
        Flags: bus master, fast devsel, latency 0, IRQ 27
        Memory at f0000000 (64-bit, non-prefetchable) [size=4M]
        Memory at e0000000 (64-bit, prefetchable) [size=256M]
        I/O ports at f000 [size=64]
        [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
        Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [d0] Power Management version 2
        Capabilities: [a4] PCI Advanced Features
        Kernel driver in use: i915
        Kernel modules: i915

00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
        Subsystem: ASRock Incorporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller
        Flags: bus master, fast devsel, latency 0, IRQ 30
        Memory at f0614000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [50] Power Management version 2
        Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel

00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05) (prog-if 30 [XHCI])
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family USB xHCI
        Flags: bus master, medium devsel, latency 0, IRQ 24
        Memory at f0600000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [70] Power Management version 2
        Capabilities: [80] MSI: Enable+ Count=1/8 Maskable- 64bit+
        Kernel driver in use: xhci_hcd

00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family MEI Controller
        Flags: bus master, fast devsel, latency 0, IRQ 28
        Memory at f061e000 (64-bit, non-prefetchable) [size=16]
        Capabilities: [50] Power Management version 3
        Capabilities: [8c] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Kernel driver in use: mei_me
        Kernel modules: mei_me

00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05) (prog-if 20 [EHCI])
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family USB EHCI
        Flags: bus master, medium devsel, latency 0, IRQ 16
        Memory at f061c000 (32-bit, non-prefetchable) [size=1K]
        Capabilities: [50] Power Management version 2
        Capabilities: [58] Debug port: BAR=1 offset=00a0
        Capabilities: [98] PCI Advanced Features
        Kernel driver in use: ehci-pci

00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset High Definition Audio Controller
        Flags: bus master, fast devsel, latency 0, IRQ 29
        Memory at f0610000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [50] Power Management version 2
        Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel

00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        I/O behind bridge: 00002000-00002fff
        Memory behind bridge: dfa00000-dfbfffff
        Prefetchable memory behind bridge: 00000000dfc00000-00000000dfdfffff
        Capabilities: [40] Express Root Port (Slot+), MSI 00
        Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
        Capabilities: [90] Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family PCI Express Root Port
        Capabilities: [a0] Power Management version 3
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1c.3 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #4 (rev d5) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 19
        Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
        I/O behind bridge: 0000e000-0000efff
        Memory behind bridge: f0500000-f05fffff
        Capabilities: [40] Express Root Port (Slot+), MSI 00
        Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
        Capabilities: [90] Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family PCI Express Root Port
        Capabilities: [a0] Power Management version 3
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1c.5 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #6 (rev d5) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 17
        Bus: primary=00, secondary=03, subordinate=03, sec-latency=0
        I/O behind bridge: 0000d000-0000dfff
        Memory behind bridge: f0400000-f04fffff
        Capabilities: [40] Express Root Port (Slot+), MSI 00
        Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
        Capabilities: [90] Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family PCI Express Root Port
        Capabilities: [a0] Power Management version 3
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05) (prog-if 20 [EHCI])
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family USB EHCI
        Flags: bus master, medium devsel, latency 0, IRQ 23
        Memory at f061b000 (32-bit, non-prefetchable) [size=1K]
        Capabilities: [50] Power Management version 2
        Capabilities: [58] Debug port: BAR=1 offset=00a0
        Capabilities: [98] PCI Advanced Features
        Kernel driver in use: ehci-pci

00:1f.0 ISA bridge: Intel Corporation C220 Series Chipset Family H81 Express LPC Controller (rev 05)
        Subsystem: ASRock Incorporation C220 Series Chipset Family H81 Express LPC Controller
        Flags: bus master, medium devsel, latency 0
        Capabilities: [e0] Vendor Specific Information: Len=0c <?>
        Kernel driver in use: lpc_ich
        Kernel modules: lpc_ich

00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05) (prog-if 01 [AHCI 1.0])
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]
        Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 25
        I/O ports at f0b0 [size=8]
        I/O ports at f0a0 [size=4]
        I/O ports at f090 [size=8]
        I/O ports at f080 [size=4]
        I/O ports at f060 [size=32]
        Memory at f061a000 (32-bit, non-prefetchable) [size=2K]
        Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [70] Power Management version 3
        Capabilities: [a8] SATA HBA v1.0
        Kernel driver in use: ahci
        Kernel modules: ahci

00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
        Subsystem: ASRock Incorporation 8 Series/C220 Series Chipset Family SMBus Controller
        Flags: medium devsel, IRQ 3
        Memory at f0619000 (64-bit, non-prefetchable) [size=256]
        I/O ports at f040 [size=32]
        Kernel modules: i2c_i801

02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
        Subsystem: ASRock Incorporation Motherboard (one of many)
        Flags: bus master, fast devsel, latency 0, IRQ 19
        I/O ports at e000 [size=256]
        Memory at f0504000 (64-bit, non-prefetchable) [size=4K]
        Memory at f0500000 (64-bit, prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 01
        Capabilities: [b0] MSI-X: Enable+ Count=4 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Virtual Channel
        Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
        Capabilities: [170] Latency Tolerance Reporting
        Kernel driver in use: r8169
        Kernel modules: r8169

03:00.0 Serial controller: Device 1c00:3250 (rev 10) (prog-if 05 [16850])
        Subsystem: Device 1c00:3250
        Flags: fast devsel, IRQ 17
        I/O ports at d000 [size=256]
        Memory at f0408000 (32-bit, prefetchable) [size=32K]
        I/O ports at d100 [size=4]
        Expansion ROM at f0400000 [disabled] [size=32K]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable- Count=1/32 Maskable+ 64bit+
        Capabilities: [80] Express Legacy Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Kernel driver in use: parport_serial
        Kernel modules: parport_serial

root@pdv3:/home/pdv3# 

답변1

프린터가 PCI 장치인 줄 알았는데 잘못 읽었기 때문에 이 답변은 올바르지 않습니다. 병렬 포트가 이미 시스템에 있습니다.

문제의 성격은 모르지만 udev아래 설명과 같이 Linux 커널이 PCI 장치를 연결/연결 해제할 때마다 사용자 고유의 스크립트를 안정적으로 트리거할 수 있습니다.

https://www.pcsuggest.com/run-shell-scripts-from-udev-rules

  sudo nano /etc/udev/rules.d/40-switch_modem.rules
My custom rule looks like bellow

  ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1c9e", ATTR{idProduct}=="f000", RUN+="switch_modem.service"

여기서 idVendor 및 idProduct는 lspci의 출력에서 ​​사용할 수 있으며 하드웨어 자체에서 나옵니다. 귀하의 경우 하위 시스템은 USB가 아닙니다. udev가능한 값은 문서에 제공됩니다.

이 기사에서 작성자는 자신이 선택한 스크립트를 작성했습니다(한 번 프린터에 개행 문자를 보낼 수도 있습니다).

As directly running the script from a custom udev rule didn't worked, I had to create 
a new systemd service to run the script through it, when the device is plugged in, a 
USB modem in this case.

User created systemd service files are usually stored under /etc/systemd/system/ , 
I'm naming it switch_modem.service

  sudo nano /etc/systemd/system/switch_modem.service

The systemd service file,

  [Unit]
  Description=4G modem switcher

  [Service]
  Type=oneshot
  RemainAfterExit=no
  ExecStart=/usr/local/bin/switch_modem

  [Install]
  WantedBy=multi-user.target

이는 다음을 보장합니다: - 대상에 도달하기 전에 부팅하는 동안 실행됩니다 multi-user. - 일치하는 하드웨어가 연결될 때마다 실행됩니다.

udev또한 모든 장치에서 연결/연결 해제할 때마다 호출되는 고유한 스크립트를 제공하는 옵션도 있습니다 . 여기서 udev적절한 정보는 명령줄 인수 또는 환경 변수로 전달됩니다. 이 옵션은 더 유연하지만 구현하기가 더 어렵습니다.

관련 정보