简体   繁体   English

如何连接不公开串行接口的 USB 设备?

[英]How I can interface a USB device that does not expose a serial interface?

I want to make a custom program that will allow me to interface a Salae Logic usb logic analyzer.我想制作一个自定义程序,允许我连接 Salae Logic usb 逻辑分析仪。 So first and foremost I looked upon for any info regarding the usb in my linux box:因此,首先,我在我的 linux 框中查看了有关 usb 的任何信息:

$ lsusb
Bus 002 Device 002: ID 05e3:0732 Genesys Logic, Inc. All-in-One Cardreader
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 002: ID 4e53:5407  
Bus 001 Device 004: ID 0925:3881 Lakeview Research Saleae Logic
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Dmesg:消息:

[  428.549560] usb 1-6: new high-speed USB device number 4 using xhci_hcd
[  428.697722] usb 1-6: New USB device found, idVendor=0925, idProduct=3881, bcdDevice= 0.01
[  428.697727] usb 1-6: New USB device strings: Mfr=0, Product=0, SerialNumber=0

Is seems that does not expose a serial device like arduino (or any other FTDI interfacing device) like modems:似乎不会像调制解调器一样暴露像 arduino(或任何其他 FTDI 接口设备)这样的串行设备:

[  766.906266] usb 1-5: new full-speed USB device number 5 using xhci_hcd
[  767.056746] usb 1-5: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
[  767.056752] usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[  767.056756] usb 1-5: Manufacturer: Arduino (www.arduino.cc)
[  767.056759] usb 1-5: SerialNumber: 7533131313335170A061
[  767.088804] cdc_acm 1-5:1.0: ttyACM0: USB ACM device
[  767.089110] usbcore: registered new interface driver cdc_acm
[  767.089110] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

So supposedly I want to make a C++ (or any other language) software where I can read data from it how I can make my application to have access to a non usb-to-serial interfacing device?所以据说我想制作一个 C++ (或任何其他语言)软件,我可以从中读取数据如何让我的应用程序能够访问USB 到串行接口设备?

I mean for an arduino I could use the POSIX open as the example shows from this link :我的意思是对于 arduino 我可以使用 POSIX open ,如此链接中的示例所示:

    #include <stdio.h>   /* Standard input/output definitions */
    #include <string.h>  /* String function definitions */
    #include <unistd.h>  /* UNIX standard function definitions */
    #include <fcntl.h>   /* File control definitions */
    #include <errno.h>   /* Error number definitions */
    #include <termios.h> /* POSIX terminal control definitions */

    /*
     * 'open_port()' - Open serial port 1.
     *
     * Returns the file descriptor on success or -1 on error.
     */
    int open_port(void){
      int fd; /* File descriptor for the port */


      fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NDELAY);
      if (fd == -1)
      {
       /*
        * Could not open the port.
        */
        perror("open_port: Unable to open /dev/ttyS0 - ");
      } else{ 
        fcntl(fd, F_SETFL, 0); 
      }

      return (fd);
    }

But in my case I have no such a file descriptor to begin with according to dmesg .但就我而言,根据dmesg ,我没有这样的文件描述符。

Normally something like this is done with libusb, at least when you are in userspace (which your question suggests you are).通常这样的事情是用 libusb 完成的,至少当你在用户空间时(你的问题表明你是)。

USB transfers are a lot more complicated than a USB UART though, so brace yourself to deal with different endpoints, pipes, transfer modes and co USB 传输比 USB UART 复杂得多,因此请准备好处理不同的端点、管道、传输模式和 co

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM