C#中串口的电源设置 [英] Power Settings of Serialport in C#

查看:137
本文介绍了C#中串口的电源设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我有串口加速度计,我通过USB转串口电缆连接到PC。当我用Hyerterminal,AccessPort和Teraterm进行测试时。当我连接到COM端口时,它显示电源指示灯亮。但是,当我尝试使用与Hyperterminal相同配置的C#代码时,我正在成功连接端口,但这些模块没有打开电源指示灯,它无法正常工作。你能否告诉我这是他们在C#串口中为串口提供电源的一些具体配置。





谢谢

解决方案

串口不提供电源,引脚按顺序:



1:DCD或数据载波检测

2:接收或接收

3:TX或传输

4:DTR或数据终端就绪

5 :信号接地

6:DSR或数据集就绪

7:RTS或要求发送

8:CTS或清除发送

9:RI或振铃指示器



这些引脚都没有为设备供电。 GND引脚用于在信号电平之间共用一个接地,以便RS232芯片可以检测到与器件相同的电平(称为接地参考)。



您需要改善您的问题 [ ^ ]并添加有关设备及其连接方式的详细信息,可能需要其他一个引脚变为低电平,如DTR或CTS,然后再发送数据。


只需添加关于Ron Beyer关于串口引脚排列的评论 - Hyperterminal很可能将一些输出信号引脚设置为高电平并且你的设备正在读取它们并自行开启(如果它的抽取率很低,它实际上可能也会从它们自身供电足够的,RS232信号通常可以很好地驱动低功率LED,但它们通常会遇到远高于几mA的任何东西。)



因此尝试使用输出信号DtrEnable和RtsEnable - 他们可能会打开你的设备!


感谢您分享您的知识。好吧,我启用了DtrEnable和RtsEnable,现在设备工作正常。我注意到功率LED从这些信号中获得了功率。



 _ serialPort =  new  SerialPort(  COM3); 
_serialPort.StopBits = StopBits.One;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8 ;
_serialPort.BaudRate = 38400 ;
_serialPort.RtsEnable = true ;
_serialPort.DtrEnable = true ;


Hi
I have serial port accelerometer which i am connecting to PC via "USB to Serial" Cable. When i have tested it with Hyerterminal, AccessPort and Teraterm. It shows power light ON when i connect to the COM port. But when i am trying to use it with C# code with same configurations as Hyperterminal, I am getting success to connect with port but this modules don't turn on Power light and it is not working. Can you tell me that is their some specific configuration in C# serial port to provide power on serial port.


Thanks

解决方案

Serial ports do not provide power, the pins are, in order:

1: DCD or Data Carrier Detect
2: RX or Receive
3: TX or Transmit
4: DTR or Data Terminal Ready
5: Signal Ground
6: DSR or Data Set Ready
7: RTS or Request To Send
8: CTS or Clear To Send
9: RI or Ring Indicator

None of those pins provide power to a device. The GND pin is to share a ground between signal levels so that the RS232 chip can detect the same levels as the device (called a ground reference).

You will need to Improve your question[^] and add details about the device and how you connect to it, perhaps it requires one of the other pins to go low, like DTR or CTS before it will send data.


Just to add to Ron Beyer's comments about pinout on serial - it is quite likely that Hyperterminal is setting some of the output signal pins high and your device is reading those and turning itself on (it may also be actually powering itself from them, if it's draw is low enough, RS232 signals can normally drive low power LED's pretty well, but they normally struggle with anything much above a couple of mA.)

So try playing with the output signals DtrEnable and RtsEnable - they may switch your device on!


Thank you for sharing your knowledge. Well I have enabled DtrEnable and RtsEnable now device is working fine. I have noticed that power LED was getting power from these signals.

_serialPort = new SerialPort("COM3");
_serialPort.StopBits = StopBits.One;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8;
_serialPort.BaudRate = 38400;
_serialPort.RtsEnable = true;
_serialPort.DtrEnable = true;


这篇关于C#中串口的电源设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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