Configurator.Net: Added BaudRate option

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1733 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
mandrolic 2011-02-28 20:11:44 +00:00
parent 5f853768f4
commit dd008ec97f
7 changed files with 78 additions and 12 deletions

View File

@ -33,7 +33,7 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.htm</WebPage> <WebPage>index.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish> <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>7</ApplicationRevision> <ApplicationRevision>8</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -11,6 +11,7 @@ namespace ArducopterConfigurator
event Action<string> LineOfDataReceived; event Action<string> LineOfDataReceived;
string CommPort { get; set; } string CommPort { get; set; }
bool IsConnected { get; } bool IsConnected { get; }
int BaudRate { get; set; }
IEnumerable<string> ListCommPorts(); IEnumerable<string> ListCommPorts();
void Send(string send); void Send(string send);
bool Connect(); bool Connect();
@ -37,9 +38,11 @@ namespace ArducopterConfigurator
public string CommPort { get; set; } public string CommPort { get; set; }
public int BaudRate { get; set; }
public bool Connect() public bool Connect()
{ {
_sp.BaudRate = 115200; _sp.BaudRate = BaudRate;
_sp.PortName = CommPort; _sp.PortName = CommPort;
_sp.NewLine = "\n"; _sp.NewLine = "\n";
_sp.Handshake = Handshake.None; _sp.Handshake = Handshake.None;
@ -125,6 +128,8 @@ namespace ArducopterConfigurator
get { return _sp.IsOpen; } get { return _sp.IsOpen; }
} }
public IEnumerable<string> ListCommPorts() public IEnumerable<string> ListCommPorts()
{ {
return SerialPort.GetPortNames(); return SerialPort.GetPortNames();

View File

@ -32,6 +32,9 @@ namespace ArducopterConfigurator
get { return _connected; } get { return _connected; }
} }
public int BaudRate { get; set; }
public IEnumerable<string> ListCommPorts() public IEnumerable<string> ListCommPorts()
{ {
return new[] {"FakePort1", "FakePort2"}; return new[] {"FakePort1", "FakePort2"};

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using Timer=System.Windows.Forms.Timer; using Timer=System.Windows.Forms.Timer;
@ -10,6 +11,7 @@ namespace ArducopterConfigurator.PresentationModels
private bool _isConnected; private bool _isConnected;
private IPresentationModel _selectedVm; private IPresentationModel _selectedVm;
private string _selectedPort; private string _selectedPort;
private int _selectedBaudRate;
private string _apmVersion; private string _apmVersion;
private Timer _connectionAttemptsTimer; private Timer _connectionAttemptsTimer;
@ -55,6 +57,9 @@ namespace ArducopterConfigurator.PresentationModels
AvailablePorts = new BindingList<string>(); AvailablePorts = new BindingList<string>();
AvailableBaudRates = new BindingList<int>() {115200, 57600, 38400, 9600};
SelectedBaudRate = 115200;
RefreshPorts(); RefreshPorts();
// Initially have selected the last discovered com port. // Initially have selected the last discovered com port.
@ -131,6 +136,8 @@ namespace ArducopterConfigurator.PresentationModels
public BindingList<string> AvailablePorts { get; private set; } public BindingList<string> AvailablePorts { get; private set; }
public BindingList<int> AvailableBaudRates { get; private set; }
public enum SessionStates public enum SessionStates
{ {
Disconnected, Disconnected,
@ -179,9 +186,24 @@ namespace ArducopterConfigurator.PresentationModels
} }
} }
public int SelectedBaudRate
{
get { return _selectedBaudRate; }
set
{
if (_selectedBaudRate != value)
{
_selectedBaudRate = value;
FirePropertyChanged("SelectedBaudRate");
}
}
}
public void Connect() public void Connect()
{ {
_comms.CommPort = SelectedPort; _comms.CommPort = SelectedPort;
_comms.BaudRate = SelectedBaudRate;
// Todo: check the status of this call success/failure // Todo: check the status of this call success/failure
if (!_comms.Connect()) if (!_comms.Connect())

View File

@ -16,6 +16,12 @@ namespace ArducopterConfiguratorTest
get { return _isConnected; } get { return _isConnected; }
} }
public int BaudRate
{
get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); }
}
public IEnumerable<string> ListCommPorts() public IEnumerable<string> ListCommPorts()
{ {
return new[] {"MockComport1"}; return new[] {"MockComport1"};

View File

@ -39,12 +39,15 @@ namespace ArducopterConfigurator
this.button4 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button();
this.btnConnect = new System.Windows.Forms.Button(); this.btnConnect = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.cmboComPorts = new System.Windows.Forms.ComboBox(); this.cmboComPorts = new System.Windows.Forms.ComboBox();
this.lblConnectionStatus = new System.Windows.Forms.Label(); this.lblConnectionStatus = new System.Windows.Forms.Label();
this.availableBaudRatesBindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.mainVmBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.mainVmBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.availablePortsBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.availablePortsBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.availableBaudRatesBindingSource)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// tabCtrlMonitorVms // tabCtrlMonitorVms
@ -95,7 +98,7 @@ namespace ArducopterConfigurator
this.btnConnect.Cursor = System.Windows.Forms.Cursors.Arrow; this.btnConnect.Cursor = System.Windows.Forms.Cursors.Arrow;
this.btnConnect.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.mainVmBindingSource, "ConnectCommand", true)); this.btnConnect.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.mainVmBindingSource, "ConnectCommand", true));
this.btnConnect.Image = ((System.Drawing.Image)(resources.GetObject("btnConnect.Image"))); this.btnConnect.Image = ((System.Drawing.Image)(resources.GetObject("btnConnect.Image")));
this.btnConnect.Location = new System.Drawing.Point(96, 407); this.btnConnect.Location = new System.Drawing.Point(165, 408);
this.btnConnect.Name = "btnConnect"; this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(26, 26); this.btnConnect.Size = new System.Drawing.Size(26, 26);
this.btnConnect.TabIndex = 6; this.btnConnect.TabIndex = 6;
@ -108,17 +111,29 @@ namespace ArducopterConfigurator
this.button1.Cursor = System.Windows.Forms.Cursors.Arrow; this.button1.Cursor = System.Windows.Forms.Cursors.Arrow;
this.button1.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.mainVmBindingSource, "DisconnectCommand", true)); this.button1.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.mainVmBindingSource, "DisconnectCommand", true));
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image"))); this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Location = new System.Drawing.Point(127, 407); this.button1.Location = new System.Drawing.Point(196, 408);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(26, 26); this.button1.Size = new System.Drawing.Size(26, 26);
this.button1.TabIndex = 7; this.button1.TabIndex = 7;
this.toolTip.SetToolTip(this.button1, "Disconnect"); this.toolTip.SetToolTip(this.button1, "Disconnect");
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
// //
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.mainVmBindingSource, "SelectedBaudRate", true));
this.comboBox1.DataSource = this.availableBaudRatesBindingSource;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(80, 411);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(79, 21);
this.comboBox1.TabIndex = 15;
this.toolTip.SetToolTip(this.comboBox1, "Baud Rate");
//
// linkLabel1 // linkLabel1
// //
this.linkLabel1.AutoSize = true; this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(346, 415); this.linkLabel1.Location = new System.Drawing.Point(355, 423);
this.linkLabel1.Name = "linkLabel1"; this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(84, 13); this.linkLabel1.Size = new System.Drawing.Size(84, 13);
this.linkLabel1.TabIndex = 13; this.linkLabel1.TabIndex = 13;
@ -129,7 +144,7 @@ namespace ArducopterConfigurator
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(346, 399); this.label1.Location = new System.Drawing.Point(355, 407);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 13); this.label1.Size = new System.Drawing.Size(89, 13);
this.label1.TabIndex = 14; this.label1.TabIndex = 14;
@ -143,7 +158,7 @@ namespace ArducopterConfigurator
this.cmboComPorts.FormattingEnabled = true; this.cmboComPorts.FormattingEnabled = true;
this.cmboComPorts.Location = new System.Drawing.Point(11, 410); this.cmboComPorts.Location = new System.Drawing.Point(11, 410);
this.cmboComPorts.Name = "cmboComPorts"; this.cmboComPorts.Name = "cmboComPorts";
this.cmboComPorts.Size = new System.Drawing.Size(79, 21); this.cmboComPorts.Size = new System.Drawing.Size(63, 21);
this.cmboComPorts.TabIndex = 5; this.cmboComPorts.TabIndex = 5;
this.cmboComPorts.DropDown += new System.EventHandler(this.cmboComPorts_DropDown); this.cmboComPorts.DropDown += new System.EventHandler(this.cmboComPorts_DropDown);
// //
@ -151,17 +166,23 @@ namespace ArducopterConfigurator
// //
this.lblConnectionStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblConnectionStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblConnectionStatus.AutoSize = true; this.lblConnectionStatus.AutoSize = true;
this.lblConnectionStatus.Location = new System.Drawing.Point(159, 418); this.lblConnectionStatus.Location = new System.Drawing.Point(228, 419);
this.lblConnectionStatus.Name = "lblConnectionStatus"; this.lblConnectionStatus.Name = "lblConnectionStatus";
this.lblConnectionStatus.Size = new System.Drawing.Size(112, 13); this.lblConnectionStatus.Size = new System.Drawing.Size(112, 13);
this.lblConnectionStatus.TabIndex = 8; this.lblConnectionStatus.TabIndex = 8;
this.lblConnectionStatus.Text = "connection string here"; this.lblConnectionStatus.Text = "connection string here";
// //
// availableBaudRatesBindingSource
//
this.availableBaudRatesBindingSource.DataMember = "AvailableBaudRates";
this.availableBaudRatesBindingSource.DataSource = this.mainVmBindingSource;
//
// mainForm // mainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(554, 445); this.ClientSize = new System.Drawing.Size(554, 445);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.lblConnectionStatus); this.Controls.Add(this.lblConnectionStatus);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
@ -179,6 +200,7 @@ namespace ArducopterConfigurator
this.SizeChanged += new System.EventHandler(this.mainForm_SizeChanged); this.SizeChanged += new System.EventHandler(this.mainForm_SizeChanged);
((System.ComponentModel.ISupportInitialize)(this.mainVmBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.mainVmBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.availablePortsBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.availablePortsBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.availableBaudRatesBindingSource)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -198,6 +220,8 @@ namespace ArducopterConfigurator
private System.Windows.Forms.ComboBox cmboComPorts; private System.Windows.Forms.ComboBox cmboComPorts;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label lblConnectionStatus; private System.Windows.Forms.Label lblConnectionStatus;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.BindingSource availableBaudRatesBindingSource;
} }
} }

