注册名:

密码:

个人注册

企业注册

商务申请

商务管理平台

企业管理平台

个人管理平台

我的工控博客

中国工控网www.chinakong.com

首页 | 新闻中心 | 工控论坛 | 经验视点 | 工控商务 | 电气手册 | 工控博客 | 招聘求职 | 网上调查 | 企业中心 | 供求信息 | 资料中心 | 工控书店

所在位置:工控论坛 -- 工业自动化网络论坛 -- 工业自动化网络论坛(非专题) -- 协议标准

中国工控网搜索:

 登陆:密码:  注册  密码

搜索:

工业自动化网络论坛(非专题)分类  

全部论题

协议标准

硬件配置

发表人:jianhai55 发表时间:2008/11/22 15:48:00  

 

 本栏论题: C#结合串口通信类实现串口通信源代码  [4450]

    mycom是串口通信类,在本blog前一篇中有完整代码。( C#串口通信编程类(修改版) )
    下面是串口通讯测试程序的源代码,将mycom类放在此项目中
    可以实现简单的串口通信,希望读者能通过这个程序对串口通信过程有一个初步的了解:
   
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Threading;
    namespace BusApp
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.Button button3;
    private System.Windows.Forms.Button button4;
    private System.Windows.Forms.TextBox textBox8;
    private System.Windows.Forms.Label label7;
    public int iPort=1; //1,2,3,4
    public int iRate=9600; //1200,2400,4800,9600
    public byte bSize=8; //8 bits
    public byte bParity=0; // 0-4=no,odd,even,mark,space
    public byte bStopBits=1; // 0,1,2 = 1, 1.5, 2
    public int iTimeout=1000;
    public mycom mycom1=new mycom();
    public byte[] recb;
    private System.Windows.Forms.TextBox msg;
    private System.Windows.Forms.TextBox t_port;
    private System.Windows.Forms.TextBox t_rate;
    private System.Windows.Forms.TextBox t_bytesize;
    private System.Windows.Forms.TextBox t_stopbyte;
    private System.Windows.Forms.TextBox t_parity;
    private System.Windows.Forms.TextBox t_send;
    private System.Windows.Forms.Button button5; //readTimeOut
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
    public Form1()
    {
    InitializeComponent();
    }
    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }
    #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.msg = new System.Windows.Forms.TextBox();
    this.label1 = new System.Windows.Forms.Label();
    this.label2 = new System.Windows.Forms.Label();
    this.t_send = new System.Windows.Forms.TextBox();
    this.button1 = new System.Windows.Forms.Button();
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.button2 = new System.Windows.Forms.Button();
    this.t_port = new System.Windows.Forms.TextBox();
    this.label3 = new System.Windows.Forms.Label();
    this.t_rate = new System.Windows.Forms.TextBox();
    this.label4 = new System.Windows.Forms.Label();
    this.t_bytesize = new System.Windows.Forms.TextBox();
    this.label5 = new System.Windows.Forms.Label();
    this.t_stopbyte = new System.Windows.Forms.TextBox();
    this.label6 = new System.Windows.Forms.Label();
    this.t_parity = new System.Windows.Forms.TextBox();
    this.button3 = new System.Windows.Forms.Button();
    this.button4 = new System.Windows.Forms.Button();
    this.textBox8 = new System.Windows.Forms.TextBox();
    this.label7 = new System.Windows.Forms.Label();
    this.button5 = new System.Windows.Forms.Button();
    this.groupBox1.SuspendLayout();
    this.SuspendLayout();
    //
    // msg
    //
    this.msg.ForeColor = System.Drawing.Color.Green;
    this.msg.Location = new System.Drawing.Point(0, 0);
    this.msg.Multiline = true;
    this.msg.Name = "msg";
    this.msg.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
    this.msg.Size = new System.Drawing.Size(512, 264);
    this.msg.TabIndex = 0;
    this.msg.Text = "";
    //
    // label1
    //
    this.label1.Location = new System.Drawing.Point(16, 24);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(56, 16);
    this.label1.TabIndex = 1;
    this.label1.Text = "串口号:";
    //
    // label2
    //
    this.label2.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(64)), ((System.Byte)(0)));
    this.label2.Location = new System.Drawing.Point(8, 280);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(80, 16);
    this.label2.TabIndex = 1;
    this.label2.Text = "设置数据包:";
    //
    // t_send
    //
    this.t_send.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    this.t_send.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(128)), ((System.Byte)(0)));
    this.t_send.Location = new System.Drawing.Point(80, 272);
    this.t_send.Name = "t_send";
    this.t_send.Size = new System.Drawing.Size(344, 21);
    this.t_send.TabIndex = 2;
    this.t_send.Text = "";
    //
    // button1
    //
    this.button1.Location = new System.Drawing.Point(432, 272);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(40, 23);
    this.button1.TabIndex = 3;
    this.button1.Text = "发送";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    //
    // groupBox1
    //
    this.groupBox1.Controls.Add(this.button2);
    this.groupBox1.Controls.Add(this.t_port);
    this.groupBox1.Controls.Add(this.label1);
    this.groupBox1.Controls.Add(this.label3);
    this.groupBox1.Controls.Add(this.t_rate);
    this.groupBox1.Controls.Add(this.label4);
    this.groupBox1.Controls.Add(this.t_bytesize);
    this.groupBox1.Controls.Add(this.label5);
    this.groupBox1.Controls.Add(this.t_stopbyte);
    this.groupBox1.Controls.Add(this.label6);
    this.groupBox1.Controls.Add(this.t_parity);
    this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(64)), ((System.Byte)(0)));
    this.groupBox1.Location = new System.Drawing.Point(8, 304);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(176, 216);
    this.groupBox1.TabIndex = 4;
    this.groupBox1.TabStop = false;
    this.groupBox1.Text = "参数设置";
    //
    // button2
    //
    this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
    this.button2.Location = new System.Drawing.Point(80, 184);
    this.button2.Name = "button2";
    this.button2.TabIndex = 3;
    this.button2.Text = "应用设置";
    this.button2.Click += new System.EventHandler(this.button2_Click);
    //
    // t_port
    //
    this.t_port.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    this.t_port.Location = new System.Drawing.Point(80, 16);
    this.t_port.Name = "t_port";
    this.t_port.Size = new System.Drawing.Size(80, 21);
    this.t_port.TabIndex = 2;
    this.t_port.Text = "1";
    //
    // label3
    //
    this.label3.Location = new System.Drawing.Point(16, 58);
    this.label3.Name = "label3";
    this.label3.Size = new System.Drawing.Size(56, 16);
    this.label3.TabIndex = 1;
    this.label3.Text = "波特率:";
    //
    // t_rate
    //
    this.t_rate.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    this.t_rate.Location = new System.Drawing.Point(80, 50);
    this.t_rate.Name = "t_rate";
    this.t_rate.Size = new System.Drawing.Size(80, 21);
    this.t_rate.TabIndex = 2;
    this.t_rate.Text = "9600";
    //
    // label4
    //
    this.label4.Location = new System.Drawing.Point(16, 92);
    this.label4.Name = "label4";
    this.label4.Size = new System.Drawing.Size(56, 16);
    this.label4

