Browse Source

bug fixe, serial input not correct recept data and send output not correct send code, edit Arduino C for this.

valentin 2 years ago
parent
commit
72543a97a5

+ 23 - 0
PIGOU/nbproject/UPDATED.TXT

@@ -0,0 +1,23 @@
+==================================
+Project Pigou build script updated
+==================================
+
+Project build script file jfx-impl.xml in nbproject sub-directory has not been recognized
+as compliant with this version of NetBeans JavaFX support module. To ensure correct
+and complete functionality within this NetBeans installation the script file has been
+backed up to jfx-impl_backup.xml and then updated to the currently supported state.
+
+FX Project build script auto-update may be triggered on project open either after
+NetBeans installation update or by manual changes in jfx-impl.xml. Please note that
+changing jfx-impl.xml manually is not recommended. Any build customization code should
+be placed only in build.xml in project root directory.
+
+Remark: The auto-update mechanism can be disabled by setting property
+javafx.disable.autoupdate=true
+Automatic opening of this notification when project files are updated can be disabled by setting property
+javafx.disable.autoupdate.notification=true
+(in build.properties, private.properties or project.properties).
+
+Remark: Files nbproject/jfx-impl_backup*.xml and this file nbproject/UPDATED.TXT
+are not used when building the project and can be freely deleted.
+

File diff suppressed because it is too large
+ 4008 - 0
PIGOU/nbproject/jfx-impl_backup.xml


+ 9 - 4
Pigou/src/fr/deltastar/pigou/communication/SerialClient.java

@@ -79,12 +79,17 @@ public class SerialClient implements ComClientInterface, SerialPortEventListener
     }
     
     @Override
-    public void serialEvent(SerialPortEvent spe) {
+    public synchronized void serialEvent(SerialPortEvent spe) {
         if (spe.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
             try {
                 char[] result = new char[2];
-                this.in.read(result);
-                String input = String.valueOf(result[0]) + String.valueOf(result[1]);
+                String input = "";
+                //pour palier au probleme de un chiffre a la fois, on attend que
+                //la liaison série emmet 2 caracteres renseigné ex: 02 ou 12
+                do {
+                    this.in.read(result);
+                    input = input + String.valueOf(result[0]) + String.valueOf(result[1]);
+                } while (input.trim().length() < 2);
                 listenerCom.onDataReceved(input);
                 if (StatusComViewController.getInstance() != null)
                     StatusComViewController.getInstance().addDataInput(input);
@@ -109,7 +114,7 @@ public class SerialClient implements ComClientInterface, SerialPortEventListener
                 try {
                     if (out == null)
                         out = new PrintWriter(serialPort.getOutputStream());
-                    out.write(data + "\n");
+                    out.write(data);
                     System.out.println("Data send on " + nameCom + " : " + data);
                     out.flush();
                 } catch (Exception ex) {

+ 3 - 3
Pigou/src/fr/deltastar/pigou/view/SettingsArduinoCom.fxml

@@ -27,9 +27,9 @@
                   <Font size="24.0" />
                </font>
             </Label>
-            <ComboBox fx:id="cbArduinoA" layoutX="515.0" layoutY="137.0" prefHeight="25.0" prefWidth="93.0" onAction="#cbArduinoAOnChange"  />
-            <ComboBox fx:id="cbArduinoB" layoutX="515.0" layoutY="182.0" prefHeight="25.0" prefWidth="93.0" onAction="#cbArduinoBOnChange" />
-            <ComboBox fx:id="cbArduinoC" layoutX="515.0" layoutY="226.0" prefHeight="25.0" prefWidth="93.0" onAction="#cbArduinoCOnChange" />
+            <ComboBox fx:id="cbArduinoA" layoutX="515.0" layoutY="137.0" prefHeight="25.0" prefWidth="120.0" onAction="#cbArduinoAOnChange"  />
+            <ComboBox fx:id="cbArduinoB" layoutX="515.0" layoutY="182.0" prefHeight="25.0" prefWidth="120.0" onAction="#cbArduinoBOnChange" />
+            <ComboBox fx:id="cbArduinoC" layoutX="515.0" layoutY="226.0" prefHeight="25.0" prefWidth="120.0" onAction="#cbArduinoCOnChange" />
             <Button fx:id="btnSave" layoutX="297.0" layoutY="315.0" mnemonicParsing="false" onAction="#btnSaveClick" prefHeight="64.0" prefWidth="220.0" stylesheets="@../resources/css/baseStyle.css" text="Save" />
          </children>
       </Pane>

+ 10 - 2
arduino/ArduinoC/ArduinoC.ino

@@ -74,7 +74,11 @@ void loop() {
   for (int i = 0; i < nbSwitch; i++) {
     currentStateRead = digitalRead(inputSwitch[i]);
     if (currentStateRead != currentStateInputSwitch[i]) {
-      Serial.print(i);
+      String output = String(i);
+      if (i < 10) {
+        output = "0" + output;
+      }
+      Serial.print(output);
       currentStateInputSwitch[i] = currentStateRead;
     }
   }
@@ -84,7 +88,11 @@ void loop() {
   for (int i = 0; i < nbButton; i++) {
     currentStateRead = digitalRead(inputButton[i]);
     if (currentStateRead != currentStateInputButton[i] && finalStateInputButton[i] != currentStateRead) {
-      Serial.print(currentPort);
+      String output = String(currentPort);
+      if (currentPort < 10) {
+        output = "0" + output;
+      }
+      Serial.print(output);
     }
     currentStateInputButton[i] = currentStateRead;
     currentPort++;