Ajout d'indication, ajout d'un programme Arduino pour tester
This commit is contained in:
Jean-Daniel Massard 2018-04-02 15:26:49 +02:00
parent 9598184722
commit 67f8f1c9fa
17 changed files with 149 additions and 18 deletions

View File

@ -39,12 +39,18 @@
this.button_portSend = new System.Windows.Forms.Button();
this.textBox_textToSend = new System.Windows.Forms.TextBox();
this.checkBox_HexEntering = new System.Windows.Forms.CheckBox();
this.label_comboBoxNamePort = new System.Windows.Forms.Label();
this.label_comboBoxSpeedPort = new System.Windows.Forms.Label();
this.label_comboBoxDataPort = new System.Windows.Forms.Label();
this.label_comboBoxParityPort = new System.Windows.Forms.Label();
this.label_comboBoxStopPort = new System.Windows.Forms.Label();
this.button_setupForm = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listBox_portLogs
//
this.listBox_portLogs.FormattingEnabled = true;
this.listBox_portLogs.Location = new System.Drawing.Point(12, 39);
this.listBox_portLogs.Location = new System.Drawing.Point(12, 52);
this.listBox_portLogs.Name = "listBox_portLogs";
this.listBox_portLogs.Size = new System.Drawing.Size(629, 147);
this.listBox_portLogs.TabIndex = 0;
@ -52,7 +58,7 @@
// comboBox_portName
//
this.comboBox_portName.FormattingEnabled = true;
this.comboBox_portName.Location = new System.Drawing.Point(12, 12);
this.comboBox_portName.Location = new System.Drawing.Point(12, 25);
this.comboBox_portName.Name = "comboBox_portName";
this.comboBox_portName.Size = new System.Drawing.Size(121, 21);
this.comboBox_portName.TabIndex = 1;
@ -60,7 +66,7 @@
// comboBox_portSpeed
//
this.comboBox_portSpeed.FormattingEnabled = true;
this.comboBox_portSpeed.Location = new System.Drawing.Point(139, 12);
this.comboBox_portSpeed.Location = new System.Drawing.Point(139, 25);
this.comboBox_portSpeed.Name = "comboBox_portSpeed";
this.comboBox_portSpeed.Size = new System.Drawing.Size(121, 21);
this.comboBox_portSpeed.TabIndex = 2;
@ -68,7 +74,7 @@
// comboBox_portParity
//
this.comboBox_portParity.FormattingEnabled = true;
this.comboBox_portParity.Location = new System.Drawing.Point(393, 12);
this.comboBox_portParity.Location = new System.Drawing.Point(393, 25);
this.comboBox_portParity.Name = "comboBox_portParity";
this.comboBox_portParity.Size = new System.Drawing.Size(121, 21);
this.comboBox_portParity.TabIndex = 3;
@ -76,7 +82,7 @@
// comboBox_portData
//
this.comboBox_portData.FormattingEnabled = true;
this.comboBox_portData.Location = new System.Drawing.Point(266, 12);
this.comboBox_portData.Location = new System.Drawing.Point(266, 25);
this.comboBox_portData.Name = "comboBox_portData";
this.comboBox_portData.Size = new System.Drawing.Size(121, 21);
this.comboBox_portData.TabIndex = 4;
@ -84,16 +90,16 @@
// comboBox_portStop
//
this.comboBox_portStop.FormattingEnabled = true;
this.comboBox_portStop.Location = new System.Drawing.Point(520, 12);
this.comboBox_portStop.Location = new System.Drawing.Point(520, 25);
this.comboBox_portStop.Name = "comboBox_portStop";
this.comboBox_portStop.Size = new System.Drawing.Size(121, 21);
this.comboBox_portStop.TabIndex = 5;
//
// button_portConnect
//
this.button_portConnect.Location = new System.Drawing.Point(12, 219);
this.button_portConnect.Location = new System.Drawing.Point(12, 232);
this.button_portConnect.Name = "button_portConnect";
this.button_portConnect.Size = new System.Drawing.Size(248, 23);
this.button_portConnect.Size = new System.Drawing.Size(109, 23);
this.button_portConnect.TabIndex = 6;
this.button_portConnect.Text = "Connecter";
this.button_portConnect.UseVisualStyleBackColor = true;
@ -101,9 +107,9 @@
//
// button_portDisconnect
//
this.button_portDisconnect.Location = new System.Drawing.Point(266, 219);
this.button_portDisconnect.Location = new System.Drawing.Point(127, 232);
this.button_portDisconnect.Name = "button_portDisconnect";
this.button_portDisconnect.Size = new System.Drawing.Size(248, 23);
this.button_portDisconnect.Size = new System.Drawing.Size(133, 23);
this.button_portDisconnect.TabIndex = 7;
this.button_portDisconnect.Text = "Déconnecter";
this.button_portDisconnect.UseVisualStyleBackColor = true;
@ -111,9 +117,9 @@
//
// button_portSend
//
this.button_portSend.Location = new System.Drawing.Point(520, 219);
this.button_portSend.Location = new System.Drawing.Point(266, 232);
this.button_portSend.Name = "button_portSend";
this.button_portSend.Size = new System.Drawing.Size(121, 23);
this.button_portSend.Size = new System.Drawing.Size(187, 23);
this.button_portSend.TabIndex = 8;
this.button_portSend.Text = "Envoyer";
this.button_portSend.UseVisualStyleBackColor = true;
@ -121,7 +127,7 @@
//
// textBox_textToSend
//
this.textBox_textToSend.Location = new System.Drawing.Point(13, 193);
this.textBox_textToSend.Location = new System.Drawing.Point(13, 206);
this.textBox_textToSend.Name = "textBox_textToSend";
this.textBox_textToSend.Size = new System.Drawing.Size(628, 20);
this.textBox_textToSend.TabIndex = 9;
@ -129,7 +135,7 @@
// checkBox_HexEntering
//
this.checkBox_HexEntering.AutoSize = true;
this.checkBox_HexEntering.Location = new System.Drawing.Point(13, 248);
this.checkBox_HexEntering.Location = new System.Drawing.Point(13, 261);
this.checkBox_HexEntering.Name = "checkBox_HexEntering";
this.checkBox_HexEntering.Size = new System.Drawing.Size(156, 17);
this.checkBox_HexEntering.TabIndex = 10;
@ -137,11 +143,72 @@
this.checkBox_HexEntering.UseVisualStyleBackColor = true;
this.checkBox_HexEntering.CheckedChanged += new System.EventHandler(this.checkBox_HexEntering_CheckedChanged);
//
// label_comboBoxNamePort
//
this.label_comboBoxNamePort.AutoSize = true;
this.label_comboBoxNamePort.Location = new System.Drawing.Point(47, 9);
this.label_comboBoxNamePort.Name = "label_comboBoxNamePort";
this.label_comboBoxNamePort.Size = new System.Drawing.Size(53, 13);
this.label_comboBoxNamePort.TabIndex = 11;
this.label_comboBoxNamePort.Text = "Port COM";
//
// label_comboBoxSpeedPort
//
this.label_comboBoxSpeedPort.AutoSize = true;
this.label_comboBoxSpeedPort.Location = new System.Drawing.Point(160, 9);
this.label_comboBoxSpeedPort.Name = "label_comboBoxSpeedPort";
this.label_comboBoxSpeedPort.Size = new System.Drawing.Size(77, 13);
this.label_comboBoxSpeedPort.TabIndex = 12;
this.label_comboBoxSpeedPort.Text = "Vitesse du port";
//
// label_comboBoxDataPort
//
this.label_comboBoxDataPort.AutoSize = true;
this.label_comboBoxDataPort.Location = new System.Drawing.Point(275, 9);
this.label_comboBoxDataPort.Name = "label_comboBoxDataPort";
this.label_comboBoxDataPort.Size = new System.Drawing.Size(103, 13);
this.label_comboBoxDataPort.TabIndex = 13;
this.label_comboBoxDataPort.Text = "Nombre de données";
//
// label_comboBoxParityPort
//
this.label_comboBoxParityPort.AutoSize = true;
this.label_comboBoxParityPort.Location = new System.Drawing.Point(435, 9);
this.label_comboBoxParityPort.Name = "label_comboBoxParityPort";
this.label_comboBoxParityPort.Size = new System.Drawing.Size(34, 13);
this.label_comboBoxParityPort.TabIndex = 14;
this.label_comboBoxParityPort.Text = "Parité";
//
// label_comboBoxStopPort
//
this.label_comboBoxStopPort.AutoSize = true;
this.label_comboBoxStopPort.Location = new System.Drawing.Point(539, 9);
this.label_comboBoxStopPort.Name = "label_comboBoxStopPort";
this.label_comboBoxStopPort.Size = new System.Drawing.Size(82, 13);
this.label_comboBoxStopPort.TabIndex = 15;
this.label_comboBoxStopPort.Text = "Nombre de stop";
//
// button_setupForm
//
this.button_setupForm.Location = new System.Drawing.Point(459, 232);
this.button_setupForm.Name = "button_setupForm";
this.button_setupForm.Size = new System.Drawing.Size(182, 23);
this.button_setupForm.TabIndex = 16;
this.button_setupForm.Text = "Paramètres supplémentaires";
this.button_setupForm.UseVisualStyleBackColor = true;
this.button_setupForm.Click += new System.EventHandler(this.button_setupForm_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button_setupForm);
this.Controls.Add(this.label_comboBoxStopPort);
this.Controls.Add(this.label_comboBoxParityPort);
this.Controls.Add(this.label_comboBoxDataPort);
this.Controls.Add(this.label_comboBoxSpeedPort);
this.Controls.Add(this.label_comboBoxNamePort);
this.Controls.Add(this.checkBox_HexEntering);
this.Controls.Add(this.textBox_textToSend);
this.Controls.Add(this.button_portSend);
@ -173,6 +240,12 @@
private System.Windows.Forms.Button button_portSend;
private System.Windows.Forms.TextBox textBox_textToSend;
private System.Windows.Forms.CheckBox checkBox_HexEntering;
private System.Windows.Forms.Label label_comboBoxNamePort;
private System.Windows.Forms.Label label_comboBoxSpeedPort;
private System.Windows.Forms.Label label_comboBoxDataPort;
private System.Windows.Forms.Label label_comboBoxParityPort;
private System.Windows.Forms.Label label_comboBoxStopPort;
private System.Windows.Forms.Button button_setupForm;
}
}

