Impressora térmica só imprime depois de enviar um segundo dado de saída para a porta tty

2

Eu tenho uma PCI Serial Card instalada em um computador POS e estou tentando instalar uma impressora térmica antiga nela. O comando de teste ls > / dev / ttyS4 funciona bem, mas somente depois da segunda vez que eu o envio. Para que funcione corretamente no meu sistema ERP, eu preciso que ele funcione corretamente na primeira vez.

P.S .: o usuário já está no grupo de discagem.

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# 
    
por Guilherme 23.08.2018 / 17:35

1 resposta

0

Esta resposta está incorreta, pois achei que a impressora seria o dispositivo PCI, mas eu interpretei mal. A porta paralela já está no sistema.

Embora eu não saiba a verdadeira natureza do problema, você pode disparar um script próprio sempre que o kernel do Linux conectar / desconectar dispositivos PCI através de udev , como descrito aqui: (o trecho é a seguir)

link

  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"

onde idVendor e idProduct estão disponíveis na saída do lspci e vêm do próprio hardware. O subsistema, no seu caso, não será USB. Os valores possíveis estão disponíveis em udev docs.

No artigo, o autor criou um script de sua escolha (você provavelmente desejaria enviar uma nova linha para a impressora, uma vez)

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

Isso garante que:  - ele será executado durante a inicialização, logo antes de atingir multi-user target  - ele será executado em cada conexão de hardware correspondente

Também havia uma opção em udev para fornecer o próprio script, que seria chamado em cada conexão / desconexão de QUALQUER dispositivo, em que udev passaria as informações apropriadas como parâmetros de linha de comando ou ambiente vars. Esta opção sendo mais flexível, também é mais difícil de implementar.

    
por 23.08.2018 / 18:17