串口(com,boudrate,stopbit等) [英] Serial port (com, boudrate, stopbit etc)

查看:129
本文介绍了串口(com,boudrate,stopbit等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有C#编程希望连接到基于RTU Modbus的控制器,我希望使用Visual Studio C#我的项目实时记录我的PC温度。任何机构都可以通过收到您的序列号样本来帮助我解决我的问题。我希望用PC连接实时控制器。



我尝试过:



Hi guys, I have C# programming wish to connected to my controller based on RTU Modbus, I wish record temperature in my PC real time using Visual Studio C# my project. Any body help me to solve my problem by received Serial Code Samples of yours. i wishing connected Real Time Controller with PC.

What I have tried:

"Connect!" Then
    scm485.PortName = cbComm0.Text
    scm485.BaudRate = "9600"
    scm485.DataBits = "8"
    scm485.Parity = Parity.None
    scm485.StopBits = StopBits.Two
    scm485.RtsEnable = False
    scm485.DtrEnable = False
    scm485.WriteTimeout = 10000
    scm485.ReadTimeout = 10000
    scm485.Handshake = Handshake.XOnXOff
    scm485.Open()

    if scm485.IsOpen = True Then
        cmdEx.Text = "Disconnect!"

推荐答案

嗯,你需要知道你需要什么寄存器/线圈读取 - 也就是MODBUS的功能,以及从中获取数据所需的寄存器/线圈地址 - 如果您正在使用.Net串口实现,那么不幸的是,它已经是sh * t creek,它的DataReceived事件可能会或者可能会在串口线的另一端不能很好地使用你的设备



这里设置了一个项目 C#/ .NET 2.0中的简单Modbus协议 [ ^ ]可以帮助您入门,这里有一个MODBUS协议手册 http://modbus.org/docs/PI_MBUS_300.pdf [ ^ 可能有用



因为OG指出,你曾经告诉过我们你需要什么样的信息/帮助和/或你用什么MOD​​BUS设备'重新使用,这就是一个可以通过帮助提供给你的那个





这个 GitHub - NModbus4 / NModbus4:NModbus4是Modbus协议的C#实现。 [ ^ ]也可以帮助

[/ edit]
Well, you need to know what registers/coils you need to read - that is, what MODBUS functions, and the register/coil addresses you need to get data from - If you're using the .Net serial port implementation you're already up sh*t creek unfortunately, its DataReceived event may or may not play well with your device on the other end of the serial cable

There's a project set up here Simple Modbus Protocol in C# / .NET 2.0[^] that may help you get started, and a MODBUS protocol manual here http://modbus.org/docs/PI_MBUS_300.pdf[^] that may be useful

since as OG points out, you havnt told us what information/help you need and/or what MODBUS device you're using, thats about as much as one can offer you by way of help

[edit]
this GitHub - NModbus4/NModbus4: NModbus4 is a C# implementation of the Modbus protocol.[^] may also help
[/edit]


这篇关于串口(com,boudrate,stopbit等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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