View File

@ -27,7 +27,7 @@ namespace Serial_Observer
InitializeComboBox();
// Form size
this.Size = new Size(670, 310);
this.Size = new Size(670, 320);
this.FormBorderStyle = FormBorderStyle.Fixed3D;
// Form options
@ -35,6 +35,7 @@ namespace Serial_Observer
// Buttons
modifyButtonsAccess(true, false, false);
button_setupForm.Enabled = false;
}
/***************************** Events *****************************/
@ -106,6 +107,10 @@ namespace Serial_Observer
}
}
private void button_setupForm_Click(object sender, EventArgs e)
{
}
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{
try
@ -129,7 +134,7 @@ namespace Serial_Observer
}
}
/************************* Private Methods *************************/
/************************* Private Methods Form1 *************************/
private void InitializeComboBox()
{
// Port name
@ -237,7 +242,7 @@ namespace Serial_Observer
private void AddListItemMethod(String myString)
{
listBox_portLogs.Items.Add(myString);
listBoxGoToLast();
listBoxGoToLastItem();
}
private string HexToString(string hexdata)
@ -252,7 +257,7 @@ namespace Serial_Observer
return (String.Join("", hexDataSplit));
}
private void listBoxGoToLast()
private void listBoxGoToLastItem()
{
listBox_portLogs.TopIndex = listBox_portLogs.Items.Count - 1;
}

53
microCopy/microCopy.ino Normal file
View File

@ -0,0 +1,53 @@
#define TAILLE_TABLEAU (4)
int i = 0;
char tab[TAILLE_TABLEAU];
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available() > 0)
{
while(Serial.available())
{
tab[i++] = Serial.read();
}
if(tab[0] == 0x02 && tab[1] == 0x0C && tab[2] == 0x00 && tab[3] == 0x00)
{
Serial.write("OK\r\n");
Serial.write("Your data is : ");
Serial.write(0x74);
Serial.write(0x65);
Serial.write(0x6D);
Serial.write(0x70);
Serial.write(0x3A);
Serial.write(0x32);
Serial.write(0x1F);
Serial.write(0x43);
Serial.write("\r\n");
for(int count = 0;count<TAILLE_TABLEAU;count++)
{
tab[count] = ' ';
}
}
else if(tab[0] != 0x02 || tab[1] != 0x0C || tab[2] != 0x00 || tab[3] != 0x00)
{
Serial.write("BAD COMMAND\r\n");
for(int count = 0;count<TAILLE_TABLEAU;count++)
{
tab[count] = ' ';
}
}
}
i = 0;
delay(1000);
}