资源简介
这是一个对串口发送printf("pitch:%.2f roll:%.2f yaw:%.2f\n",Pitch,Roll,Yaw);进行接收的上位机,并分离出相应的欧拉角数据
代码片段和文件信息
using System;
using System.Configuration;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Text.Regularexpressions;
namespace SerialportSample
{
public partial class SerialportSampleForm : Form
{
int i;
string data1data2data3;
private SerialPort comm = new SerialPort();
private StringBuilder builder = new StringBuilder();//避免在事件处理方法中反复的创建,定义到外面。
private long received_count = 0;//接收计数
private long send_count = 0;//发送计数
private bool Listening = false;//是否没有执行完invoke相关操作
private bool Closing = false;//是否正在关闭串口,执行Application.DoEvents,并阻止再次invoke
private List buffer = new List(4096);//默认分配1页内存,并始终限制不允许超过
private byte[] binary_data_1 = new byte[20];
private byte[] binary_data_2 = new byte[20];
private byte[] binary_data_3 = new byte[20];
public SerialportSampleForm()
{
InitializeComponent();
}
//窗体初始化
private void Form1_Load(object sender EventArgs e)
{
//初始化下拉串口名称列表框
string[] ports = SerialPort.GetPortNames();
Array.Sort(ports);
comboPortName.Items.AddRange(ports);
comboPortName.SelectedIndex = comboPortName.Items.Count > 0 ? 0 : -1;
comboBaudrate.SelectedIndex = comboBaudrate.Items.IndexOf(“115200“);
this.KeyPreview = true;
//初始化SerialPort对象
comm.NewLine = “\r\n“;
comm.RtsEnable = true;//根据实际情况吧。
comboPortName.Text = “COM16“;
//添加事件注册
comm.DataReceived += comm_DataReceived;
chart1.ChartAreas[“ChartArea1“].AxisX.Minimum =100;
chart1.ChartAreas[“ChartArea1“].AxisX.Maximum = 0;
chart1.ChartAreas[“ChartArea1“].AxisY.Minimum = -100;
chart1.ChartAreas[“ChartArea1“].AxisY.Maximum = 100;
chart1.ChartAreas[“ChartArea1“].AxisX.Interval = 1;//设置每个刻度的跨度
chart1.ChartAreas[“ChartArea1“].AxisY.Interval = 10;//设置每个刻度的跨度
i = 0;
/* DataTable dt = default(DataTable);
dt = CreateDataTable();
//设置图表的数据源
Chart1.DataSource = dt;
//设置图表Y轴对应项
Chart1.Series[0].YValueMembers = “Volume1“;
Chart1.Series[1].YValueMembers = “Volume2“;
//设置图表X轴对应项
Chart1.Series[0].XValueMember = “Date“;
//绑定数据
Chart1.DataBind();*/
// MessageBox.Show(“你很狡猾吗?“);
}
Random rnd = new Random();
/* private DataTable CreateDataTable()
{
//Create a DataTable as the data source of the Chart control
DataTable dt = new DataTable();
//Add three c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 48128 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\bin\Debug\SerialportSample.exe
文件 36352 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\bin\Debug\SerialportSample.pdb
文件 11600 2014-04-13 22:18 SerialportSample(3)\SerialportSample\SerialportSample\bin\Debug\SerialportSample.vshost.exe
文件 490 2010-03-18 12:39 SerialportSample(3)\SerialportSample\SerialportSample\bin\Debug\SerialportSample.vshost.exe.manifest
文件 18656 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\Form1.cs
文件 22814 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\Form1.Designer.cs
文件 25609 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\Form1.resx
文件 12862 2014-04-02 20:29 SerialportSample(3)\SerialportSample\SerialportSample\MY_first_PS.ico
文件 62976 2014-04-04 00:51 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\AxInterop.TeeChart.dll
文件 14101 2014-04-05 14:29 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6697 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 642 2010-05-27 09:08 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\GenerateResource.read.1.tlog
文件 1614 2010-05-27 09:08 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\GenerateResource.write.1.tlog
文件 244224 2014-04-04 00:51 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\Interop.TeeChart.dll
文件 3172 2014-04-13 22:18 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.csproj.FileListAbsolute.txt
文件 975 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.csproj.GenerateResource.Cache
文件 770 2014-04-04 00:51 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.csproj.ResolveComReference.cache
文件 9174 2014-04-02 20:43 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.csprojResolveAssemblyReference.cache
文件 48128 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.exe
文件 36352 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.pdb
文件 180 2014-04-04 10:20 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.Properties.Resources.resources
文件 13428 2014-04-13 22:17 SerialportSample(3)\SerialportSample\SerialportSample\obj\x86\Debug\SerialportSample.SerialportSampleForm.resources
文件 523 2010-05-16 03:24 SerialportSample(3)\SerialportSample\SerialportSample\Program.cs
文件 1468 2010-05-16 02:19 SerialportSample(3)\SerialportSample\SerialportSample\Properties\AssemblyInfo.cs
文件 2858 2010-05-16 02:19 SerialportSample(3)\SerialportSample\SerialportSample\Properties\Resources.Designer.cs
文件 5612 2010-05-16 02:19 SerialportSample(3)\SerialportSample\SerialportSample\Properties\Resources.resx
文件 1099 2010-05-16 02:19 SerialportSample(3)\SerialportSample\SerialportSample\Properties\Settings.Designer.cs
文件 249 2010-05-16 02:19 SerialportSample(3)\SerialportSample\SerialportSample\Properties\Settings.settings
文件 3928 2014-04-04 10:20 SerialportSample(3)\SerialportSample\SerialportSample\SerialportSample.csproj
文件 890 2010-05-16 02:19 SerialportSample(3)\SerialportSample\SerialportSample.sln
............此处省略15个文件信息
- 上一篇:C#md5加密解密
- 下一篇:把其它应用嵌入到C#窗口 源代码
相关资源
- vs2010 c# 串口调试助手
- C#使用RS232串口通讯
- c#wpf chart绘图 源代码 示波器
- C#串口助手源码新手
- c# chart控件实时显示曲线
- C#编写的串口数据接收保存
- C#读取RS232串口扫描枪
- C#简易示波器,图形化显示串口数据
- C#串口调试助手_VS2010()
- Wince6.0+C#串口调试助手源码
- C# 串口调试助手源码(自动搜索PC可用
- C#串口读取数字温湿度传感器数据
- 快速设计一个简单的WPF串口上位机
- C#与DVP PLC通信
- FusionCharts+asp.net+sqlserver生成图表
- ASP.NET绑定sql数据库采用echarts显示数据
- C#串口编程
- C# chart实时数据显示简单工程文件
- WPFVisifire.Charts5.1.7.0 破解版
- 基于C#的简单抄表界面
- visual studio c#用于串口上位机 内部有
- C#读取串口数据画图
- C#通过串口采集数据,然后将数据点绘
- C#编写的基于串口的Chart数据曲线图
- C#中Chart控件
- C#+串口和USB通信编程(代码)
- C#串口MudbusRTU协议编程
- RS232串口通信的小软件
- 用c# 写的上位机程序
- C# 后台动态增加chart图表
评论
共有 条评论