Ajout d'une fonctionnalitée d'écriture en hexadécimal
This commit is contained in:
parent
7e40f83579
commit
e394fd6105
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
Serial Observer/Serial Observer/Form1.Designer.cs
generated
14
Serial Observer/Serial Observer/Form1.Designer.cs
generated
@ -38,6 +38,7 @@
|
|||||||
this.button_portDisconnect = new System.Windows.Forms.Button();
|
this.button_portDisconnect = new System.Windows.Forms.Button();
|
||||||
this.button_portSend = new System.Windows.Forms.Button();
|
this.button_portSend = new System.Windows.Forms.Button();
|
||||||
this.textBox_textToSend = new System.Windows.Forms.TextBox();
|
this.textBox_textToSend = new System.Windows.Forms.TextBox();
|
||||||
|
this.checkBox_HexEntering = new System.Windows.Forms.CheckBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// listBox_portLogs
|
// listBox_portLogs
|
||||||
@ -125,11 +126,23 @@
|
|||||||
this.textBox_textToSend.Size = new System.Drawing.Size(628, 20);
|
this.textBox_textToSend.Size = new System.Drawing.Size(628, 20);
|
||||||
this.textBox_textToSend.TabIndex = 9;
|
this.textBox_textToSend.TabIndex = 9;
|
||||||
//
|
//
|
||||||
|
// checkBox_HexEntering
|
||||||
|
//
|
||||||
|
this.checkBox_HexEntering.AutoSize = true;
|
||||||
|
this.checkBox_HexEntering.Location = new System.Drawing.Point(13, 248);
|
||||||
|
this.checkBox_HexEntering.Name = "checkBox_HexEntering";
|
||||||
|
this.checkBox_HexEntering.Size = new System.Drawing.Size(156, 17);
|
||||||
|
this.checkBox_HexEntering.TabIndex = 10;
|
||||||
|
this.checkBox_HexEntering.Text = "Mode d\'entrée hexadécimal";
|
||||||
|
this.checkBox_HexEntering.UseVisualStyleBackColor = true;
|
||||||
|
this.checkBox_HexEntering.CheckedChanged += new System.EventHandler(this.checkBox_HexEntering_CheckedChanged);
|
||||||
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
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(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.checkBox_HexEntering);
|
||||||
this.Controls.Add(this.textBox_textToSend);
|
this.Controls.Add(this.textBox_textToSend);
|
||||||
this.Controls.Add(this.button_portSend);
|
this.Controls.Add(this.button_portSend);
|
||||||
this.Controls.Add(this.button_portDisconnect);
|
this.Controls.Add(this.button_portDisconnect);
|
||||||
@ -159,6 +172,7 @@
|
|||||||
private System.Windows.Forms.Button button_portDisconnect;
|
private System.Windows.Forms.Button button_portDisconnect;
|
||||||
private System.Windows.Forms.Button button_portSend;
|
private System.Windows.Forms.Button button_portSend;
|
||||||
private System.Windows.Forms.TextBox textBox_textToSend;
|
private System.Windows.Forms.TextBox textBox_textToSend;
|
||||||
|
private System.Windows.Forms.CheckBox checkBox_HexEntering;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace Serial_Observer
|
|||||||
InitializeComboBox();
|
InitializeComboBox();
|
||||||
|
|
||||||
// Form size
|
// Form size
|
||||||
this.Size = new Size(670, 300);
|
this.Size = new Size(670, 310);
|
||||||
this.FormBorderStyle = FormBorderStyle.Fixed3D;
|
this.FormBorderStyle = FormBorderStyle.Fixed3D;
|
||||||
|
|
||||||
// Form options
|
// Form options
|
||||||
@ -89,7 +89,15 @@ namespace Serial_Observer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serialPort.Write(textBox_textToSend.Text);
|
if(checkBox_HexEntering.Checked)
|
||||||
|
{
|
||||||
|
serialPort.Write(HexToString(textBox_textToSend.Text));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serialPort.Write(textBox_textToSend.Text);
|
||||||
|
}
|
||||||
|
|
||||||
textBox_textToSend.Clear();
|
textBox_textToSend.Clear();
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
@ -113,6 +121,14 @@ namespace Serial_Observer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkBox_HexEntering_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(checkBox_HexEntering.Checked == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show(String.Format("Mode d'entrée hexadécimal actif ! \r\nSyntaxe : '68-65-6C-6C-6F' pour ecrire 'hello'."),"Changement de mode d'entrée",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************* Private Methods *************************/
|
/************************* Private Methods *************************/
|
||||||
private void InitializeComboBox()
|
private void InitializeComboBox()
|
||||||
{
|
{
|
||||||
@ -222,5 +238,17 @@ namespace Serial_Observer
|
|||||||
{
|
{
|
||||||
listBox_portLogs.Items.Add(myString);
|
listBox_portLogs.Items.Add(myString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string HexToString(string hexdata)
|
||||||
|
{
|
||||||
|
string[] hexDataSplit = hexdata.Split('-');
|
||||||
|
|
||||||
|
for (int count = 0 ; count < hexDataSplit.Length ; count++)
|
||||||
|
{
|
||||||
|
hexDataSplit[count] = Char.ConvertFromUtf32(Convert.ToInt32(hexDataSplit[count], 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String.Join("", hexDataSplit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -8,3 +8,13 @@ C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial Ob
|
|||||||
C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial Observer.exe
|
C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial Observer.exe
|
||||||
C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial Observer.pdb
|
C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial Observer.pdb
|
||||||
C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial_Observer.Form1.resources
|
C:\Users\Jean-Daniel\Desktop\Serial Observer\Serial Observer\obj\Debug\Serial_Observer.Form1.resources
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\bin\Debug\Serial Observer.exe.config
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\bin\Debug\Serial Observer.exe
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\bin\Debug\Serial Observer.pdb
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial Observer.csprojResolveAssemblyReference.cache
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial_Observer.Form1.resources
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial_Observer.Properties.Resources.resources
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial Observer.csproj.GenerateResource.cache
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial Observer.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial Observer.exe
|
||||||
|
C:\Users\Jean-Daniel\Documents\GitHub\SerialObserver\Serial Observer\Serial Observer\obj\Debug\Serial Observer.pdb
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user