資源簡介
上位機實現了串口通信,基本功能包括發送數據,hex、文本數據接收顯示等。可按照通信協議接收下位機數據并進行和校驗后顯示,實時顯示包括三軸加速度、角速度、歐拉姿態角等參數信息。實時顯示各數據波形,同時可以自由選擇需要的顯示的數據通道。軟件使用VS2008 C#開發,在win7下測試一切正常。

代碼片段和文件信息
using?System;
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;
namespace?quadrotor
{
????public?partial?class?Fonfig_USART?:?Form
????{
????????Form1?fm;
????????public?Fonfig_USART()
????????{
????????????InitializeComponent();
????????}
????????private?void?scan_com()
????????{
????????????string[]?ports?=?SerialPort.GetPortNames();
????????????Array.Sort(ports);
????????????comboBox_comname.Items.AddRange(ports);
????????}
????????private?void?Fonfig_USART_Load(object?sender?EventArgs?e)
????????{
????????????fm?=?(Form1)this.Owner;?
????????????scan_com();//掃描可用串口
????????????comboBox_comname.SelectedIndex?=?comboBox_comname.Items.Count?>?0???2?:?-1;//旋轉第一個可用串口
????????????comboBox_baudrate.SelectedIndex?=?comboBox_baudrate.Items.IndexOf(“500000“);//選擇波特率??
????????????comboBox_parity_bit.SelectedIndex?=?comboBox_parity_bit.Items.IndexOf(“無“);
????????????comboBox_data_bit.SelectedIndex?=?comboBox_data_bit.Items.IndexOf(“8“);
????????????comboBox_stop_bit.SelectedIndex?=?comboBox_stop_bit.Items.IndexOf(“1“);
????????????
????????????btn_com_open.Text?=?“打開串口“;
????????}
????????private?void?btn_com_open_Click(object?sender?EventArgs?e)
????????{
????????????if?(“打開串口“?==?btn_com_open.Text)
????????????{
????????????????fm.serialPort1.PortName?=?comboBox_comname.Text;
????????????????fm.serialPort1.BaudRate?=?int.Parse(comboBox_baudrate.Text);
????????????????fm.serialPort1.Parity???=?Parity.None;
????????????????switch?(comboBox_parity_bit.SelectedIndex)
????????????????{
????????????????????case?0:
????????????????????????fm.serialPort1.Parity?=?Parity.None;
????????????????????????break;
????????????????????case?1:
????????????????????????fm.serialPort1.Parity?=?Parity.Odd;
????????????????????????break;
????????????????????case?2:
????????????????????????fm.serialPort1.Parity?=?Parity.Even;
????????????????????????break;
????????????????}
????????????????switch?(comboBox_data_bit.SelectedIndex)
????????????????{
????????????????????case?0:
????????????????????????fm.serialPort1.DataBits?=?4;
????????????????????????break;
????????????????????case?1:
????????????????????????fm.serialPort1.DataBits?=?5;
????????????????????????break;
????????????????????case?2:
????????????????????????fm.serialPort1.DataBits?=?6;
????????????????????????break;
????????????????????case?3:
????????????????????????fm.serialPort1.DataBits?=?7;
????????????????????????break;
????????????????????case?4:
????????????????????????fm.serialPort1.DataBits?=?8;
????????????????????????break;
????????????????}
????????????????switch?(comboBox_stop_bit.SelectedIndex)
????????????????{
????????????????????case?0:
????????????????????????fm.serialPort1.StopBits?=?StopBits.One;
????????????????????????break;
????????????????????case?1:
????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????67646??2014-11-05?15:39??quadrotor地面站\quadrotor\20140606041332138_easyicon_net_128.ico
?????文件?????192512??2014-11-08?18:59??quadrotor地面站\quadrotor\bin\Debug\AxInterop.iPlotLibrary.dll
?????文件?????487424??2014-11-04?11:40??quadrotor地面站\quadrotor\bin\Debug\AxInterop.iProfessionalLibrary.dll
?????文件?????225280??2014-11-04?19:39??quadrotor地面站\quadrotor\bin\Debug\AxInterop.isDigitalLibrary.dll
?????文件??????69632??2014-11-08?18:00??quadrotor地面站\quadrotor\bin\Debug\AxInterop.iStripChartXControl.dll
?????文件?????507904??2014-11-08?18:59??quadrotor地面站\quadrotor\bin\Debug\Interop.iPlotLibrary.dll
?????文件?????667648??2014-11-04?11:40??quadrotor地面站\quadrotor\bin\Debug\Interop.iProfessionalLibrary.dll
?????文件?????303104??2014-11-04?19:39??quadrotor地面站\quadrotor\bin\Debug\Interop.isDigitalLibrary.dll
?????文件??????73728??2014-11-08?18:00??quadrotor地面站\quadrotor\bin\Debug\Interop.iStripChartXControl.dll
?????文件?????516096??2006-08-18?11:50??quadrotor地面站\quadrotor\bin\Debug\IrisSkin2.dll
?????文件???????1579??2014-11-11?22:22??quadrotor地面站\quadrotor\bin\Debug\quadrotor.application
?????文件?????266240??2014-11-11?22:22??quadrotor地面站\quadrotor\bin\Debug\quadrotor.exe
?????文件??????10159??2014-11-11?22:22??quadrotor地面站\quadrotor\bin\Debug\quadrotor.exe.manifest
?????文件??????56832??2014-11-11?22:22??quadrotor地面站\quadrotor\bin\Debug\quadrotor.pdb
?????文件???????1579??2014-11-11?22:22??quadrotor地面站\quadrotor\bin\Debug\quadrotor.vshost.application
?????文件??????14328??2016-05-24?19:32??quadrotor地面站\quadrotor\bin\Debug\quadrotor.vshost.exe
?????文件??????33729??2006-03-22?10:24??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\calmness.gif
?????文件??????20139??2006-03-22?10:16??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\Calmness.ssk
?????文件??????20271??2006-03-22?10:16??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\CalmnessColor1.ssk
?????文件??????20208??2006-03-22?10:15??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\CalmnessColor2.ssk
?????文件??????40436??2006-03-22?10:25??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\calmness_color1.gif
?????文件??????50601??2006-03-22?10:26??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\calmness_color2.gif
????..A.SH.?????13312??2006-11-10?15:27??quadrotor地面站\quadrotor\bin\Debug\skin\Carlmness\Thumbs.db
?????文件??????18221??2006-03-22?12:22??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\deepcyan.gif
?????文件???????5032??2006-04-04?15:20??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\DeepCyan.ssk
?????文件??????17920??2006-03-22?12:23??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\deepgreen.gif
?????文件???????5037??2006-03-29?12:12??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\DeepGreen.ssk
?????文件??????20292??2006-03-22?12:24??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\deeporange.gif
?????文件???????4908??2006-03-29?12:12??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\DeepOrange.ssk
????..A.SH.?????13312??2006-11-10?15:27??quadrotor地面站\quadrotor\bin\Debug\skin\Deep\Thumbs.db
............此處省略199個文件信息
評論
共有 條評論