2022年6月4日 星期六

Linux 存取目錄

列出目錄的檔案。

opendir(目錄) 或 fdopendir(fd) 開啟一個 directory stream (DIR),包含此目錄的所有檔案 (含目錄)。readdir(DIR *) 自 directory stream 取得一個檔案,用 struct direct 表示,包含名稱等。再 readdir() 取得下一個,直到 NULL。

參考

  1. https://www.gnu.org/software/libc/manual/html_node/Accessing-Directories.html

2022年5月29日 星期日

USB Communication Device Class

Base Class 02h,通訊裝置包括電話、PSTN/DSL/Cable 數據機、ISDN、Ethernet/ATM/無線/行動網路。

Class CodeSubClass說明
02h 01hDirect Line Control Model[USBPSTN1.2]
02h 02h 00hAbstract Control Model (CDC-ACM)No Class Specified Protocol [USBPSTN1.2]
02h 02h 01hAT commands [V250] [USBPSTN1.2]
02h 03hTelephone Control Model[USBPSTN1.2]
02h 04hMulti-Channel Control Model[USBISDN1.2]
02h 05hCAPI Control Model[USBISDN1.2]
02h 06hEthernet Networking Control Model[USBECM1.2]
02h 07hATM Networking Control Model[USBATM1.2]
02h 08hWireless Handset Control Model[USBWMC1.1]
02h 09hDevice Management[USBWMC1.1]
02h 0AhMobile Direct Line Model[USBWMC1.1]
02h 0BhOBEX[USBWMC1.1]
02h 0ChEthernet Emulation Model[USBEEM1.0]
02h 0DhNetwork Control Model[USBNCM1.0]

一個 CDC 裝置必須支援兩個 Interface,一個描述所支援的功能,另一個描述資料傳輸的通道,透過 IAD (Interface Association Descriptor) 將兩者宣告屬於同一個 function。

RS232 over USB

Ethernet over USB:透過 USB 傳送 Ethernet frames,達到這的目的協定有 Microsoft 的 Remote Network Driver Interface Specification (RNDIS)、CDC Ethernet Control Model (ECM)、CDC Ethernet Emulation Model (EEM)、和 CDC Network Control Model (NCM)。

ECM 用在 USB full speed。

EEM is intended for use in communicating with devices, using Ethernet frames as the next layer of trans- port. It is not intended for use with routing or Internet connectivity devices, although this use is not pro- hibited.

NCM 改良 ECM 1.2 支援更高 data rates:單一 USB 傳送可送多個 Ethernet frames,並可指定偏好位置減少處理 overhead。NCM 定義兩種 encapsulating datagrams,一種長度可達 64KiB 可放 40 Ethernet frames,另一種達 4GiB 支援 High Speed 和 SuperSpeed data rates。一個 NCM function 包含一個 NCM Communications Interface 和一個 NCM Data Interface。NCM Communications Interface 用來設定和管理 the networking function。NCM Data Interface 使用定義的 endpoints 來傳送 data。

參考

  1. http://pollos-blog.blogspot.com/2014/10/rs232-over-usb.html
  2. https://en.wikipedia.org/wiki/Ethernet_over_USB
  3. https://www.usb.org/document-library/network-control-model-devices-specification-v10-and-errata-and-adopters-agreement
  • 比較:Video、MTP 傳送特定應用協定

2022年5月28日 星期六

USB Device Classes

USB 裝置提供 Class Code,讓來自不同製造商的裝置可使用通用驅動程式,資訊包括 3 bytes:Base Class、SubClass、和 Protocol,可用在 Device Descriptor 或 Interface Descriptors。

Base ClassDescriptor說明
00hDevice使用在 Interface Description 的 class 資訊。
01hInterfaceAudio
02hBothCommunications Device Class (CDC)
03hInterfaceHID (Human Interface Device)
05hInterfacePhysical
06hInterfaceImage (PTP/MTP)
07hInterfacePrinter
08hInterfaceMass Storage
09hDeviceHub
0AhInterfaceCDC-Data
0BhInterfaceSmart Card
0DhInterfaceContent Security
0EhInterfaceVideo (UVC)
0FhInterfacePersonal Healthcare
10hInterfaceAudio/Video Devices
11hDeviceBillboard Device Class
12hInterfaceUSB Type-C Bridge Class
3ChInterfaceI3C Device Class
DChBothDiagnostic Device
E0hInterfaceWireless Controller
EFhBothMiscellaneous
FEhInterfaceApplication Specific
FFhBothVendor Specific

http://www.howtogeek.com/192732/android-usb-connections-explained-mtp-ptp-and-usb-mass-storage/

USB Video Class (UVC)

USB Video Class (UVC)

http://pollos-blog.blogspot.com/2014/10/usb-video-class.html

USB MTP

MTP (Media Transfer Protocol) 是 PTP (Picture Transfer Protocol) 的擴充。PTP 設計只用來下載相片, MTP 可和行動裝置間雙向傳送 music files、media files、以及 personal information。

MTP 是 "Windows Media" 框架的一部分而和 Windows Media Player 關係密切。2008,MTP 成為標準 USB device class,擴充 PTP 並共用相同 class code。2011,成為和 Android 間傳送檔案的標準方式。

參考:

  1. https://en.wikipedia.org/wiki/Media_Transfer_Protocol
  • 相關

2022年5月27日 星期五

Remote Desktop

遠端桌面

Remote Desktop Protocol (RDP) 是 Microsoft proprietary protocol,只運作在 Windows,client 則不限。

Virtual Network Computing (VNC)

X11

NX

參考

2022年5月22日 星期日

Find Duplicate Files

檔案算 checksum -> checksum 排序找出相同的

以下待測試

find . ! -empty -type f -exec md5sum {} + | sort | uniq -w32 -dD
find . ! -type d -exec cksum {} ; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ‘ ‘ | uniq -d | grep -hif – /tmp/f.tmp > duplicates.txt 

移除檔案

GUI

SIP header Via

所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...