无法在 .net 2.0 中接收串行数据,使用 rs232 到 rs485 转换器 [英] Can't receive serial data in .net 2.0, using rs232 to rs485 converter

查看:63
本文介绍了无法在 .net 2.0 中接收串行数据,使用 rs232 到 rs485 转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 .Net 2.0 串行端口类.直到今天,我才遇到它.

I've done a good deal of RS232 work using the .Net 2.0 serialport class. I've never had trouble with it, until today.

我正在与使用 RS485 协议的公司硬件进行通信.我正在使用 B & 的 RS232 到 RS485 转换器设备.B 电子.

I'm communicating with a piece of company hardware that uses the RS485 protocol. I'm using an RS232 to RS485 converter device from B & B electronics.

我可以很好地发送数据,并看到它在另一端收到.但是,我的 data_received 事件从不触发,即使使用 BytesToRead 我也看不到任何返回.

I can send data just fine, and see it received on the other side. However, my data_received event NEVER fires, and even using BytesToRead I never see anything coming back.

ReadExisting 也为空.

ReadExisting comes up empty as well.

我们启动了 232Analyzer,我可以使用该应用程序发送和接收数据包.我假设这与 .Net 2.0 串行类有关.

We fired up 232Analyzer, and I can send AND receive packets with that application. I'm assuming this has something to do with the .Net 2.0 serial class.

有什么想法吗?

推荐答案

事实证明(经过数小时的研究和尝试)是这样设置的:

It turns out (after hours of researching and trying) that setting this:

.DtrEnable = True

.DtrEnable = True

成功了.我以前从未使用过 DTR 属性,但无论是我正在使用的这台设备的问题,还是我遗漏的其他东西 - 都做到了.

did the trick. I've never had to use the DTR properties before, but whether it's an issue with this one device I'm working with, or something else I'm missing - that did it.

我认为这可能会让其他人免于头痛.

I thought this might save someone else a headache down the road.

这篇关于无法在 .net 2.0 中接收串行数据,使用 rs232 到 rs485 转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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