简体   繁体   English

如何访问USB驱动程序直接发送命令? C#

[英]How to access a usb driver to directly send commands? C#

I´m currently developing software to communicate with the TM-T88V Epson printer. 我目前正在开发与TM-T88V Epson打印机通信的软件。 Everything works fine via serial ports, however, I also need to be able to send and receive commands via USB (and later ethernet). 一切都可以通过串口工作,但是,我还需要能够通过USB(以及以后的以太网)发送和接收命令。 I've found that this is considerably more complex than serial ports, there is no native library for controlling USB ports. 我发现这比串行端口复杂得多,没有用于控制USB端口的本机库。

Most questions and tutorials on this topic refer to printing via System.Drawing.Printing, or using external downloaded libraries to access the bus. 关于此主题的大多数问题和教程都涉及通过System.Drawing.Printing进行打印,或使用外部下载的库来访问总线。 Also, there are a lot of references to using some of the System.Management classes to search for events and properties of the USB ports, quite useful, but no message interchange. 此外,有很多参考使用一些System.Management类来搜索USB端口的事件和属性,非常有用,但没有消息交换。 Nonetheless, what I think would be the best is to use the printer driver if possible and use it for this task, I guess that's what the driver is for... I'm definitely not an expert and I've only used serial communication for whatever reason through my major. 尽管如此,我认为最好的是尽可能使用打印机驱动程序并将其用于此任务,我想这就是驱动程序的用途......我绝对不是专家,我只使用串行通信无论出于什么原因通过我的专业

Basically, I want to detect, select, send and receive messages from a USB port. 基本上,我想从USB端口检测,选择,发送和接收消息。 If the printer driver is up for this task great, if not whatever resource is useful. 如果打印机驱动程序适合这项任务很好,如果没有任何资源是有用的。 Note that I already have all the messages and message structure. 请注意,我已经拥有所有消息和消息结构。

Here is very simple code to get started : 这是一个非常简单的入门代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;


namespace ConsoleApplication108
{
    class Program
    {
       static void Main(string[] args)
        {
            string[] names = SerialPort.GetPortNames();

        }
    }

}

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

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