简体   繁体   English

通过USB访问串行端口

[英]Access Serial Port VIA USB

I want to access a scale hooked up via a RS232 Serial Port. 我想访问通过RS232串行端口连接的秤。 The machine I'm writing the C# code on does not have a serial port, so I was going to use a USB to Serial Port dongle. 我正在编写C#代码的机器没有串行端口,因此我打算使用USB到串行端口的软件狗。 Will anything need to be changed with my code? 我的代码是否需要更改?

No, they emulate a serial port at the driver level. 不,它们在驱动程序级别模拟串行端口。 Your code, nor the SerialPort class, won't know the difference. 您的代码或SerialPort类都不知道它们之间的区别。 The only temptation you'll have to resist is unplugging the USB cable while the port is opened. 您唯一需要抗拒的诱惑就是在打开端口时拔下USB电缆。 That works about as well as unplugging a flash memory stick while Windows is writing to it. 这与在Windows对其进行写操作时拔下闪存棒一样有效。 Your customer will do it anyway, but they usually get bored with it after a couple of times. 您的客户仍然会这样做,但通常会在几次之后就感到无聊。

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

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