현재 매우 오래된 Ubuntu 14.04에서 Linux를 실행하는 PC에 핸드헬드 장치를 연결하여 SynCE의 저장소 PPA를 소스 목록에 추가할 수 있습니다. 이제 목표는 운영 체제를 업데이트하는 것이었고 Debian Buster를 선택했고 Ubuntu Xenial 버전의 동일한 저장소에서 DEB 패키지를 성공적으로 설치했습니다.
데비안에서는 USB 직렬 장치가 인식되어 ttyUSB 버스에 연결되고, IP 주소를 획득한 후 몇 초(2초, 최대 3초) 후에 연결이 끊어집니다. PPP 디버깅을 수행했는데(디버그 덤프 및 kdebug 옵션) 모든 것이 괜찮아 보입니다.
pppd options in effect:
debug # (from /etc/ppp/options)
kdebug 7 # (from /etc/ppp/options)
logfile /tmp/pppd.log # (from /etc/ppp/options)
linkname synce-device0 # (from command line)
dump # (from /etc/ppp/options)
noauth # (from command line)
/dev/ttyUSB0 # (from command line)
115200 # (from command line)
lock # (from /etc/ppp/options)
connect /usr/lib/synce-core/synce-serial-chat # (from command line)
record /tmp/pppd.pcap # (from /etc/ppp/options)
crtscts # (from command line)
local # (from command line)
asyncmap 0 # (from /etc/ppp/options)
lcp-echo-failure 4 # (from /etc/ppp/options)
lcp-echo-interval 30 # (from /etc/ppp/options)
hide-password # (from /etc/ppp/options)
ms-dns xxx # [don't know how to print value] # (from command line)
nodefaultroute # (from command line)
192.168.131.1:192.168.131.129 # (from command line)
noipx # (from /etc/ppp/options)
Removed stale lock on ttyUSB0 (pid 4366)
Script /usr/lib/synce-core/synce-serial-chat finished (pid 4435), status = 0x0
Serial connection established.
using channel 14
Using interface ppp0
Connect: ppp0 <--> /dev/pts/3
rcvd [LCP ConfReq id=0x0 <mru 1500> <asyncmap 0x0> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xf230f2eb> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <mru 1500> <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xf230f2eb> <pcomp> <accomp>]
sent [LCP EchoReq id=0x0 magic=0xf230f2eb]
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 192.168.131.1>]
rcvd [CCP ConfReq id=0x0 <mppe -H -M -S -L -D +C>]
sent [CCP ConfRej id=0x0 <mppe -H -M -S -L -D +C>]
rcvd [IPCP ConfReq id=0x2 <compress VJ 0f 00> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-wins 0.0.0.0> <ms-dns2 0.0.0.0> <ms-wins 0.0.0.0>]
sent [IPCP ConfRej id=0x2 <ms-wins 0.0.0.0> <ms-wins 0.0.0.0>]
rcvd [IPV6CP ConfReq id=0x0 <addr fe80::4283:deff:feae:dec9>]
Unsupported protocol 'IPv6 Control Protocol' (0x8057) received
sent [LCP ProtRej id=0x2 80 57 01 00 00 0e 01 0a 42 83 de ff fe ae de c9]
rcvd [LCP EchoRep id=0x0 magic=0x0]
rcvd [CCP ConfRej id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [CCP ConfReq id=0x2]
rcvd [IPCP ConfAck id=0x1 <compress VJ 0f 01> <addr 192.168.131.1>]
rcvd [CCP ConfReq id=0x1]
sent [CCP ConfAck id=0x1]
rcvd [IPCP ConfReq id=0x3 <compress VJ 0f 00> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
sent [IPCP ConfNak id=0x3 <addr 192.168.131.129> <ms-dns1 192.168.131.1> <ms-dns2 192.168.131.1>]
rcvd [CCP ConfNak id=0x2 <mppe -H -M -S -L -D +C>]
sent [CCP ConfReq id=0x3]
rcvd [IPCP ConfReq id=0x4 <compress VJ 0f 00> <addr 192.168.131.129> <ms-dns1 192.168.131.1> <ms-dns2 192.168.131.1>]
sent [IPCP ConfAck id=0x4 <compress VJ 0f 00> <addr 192.168.131.129> <ms-dns1 192.168.131.1> <ms-dns2 192.168.131.1>]
local IP address 192.168.131.1
remote IP address 192.168.131.129
Script /etc/ppp/ip-up started (pid 4444)
rcvd [CCP ConfAck id=0x3]
Script /etc/ppp/ip-up finished (pid 4444), status = 0x0
UDEV에서는 "추가" 이벤트 후에 장치 연결을 끊지 않고 커널에서 "제거"를 트리거하는 것을 볼 수 있습니다. 놀랍게도 이 이벤트는 ppp0 네트워크 장치에만 관련되어 있습니다.
KERNEL[13133.932298] add /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
KERNEL[13133.941859] add /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
KERNEL[13133.946512] add /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
KERNEL[13133.946847] add /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0 (tty)
KERNEL[13133.946887] bind /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
KERNEL[13133.946930] bind /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
KERNEL[13133.947016] bind /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
UDEV [13133.951550] add /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
UDEV [13133.967665] add /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
UDEV [13133.969926] add /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
UDEV [13133.993251] add /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0 (tty)
UDEV [13134.002291] bind /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
UDEV [13134.003803] bind /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
UDEV [13134.004620] bind /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
KERNEL[13134.445488] add /devices/virtual/net/ppp0 (net)
KERNEL[13134.445509] add /devices/virtual/net/ppp0/queues/rx-0 (queues)
KERNEL[13134.445519] add /devices/virtual/net/ppp0/queues/tx-0 (queues)
UDEV [13134.498959] add /devices/virtual/net/ppp0 (net)
UDEV [13134.510588] add /devices/virtual/net/ppp0/queues/rx-0 (queues)
UDEV [13134.514145] add /devices/virtual/net/ppp0/queues/tx-0 (queues)
<< a little few seconds later >>
KERNEL[13137.624110] remove /devices/virtual/net/ppp0/queues/rx-0 (queues)
KERNEL[13137.624144] remove /devices/virtual/net/ppp0/queues/tx-0 (queues)
KERNEL[13137.624169] remove /devices/virtual/net/ppp0 (net)
UDEV [13137.644633] remove /devices/virtual/net/ppp0/queues/tx-0 (queues)
UDEV [13137.644791] remove /devices/virtual/net/ppp0/queues/rx-0 (queues)
UDEV [13137.659488] remove /devices/virtual/net/ppp0 (net)
해당 이벤트는 네트워크 인터페이스 또는 네트워크 프로토콜과 관련되어 있지만 이를 유발하는 항목은 본 적이 없습니다. Whireshark를 사용하여 네트워크 트래픽(pcap 파일에 로깅)을 살펴보면 어떤 단서도 찾지 못했습니다. Ubuntu의 연결과 비교했지만 아무것도 표시되지 않습니다. Ubuntu에서는 RST에도 불구하고 연결이 끊어지지 않습니다(아래 이미지 참조).
https://i.stack.imgur.com/c0RKA.png
데비안에서는 갑자기 사라졌습니다.
https://i.stack.imgur.com/43vtk.png
목표는 USB 직렬 장치와 Linux PC 사이에 안정적인 TCP/IP 연결을 설정하는 것입니다.
ppp0 <--> /dev/ttyUSB0
현재 데비안에서는 몇 초(2~3초) 내에 연결이 끊어집니다.
Jan 18 20:26:56 debian10 pppd[1590]: local IP address 192.168.131.1
Jan 18 20:26:56 debian10 pppd[1590]: remote IP address 192.168.131.129
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_check_interface_cb: address ready
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_create_device: found device interface for /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_create_device: listening for device /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_create_device: NOT triggering connection
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_manager_client_connected_cb: have a connection to port 5679
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_manager_client_connected_cb: creating device object for /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_set_property: running for device /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_initable_init: connecting to udev
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: info buffer length = 138
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 0: unknown: guint32 ?: 40
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 4: os_major: guint8: 6
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 5: os_minor: guint8: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 6: unknown, build number ?: guint16 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 8: cpu_type: guint16: 2577
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 10: unknown: guint16 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 12: unknown: guint32 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 16: cur_partner_id: guint32: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 20: second partner id ?: guint32 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 24: offset to device name: guint32: 40
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 28: offset to platform name: guint32: 74
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 32: offset to model name: guint32: 104
Jan 18 20:26:57 debian10 dccm[1505]: Message: synce_device_dbus_init: registering object path '/org/synce/dccm/Device/_devices_pci0000_00_0000_00_06_0_usb2_2_2_2_2_1_0_ttyUSB0_tty_ttyUSB0'
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_manager_device_obj_path_changed_cb: sending connected signal for /org/synce/dccm/Device/_devices_pci0000_00_0000_00_06_0_usb2_2_2_2_2_1_0_ttyUSB0_tty_ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_dbus_init: obj_path set to /org/synce/dccm/Device/_devices_pci0000_00_0000_00_06_0_usb2_2_2_2_2_1_0_ttyUSB0_tty_ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: get_password_flag_text: setting password flags unset
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: setting CTRL_STATE_CONNECTED
Jan 18 20:26:58 debian10 dccm[1505]: DEBUG: gudev_uevent_callback: received uevent **remove** for device /sys/devices/virtual/net/ppp0/queues/tx-0
Jan 18 20:26:58 debian10 dccm[1505]: DEBUG: gudev_uevent_callback: received uevent **remove** for device /sys/devices/virtual/net/ppp0/queues/rx-0
Jan 18 20:26:58 debian10 dccm[1505]: DEBUG: gudev_uevent_callback: received uevent **remove** for device /sys/devices/virtual/net/ppp0
무슨 일이 일어나고 있는지 어떻게 알 수 있나요? , 커널이 ppp0 장치를 삭제하는 이유는 무엇입니까? 이 문제를 해결하는 데 도움이 되는 답변을 주시면 감사하겠습니다. USB 직렬 장치를 연결하는 다른 방법이 있더라도 있는지는 모르겠습니다.
답변1
이것udev 매뉴얼대답해주세요:
데몬이나 기타 장기 실행 프로세스는 시작될 수 없습니다. 분리 여부에 관계없이 분기된 프로세스는 이벤트 처리가 완료된 후 무조건 종료됩니다. udev 규칙에서 장기 실행 프로세스를 활성화하려면 서비스 단위를 제공하고 SYSTEMD_WANTS 장치 속성을 사용하여 udev 장치에서 이를 가져옵니다.
최신 udev 버전(Ubuntu 16 및 Debian 8)에서는 udev 트랜잭션 및 이에 의해 생성된 프로세스에 엄격한 시간 제한을 적용하여 RUN 또는 PROGRAM 스크립트에서 오래 지속되는 백그라운드 프로세스를 시작하지 못하게 합니다. udev 생성 스크립트의 장기 실행 프로세스 제한은 백그라운드에서 무언가를 시작하면 실제 스크립트 udev가 시작되자마자 종료됩니다. Udev는 cgroup을 사용하여 생성된 작업을 검색하고 삭제합니다. 따라서 모든 스레드는 종료 신호를 받습니다.
udev에서 장기 실행 프로세스를 시작하는 것은 허용되지 않으므로 systemd 경로는 올바른 접근 방식입니다.