View File

@ -120,6 +120,9 @@
<metadata name="mainVmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="mainVmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>7, 19</value> <value>7, 19</value>
</metadata> </metadata>
<metadata name="mainVmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>7, 19</value>
</metadata>
<metadata name="availablePortsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="availablePortsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>170, 20</value> <value>170, 20</value>
</metadata> </metadata>
@ -130,8 +133,8 @@
<data name="button3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="button3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALBgAA YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALBAAA
CwYBZDTpJAAABLRJREFUWEftVm1Mk1cYJVn8NxPjD7Nl2YeAWWJCliWbYxuwDzIdYDHIpgiKG9IBqYVR CwQBG8oqrQAABLRJREFUWEftVm1Mk1cYJVn8NxPjD7Nl2YeAWWJCliWbYxuwDzIdYDHIpgiKG9IBqYVR
UEuFgu8AKZ+1CGg7ZUBhDtdYMykMaPmmxSJfwoAhTuwYCBuEIIgMPOu9TnRY2rVz4Y8/Tpomvfec8zzn UEuFgu8AKZ+1CGg7ZUBhDtdYMykMaPmmxSJfwoAhTuwYCBuEIIgMPOu9TnRY2rVz4Y8/Tpomvfec8zzn
eXrtANitJlaVnBh/KsDqCmxVeGCjzB52Yrt/4GXZRrxT7GasqnWZslqAk9wJv6EHbYvV0C6qULNwAao/ eXrtANitJlaVnBh/KsDqCmxVeGCjzB52Yrt/4GXZRrxT7GasqnWZslqAk9wJv6EHbYvV0C6qULNwAao/
z6FhsQwvFjn8/wLWSdei854GknkBUuaiIZzhgjfNhnpRCbu8Z1DT3GqVCLMVICVdI1kDQkqwVvos/Wxd z6FhsQwvFjn8/wLWSdei854GknkBUuaiIZzhgjfNhnpRCbu8Z1DT3GqVCLMVICVdI1kDQkqwVvos/Wxd
@ -210,6 +213,9 @@
IEcrx3nZquyh7NsISVnw5bFgit2/J/uPz/w7PYg4GfFdEjIAAAAASUVORK5CYII= IEcrx3nZquyh7NsISVnw5bFgit2/J/uPz/w7PYg4GfFdEjIAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<metadata name="availableBaudRatesBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>466, 20</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
AAABAAgAAAAAAAEAIACJiQAAhgAAAICAAAABACAAKAgBAA+KAABISAAAAQAgAIhUAAA3kgEAQEAAAAEA AAABAAgAAAAAAAEAIACJiQAAhgAAAICAAAABACAAKAgBAA+KAABISAAAAQAgAIhUAAA3kgEAQEAAAAEA