以下是关于《C#结合串口通信类实现串口通信源代码》论题的回复(共4篇)

回复人:cn18show 

 回复时间:2009/9/19 4:00:00

支持(387) | 反对(300)

 

    大家知道“易展五周年庆 50万感恩回馈”的活动吗?就是这里:http://www.18show.cn/5/?m=189

回复人:lupei 

 回复时间:2011/8/19 15:51:00

支持(647) | 反对(291)

 

    本人现有北京纵横科技的hmibuilder组态软件150点,中间变量不算点,现欲清仓出售,1000块一套,正版,有软件狗,包装盒里有详细的说明书和功能手册,有兴趣的qq联系。
    qq:1455457295
   

回复人:369963794 

 回复时间:2015/1/31 10:48:00

支持(283) | 反对(631)

 

    很好!

回复人:杭州双翌 

 回复时间:2017/6/29 17:11:00

支持(294) | 反对(266)

 

    杭州双翌自动化科技有限公司主要致力于发展
   
    MicroPos机械手视觉定位系统:MicroPos机械手视觉定位系统是双翌光电自主研发的软件算法,MicroPos功能齐备,使用简便,满足自动化绝大部分的应用需求,开放的通讯接口,能快速搭建如1相机的拾取加工、2相机或者多颗相机的高精装配等应用
   
    机器视觉:机器视觉系统主要由三部分组成:图像的获取、图像的处理和分析、输出或显示,双翌为客户提供配套的机器视觉产品。从光源、镜头、相机到图像处理库,实现最大化脱离人工干预的自动化,为工业4.0助力
   
    MicroDistPro对位系统 :MicroDistPro视觉对位系统是双翌光电科技专门针对高精度对位需求而自主研发的视觉对位产品。先进的机器视觉技术与运动控制相结合,无需提供精密的辅助工具,就能完成精确的系统自标定,实现精准的对位应用。简单易学的使用理念,强大的算法功能,助你快速实现高效的生产。MicroDistPro视觉对位系统有着广泛的应用领域,在精密加工与装配方面发挥着重要作用。双翌光电科技追求在自动控制领域中实现客户的梦想,为客户创造与众不同的价值。
   
    图像处理库: SYMV是面向工业自动化的图像处理库,为你带来简洁实用的6个类库:SYBASE/SYBLOB/SYCOLOR/SYGAUGE/SYIMGPROC/SYMCH,涵盖定位,识别,测量等机器视觉主要应用领域。 SYMV图像处理库,将继续立足于工业机器视觉,不断改进性能,增加更多实用性功能。
   
    杭州双翌自动化科技有限公司 宋永辉(YongHui Song)Maketing Manager
    TEL:0571-28350143 FAX:0571-88315242
    Add:杭州市西湖区文三路249号联强大厦A座421室
    Web:www.shuangyi-tech.com
    Mobile: (+86)135-8847-3224

如果要回复本栏论题,请首先中国工控网www.chinakong.com

·如果你已经是中国工控网www.chinakong.com成员,请直接登录。

·如果你还不是中国工控网www.chinakong.com成员,请首先注册,注册为免费!

注册名:

密  码:

           注册中国工控网www.chinakong.com
           忘记密码

关闭该窗口

关于我们     免责声明     服务项目     广告联系     友情链接     联系方式     意见反馈     设为首页     加入收藏

 ©2023-2025 中国工控网(www.chinakong.com) 版权所有 豫ICP备17046657号

管理员信箱:chinakong98@163.com  服务热线:13525974529

洛阳博德工控自动化技术有限公司

中国    洛阳