C#中的serial_port_RTS_pin_problem [英] serial_port_RTS_pin_problem in C#

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

问题描述

您好,

我尝试在Winforms C#中执行一个简单的应用程序,在win XP下读取或写入串口上的一些数据。我尝试与RS485上的工业控制器通信。所以我有一个转换器RS232-RS485转换器控制的信号是RTS(RS485半双工开关RX或TX)

我的通信协议是英特尔旧版BitBus的一个版本。当我想发送一些东西(例如地址,命令)时,我必须像以下一样设置RTS线:

//这里串口是用波特率,奇偶校验等定义的。

byte [] command = new byte [1];

command [0] = 0x03;

port.Open();

port.RtsEnable = true;

port.Write(command,0,1);

port.RtsEnable = false;

//这里shold开始接收数据?

现在让我的问题解决了:我设置RTS线后需要immediatley发送数据。

我用数字示波器查看信号,我在RTS线路切换到实际数据发送(写入功能)之间有7mS的时间延迟。

实际上我试图用C#程序替换x86 ASM中写的旧驱动程序(巫婆不能在XP下运行)。在DOS驱动程序下我没有任何延迟,因此我的C#通信无法正常工作。如何将RTS行与C#中的写入端口数据同步???

任何建议都将不胜感激。


提前致谢并且一切顺利

Svcc。

解决方案

你是说你需要延迟还是你的设备不能延迟工作?

无论如何,你应该只能说出你所说的内容。

打开,设置引脚电平,写入数据,设置引脚电平。



您是说您需要延迟还是您的设备无法延迟工作?

无论如何,您应该能够满足您的要求。

打开,设置引脚电平,写入数据,设置引脚电平。



您好,


首先感谢您的回答,
在RTS引脚设置时刻和

将数据写入端口之间不需要
ny
延迟
。我的C#app中RTSenable = true和RTSenable = false

之间的时间间隔是20mS,原始dos(驱动程序)是1.5mS。在这个时间间隔内

我必须发送命令。我怎么能用C#来管理它???

一切顺利


赢了你的设备停止,直到RTS引脚设置为低电平?

所以当你说RTS =高时。

设备会好吧,我会得到的所以我会等待它

然后你可以随时发送命令。

那么当你完成后,你用RTS =低表示它?


当你尝试这样做时会发生什么?


我只做了没有流量控制的rs232,所以我的知识有点儿限于

Hello,

I try to do a simple application in Winforms C# to read or write some data on serial port under win XP.I try to communicate with an industrial controller on RS485.So I have an converter RS232- RS485 The signal who does the converter control is RTS (switch RX or TX for RS485 half duplex)
My communication protocol is a version of old BitBus by Intel. When I want to sent something(eg. Address, command) I have to set the RTS line like:
//here the serial port is defined with baud rate, parity, etc.
byte[] command = new byte[1];
command[0] = 0x03;
port.Open();
port.RtsEnable = true;
port.Write(command, 0, 1);
port.RtsEnable = false;
// here shold begin to receive data?
Now commes my problem: I need immediatley after I set RTS line to send data.
I looked with an digital scope to signals and I have an aprox 7mS time delay between the switching of RTS line and the actual data sending (write fuction).
Actually I?m trying to replace with the C# program an old driver writen in x86 ASM (witch cannot be runned under XP).Under the DOS driver I don?t have any delay and because of this my C# communication is not working. How to syncronise RTS line with the write to port data in C#??
Any suggestions will be greatly appreciated.

Thanks in advance and all the best
Svcc.

解决方案

Are you saying you NEED to delay or that your device does not work WITH a delay?
At any rate you should be able to just what you stated.
Open, set pin level, write data, set pin level.


Are you saying you NEED to delay or that your device does not work WITH a delay?
At any rate you should be able to just what you stated.
Open, set pin level, write data, set pin level.

Hello,

first thank you for answering,
I don''t need any delay between the RTS pin set moment and
write data to port. The time interval between RTSenable=true and RTSenable=false
in my C# app is 20mS and in the original dos(driver) is 1.5mS. In this interval
I have to send the command.How can I mannage this in C#??
All the best


Won''t your device halt until the RTS pin is set low?
So when you say RTS=high.
The device goes "ok i''m gonna get something so i''ll wait for it"
Then you can send your command whenever.
Then when you''re done, you signify it with RTS=low?

What happens when you try and do it?

I''ve only done rs232 without flow control, so my knowledge is a bit limited


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

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