在没有任何适配器的情况下为USB端口分配串行端口 [英] Assign a serial port to usb port without any adapter

查看:112
本文介绍了在没有任何适配器的情况下为USB端口分配串行端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们!



现在我尝试找到一个代码,用于在极点显示中显示文本框文本。我已经尝试了一些代码,我已经浏览了很多网站,但我无法找到方法。



首先,我想知道是否可能?如果可能的话怎么做?



我试过下面的链接和下面的按钮点击简单代码。



http://www.merchantsoft.com/technote/Peripherals_and_Hardware/Pole_Displays/USB_Logic_Controls_POle_Displays_-_Win_7.htm



private void button1_Click(object sender,EventArgs e)

{

SerialPort sp = new SerialPort(" COM5",9600,Parity.None,8,StopBits .One);

sp.Open();

//清除显示

sp.Write(Convert.ToString((char )12));



//第一行到这里

sp.WriteLine(" Total:" + textBox1.Text + RM);



sp.Close();

sp.Dispose();

sp = null;





}





显示以下错误



端口'COM5'不存在。



我插上了它没有检测到的杆显示器呃PORTS(COM&LPT)。它已在人机接口设备下检测到



我必须将文本框内输入的任何文字传递到极点显示器。



http://www.merchantsoft.com/technote/Peripherals_and_Hardware/Pole_Displays/USB_Logic_Controls_POle_Displays_-_Win_7.htm



我按照上面的链接配置杆显示。在这个链接中,他们建议称为Virtual Com Port Driver。我从下面的链接下载了一个驱动程序,



http://www.ftdichip.com/Drivers/VCP.htm



我安装了驱动程序,安装后它没有提示任何东西。

任何人都可以建议我使用虚拟COM端口驱动程序的方式





提前致谢。

解决方案

USB端口仅在插入适配器时在Windows中创建。当移除适配器时,串行端口也是如此。除了捕获错误并意识到适配器没有插入之外没有任何其他方法。



另请注意,如果用户插入如果适配器进入不同的USB端口,COM端口将发生变化,如果使用不同的适配器,它们也可能会发生变化,或者甚至可以在设备管理器中手动更改,所以尽量不要硬编码串口。

Hi friends!

Now I try to find a code for displaying a text box text into a pole display. I have tried some codes and I have gone through lots of websites, but I couldn't be able to find the way.

First of all I want to know whether is it possible or not? If possible how to do that?

I tried like the below link and the below simple code for the button click.

http://www.merchantsoft.com/technote/Peripherals_and_Hardware/Pole_Displays/USB_Logic_Controls_POle_Displays_-_Win_7.htm

private void button1_Click(object sender, EventArgs e)
{
SerialPort sp = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
sp.Open();
// to clear the display
sp.Write(Convert.ToString((char)12));

// first line goes here
sp.WriteLine("Total : " + textBox1.Text + " RM");

sp.Close();
sp.Dispose();
sp = null;


}


The below error is displaying

The port 'COM5' does not exist.

When I plugged the pole display it hasn't detect under "PORTS (COM & LPT)". It has been detected under "Human Interface Devices"

I have to pass whatever text typed inside the text box to the pole display.

http://www.merchantsoft.com/technote/Peripherals_and_Hardware/Pole_Displays/USB_Logic_Controls_POle_Displays_-_Win_7.htm

I followed the above link to configure the pole display. In this link they are suggest something called Virtual Com Port Driver. I've downloaded a driver from the below link,

http://www.ftdichip.com/Drivers/VCP.htm

I installed the driver, after installation it doesn't prompt for anything.
Can anyone suggest me the way to use the Virtual COM Port Driver


Thanks in advance.

解决方案

USB ports are only created in Windows when the adapter is plugged in. When the adapter is removed, so is the serial port. There isn't any way around this other than to catch the error and realize that the adapter isn't plugged in.

Also keep in mind that if the user plugs the adapter into a different USB port, the COM port will change, it may also change if they use a different adapter, or they could even change it manually in the device manager, so try not to hard-code your serial port.


这篇关于在没有任何适配器的情况下为USB端口分配串行端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