xjx_user 发表于 2013-1-2 23:07:05

串口通信--网络实验2

<div class="postcontent"><div id="cnblogs_post_body">1.串口通信基本接线方法:http://download.csdn.net/detail/xuanzuonuo/4870715
(RS232c接口直接用电缆连接(短距离) 中间加两个调制解调器(长距离))
2.RS232C 9 脚接头信号列表:程序设计的指导文件:
pdf: http://download.csdn.net/detail/xuanzuonuo/4870727
ppt:http://pan.baidu.com/share/link?shareid=162969&uk=1678594189
实验项目:http://download.csdn.net/detail/xuanzuonuo/4870733
3.RS232C信号时序
4.MSComm 控件
5.Modem AT 指令集
<div class="cnblogs_Highlighter">using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace WindowsApplication2{/// <summary>/// Form1 的摘要说明。/// </summary>public class Form1 : System.Windows.Forms.Form{private System.Windows.Forms.Button button1;private System.Windows.Forms.Button button2;private System.Windows.Forms.TextBox textBox1;private System.Windows.Forms.TextBox textBox2;private AxMSCommLib.AxMSComm axMSComm1;private System.Windows.Forms.Button button3;private System.Windows.Forms.TextBox textBox3;/// <summary>/// 必需的设计器变量。/// </summary>private System.ComponentModel.Container components = null;public Form1(){//// Windows 窗体设计器支持所必需的//InitializeComponent();//// TODO: 在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(){System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));this.axMSComm1 = new AxMSCommLib.AxMSComm();this.button1 = new System.Windows.Forms.Button();this.button2 = new System.Windows.Forms.Button();this.textBox1 = new System.Windows.Forms.TextBox();this.textBox2 = new System.Windows.Forms.TextBox();this.button3 = new System.Windows.Forms.Button();this.textBox3 = new System.Windows.Forms.TextBox();((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).BeginInit();this.SuspendLayout();// // axMSComm1// this.axMSComm1.Enabled = true;this.axMSComm1.Location = new System.Drawing.Point(8, 312);this.axMSComm1.Name = "axMSComm1";this.axMSComm1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMSComm1.OcxState")));this.axMSComm1.Size = new System.Drawing.Size(38, 38);this.axMSComm1.TabIndex = 0;this.axMSComm1.OnComm += new System.EventHandler(this.axMSComm1_OnComm);// // button1// this.button1.Location = new System.Drawing.Point(16, 24);this.button1.Name = "button1";this.button1.TabIndex = 1;this.button1.Text = "拨号";this.button1.Click += new System.EventHandler(this.button1_Click);// // button2// this.button2.Location = new System.Drawing.Point(16, 64);this.button2.Name = "button2";this.button2.TabIndex = 1;this.button2.Text = "发送";this.button2.Click += new System.EventHandler(this.button2_Click);// // textBox1// this.textBox1.Location = new System.Drawing.Point(144, 64);this.textBox1.Name = "textBox1";this.textBox1.Size = new System.Drawing.Size(136, 21);this.textBox1.TabIndex = 3;this.textBox1.Text = "";this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);// // textBox2// this.textBox2.AcceptsReturn = true;this.textBox2.AutoSize = false;this.textBox2.Location = new System.Drawing.Point(144, 128);this.textBox2.Multiline = true;this.textBox2.Name = "textBox2";this.textBox2.Size = new System.Drawing.Size(160, 176);this.textBox2.TabIndex = 4;this.textBox2.Text = "";this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);// // button3// this.button3.Location = new System.Drawing.Point(16, 112);this.button3.Name = "button3";this.button3.TabIndex = 5;this.button3.Text = "清除";this.button3.Click += new System.EventHandler(this.button3_Click);// // textBox3// this.textBox3.Location = new System.Drawing.Point(144, 24);this.textBox3.Name = "textBox3";this.textBox3.TabIndex = 6;this.textBox3.Text = "8008";// // Form1// this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);this.ClientSize = new System.Drawing.Size(344, 366);this.Controls.Add(this.textBox3);this.Controls.Add(this.button3);this.Controls.Add(this.textBox2);this.Controls.Add(this.textBox1);this.Controls.Add(this.button2);this.Controls.Add(this.button1);this.Controls.Add(this.axMSComm1);this.Name = "Form1";this.Text = "Form1";this.Load += new System.EventHandler(this.Form1_Load);((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).EndInit();this.ResumeLayout(false);}#endregion/// <summary>/// 应用程序的主入口点。/// </summary>static void Main() {Application.Run(new Form1());}private void Form1_Load(object sender, System.EventArgs e){if(axMSComm1.PortOpen==false)axMSComm1.PortOpen=true;axMSComm1.Output="ATS0=1\r\n";}private void axMSComm1_OnComm(object sender, System.EventArgs e){string recv;if(axMSComm1.InBufferCount>0){recv=(string)axMSComm1.Input;textBox2.Text=textBox2.Text+recv;}}private void button1_Click(object sender, System.EventArgs e){//axMSComm1.Output="ATDT8139\r\n";axMSComm1.Output="ATDT"+textBox3.Text+"\r\n";}private void button2_Click(object sender, System.EventArgs e){axMSComm1.Output=textBox1.Text;}private void textBox2_TextChanged(object sender, System.EventArgs e){}private void button3_Click(object sender, System.EventArgs e){textBox2.Text="";}private void textBox1_TextChanged(object sender, System.EventArgs e){}}}
页: [1]
查看完整版本: 串口通信--网络实验2