玩转USB虚拟串口

1 Linux serial
1.1 Linux控制串口的各种属性
busybox stty -F /dev/ttyS0 -a
busybox setserial -a /dev/ttyS0

busybox
https://busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/

1.2 Linux slcand
slcan:the serial line CAN(using tty line discipline,N_SLCAN),用于CAN dongle,将Linux上的CAN转串口(ttyUSB0或者ttyACM0)桥接到socketCAN

1.3 Modem option
Linux option.c:最早是适配比利时无线网络设备厂商Option的modem,Option是欧洲唯一一家无线网卡、USB闪存和嵌入式笔记本上网模块厂商。

2 Windows VCP
2.1 禁止USB转串口序列号检查
Write a reg file(Disable_Ser_SN_CHK.reg), then add the following comment.

Windows Registry Editor Version5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags]
"GlobalDisableSerNumGen"=hex:01

2.2 USB Protocol Analyzer Beagle
1)修改时间戳到Wall时间
Time-Item Right Click>>Timestamp Reference>>Wall Time View

2)Guide
Beagle使用前,USB Host的VBUS必须连接,否则会探测不到硬件,并且显示“host disconnect”

3 Windows pyserial
3.1 install
https://pypi.python.org/pypi/pyserial

pip install pyserial

3.2 showcase
import io
import os
import re
import shutil
import sys
import serial
from serial.tools import list_ports

arg0_proc_name = ''
def print_usage():
    print('\nUsage: python ' + arg0_proc_name + ' <COM_PORT>\n')

def my_print(string):
    for char in string:
        print(char, end='')

def list_serial_ports():
    print('Available serial ports:\n')
    for dev in list_ports.grep('COM', include_links=True):
        print(dev)

def serial_reader(port):
    try:
        while True:
            # port.write(('\x1c' + '\n').encode())
            count = port.inWaiting()
            if count > 0:
                raw = port.read(count)
                my_print(raw.decode())
    except KeyboardInterrupt:
            print('Got ^C signal, will close '  + port.name)

def main():
    global arg0_proc_name
    arg0_proc_name = sys.argv[0]
    if sys.argv[0].rfind(os.path.sep) > 0:
        index = sys.argv[0].rfind(os.path.sep)
        arg0_proc_name = sys.argv[0][index+1:]

    if len(sys.argv) < 2:
        print_usage()
        list_serial_ports()
        exit(0)

    print('Enter Ctrl + C to exit')
    try:
        port = serial.Serial(sys.argv[1],
            baudrate=115200,
            bytesize=serial.EIGHTBITS,
            stopbits=serial.STOPBITS_ONE,
            parity=serial.PARITY_NONE,
            xonxoff=0,
            rtscts=0,
            timeout=None)
    except IOError:
        print('Please ensure close all applications that opened ' + sys.argv[1])
        exit(0)

    # script_dir = os.path.split(os.path.realpath(sys.argv[0]))[0]
    serial_reader(port)
    if port != None:
        port.close()

if __name__ == '__main__':
    main()

4 Abbreviations
ARC:Argonant RISC Core
AT91SAM9260:SAM means Smart ARM-based Microcontroller
ATMEL SAMBA:ATMEL Smart ARM-based Microcontroller Boot Assistant
CC2530:TI ChipCon2530
DWC2:Design Ware Controller 2,Apple的嵌入式设备,包括iPad和iPhone都是使用的DWC2
FTDI_SIO:FTDI Serial Input/Output
ISP1161:Philips' Integrated host Solution Pairs 1161,“Firms introduce USB host controllers”,https://www.eetimes.com/document.asp?doc_id=1290054
SL811HS:Cypress/ScanLogic 811 Host/Slave,性能上与ISP1161(Integrated host Solution Pairs 1161)相当
TDI:TransDimension Inc.,该公司首先发明了将TT集成到EHCI RootHub中的方法,这样对于嵌入式系统来说,就省去了OHCI/UHCI的硬件,同时降低了成本,作为对该公司的纪念,Linux内核定义了宏ehci_is_TDI(ehci);产品UHC124表示USB Host Controller;收购了ARC USB技术;现已被chipidea收购,chipidea又被mips收购
TLV:TI Low Value,高性价比
TPS:TI Performance Solution
TT:Transaction Translator(事务转换器,将USB2.0的包转换成USB1.1的包)
USB BH reset:Bigger Hammer or Brad Hosler,表示warm reset;you may be confused why the USB 3.0 spec calls the same type of reset "warm reset" in some places and "BH reset" in other places. "BH" reset is supposed to stand for "Big Hammer" reset, but it also stands for "Brad Hosler". Brad died shortly after the USB 3.0 bus specification was started, and they decided to name the reset after him. The suggestion was made shortly before the spec was finalized, so the wording is a bit inconsistent
WHL:Python Wheel Package
Zadig:an Automated Driver Installer GUI application for WinUSB, libusb-win32 and libusbK

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值