• 大小: 206KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-01
  • 语言: C#
  • 标签: chart  串口  欧拉角  

资源简介

这是一个对串口发送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个文件信息

评论

共有 条评论