我是靠谱客的博主 哭泣秀发,最近开发中收集的这篇文章主要介绍玩转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_MACHINESYSTEMCurrentControlSetControlusbflags]
"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

最后

以上就是哭泣秀发为你收集整理的玩转USB虚拟串口的全部内容,希望文章能够帮你解决玩转USB虚拟串口所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部