サーマルプリンタは、2番目の出力データをttyポートに送信した後にのみ印刷します。

サーマルプリンタは、2番目の出力データをttyポートに送信した後にのみ印刷します。

POSコンピュータにPCIシリアルカードを取り付け、その中に古い熱転写プリンタを取り付けてみました。テストコマンドls > / dev / ttyS4はうまく機能しますが、2回目の送信後にのみ可能です。私のERPシステムで正しく動作するには、最初から正しく動作する必要があります。

PS:ユーザーはすでにグループダイヤルアウトになっています。

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適切な情報はコマンドライン引数または環境変数に渡されます。このオプションはより柔軟ですが、実装するのは難しいです。

関連情報