Trying to open Images with jSon Object shows unreliable behavior

Hi,
Currently we are working on a project where we send signals from an Android app to an arduino. The arduino controls a robot and send the signals via serial communication (in jSon format) to a GUI. The GUI is written in Java with Processing 3.3.7. For example if I press a specific button the GUI shows a green circle which refers to that signal, otherwise it shows a red circle. Unfortunately it does not work as desired. Sometimes the circle turns green, most of the times it stays red and sometimes it stays green for about 2 seconds.

Here is the Arduino Code:

#include<ArduinoJson.h>
#include <Wire.h>

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  Wire.begin(); // join i2c bus (address optional for master)
}
void loop() {
  DynamicJsonBuffer jBuffer;
  JsonObject& root = jBuffer.createObject();


  if (Serial1.available() >= 0) {
    int inByte = Serial1.read();
    // Arduino connected
    root["ArdC"] = "1";

    switch (inByte) {
      case 'A':
        root["XF"] = "1";
        root["XD"] = "0";
        root["YL"] = "0";
        root["YR"] = "0";
        root["ZU"] = "0";
        root["ZD"] = "0";
        root["Init"] = "0";
        break;
      case 'C':
        root["XF"] = "0";
        root["XD"] = "1";
        root["YL"] = "0";
        root["YR"] = "0";
        root["ZU"] = "0";
        root["ZD"] = "0";
        root["Init"] = "0";
        break;
      case 'G':
        root["XF"] = "0";
        root["XD"] = "0";
        root["YL"] = "1";
        root["YR"] = "0";
        root["ZU"] = "0";
        root["ZD"] = "0";
        root["Init"] = "0";
        break;
      case 'E':
        root["XF"] = "0";
        root["XD"] = "0";
        root["YL"] = "0";
        root["YR"] = "1";
        root["ZU"] = "0";
        root["ZD"] = "0";
        root["Init"] = "0";
        break;
      case 'I':
        root["XF"] = "0";
        root["XD"] = "0";
        root["YL"] = "0";
        root["YR"] = "0";
        root["ZU"] = "1";
        root["ZD"] = "0";
        root["Init"] = "0";
        break;
      case 'K':
        root["XF"] = "0";
        root["XD"] = "0";
        root["YL"] = "0";
        root["YR"] = "0";
        root["ZU"] = "0";
        root["ZD"] = "1";
        root["Init"] = "0";
        break;
      case 'M':
        root["XF"] = "0";
        root["XD"] = "0";
        root["YL"] = "0";
        root["YR"] = "0";
        root["ZU"] = "0";
        root["ZD"] = "0";
        root["Init"] = "1";
      default:
        // X-Axis forwards
        root["XF"] = "0";
        //X-Axis Downwards
        root["XD"] = "0";
        // Y-Axis Left
        root["YL"] = "0";
        // Y-Axis Right
        root["YR"] = "0";
        // Z-Axis Up
        root["ZU"] = "0";
        // Z-Axis Down
        root["ZD"] = "0";
        // Initialise
        root["Init"] = "0";
    }
    // Bluetooth connected
    root["Blth"] = "0";
    // Limit Switch Rotary
    root["LimR"] = "0";
    // Limit Switch Horizontal
    root["LimH"] = "0";
    // Limit Switch Vertical
    root["LimV"] = "0";
    // Wire Touched
    root["WT"] = "0";
    root.printTo(Serial);
    Serial.println();
  }
}

void wireWrite(char* inputString) {
  Wire.beginTransmission(8); // transmit to device #8
  for (int i = 0; i < 31; i++) {
    Wire.write(inputString[i]);
  }
  Wire.endTransmission();    // stop transmitting
}

Here is the Processing Code:

import gifAnimation.*;
import processing.serial.*;

int lf = 10;    // Linefeed in ASCII
String myString = null;
Serial myPort;  // The serial port
PImage imgGreen;
PImage imgRed;
PImage wallpaper;

boolean LimitSwitchVerticalAxisReached = false;
boolean LimitSwitchHorizontalAxisReached = false;
boolean LimitSwitchRotaryAxisReached = false;
boolean jsonFlag = false; 

void setup() {
  fullScreen();
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.clear();
  imgGreen = loadImage("greenEggSmall.png");
  imgRed = loadImage("redEggSmall.png");
  wallpaper = loadImage("Wallpaper4.jpg");

  void draw() {
    background(wallpaper);

    // Grey Background for "Home Position Finished"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(90, 955, 520, 70, 20);

    // Grey Background for "Limit Switch Horizontal Axis"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(90, 855, 520, 70, 20);

    // Grey Background for "Limit Switch Rotary Axis"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(90, 755, 520, 70, 20);

    // Grey Background for "Limit Switch Vertical Axis"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(90, 655, 520, 70, 20);

    // Grey Background for "Motor-X Running"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(700, 655, 390, 70, 20);

    // Grey Background for "Motor-Y Running"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(700, 755, 390, 70, 20);

    // Grey Background for "Motor-Z Running"
    fill(229, 229, 229, 100);
    stroke(0, 0, 0, 100); 
    rect(700, 855, 390, 70, 20);

    while (myPort.available() > 0) {
      String myString = myPort.readStringUntil('}');

      if (myString != null) {
        println(myString);
        String subString = null;

        if (myString.length() > 8) {
          subString = myString.substring(4, 8);
        } else {
          subString = "defaultString";
        }

        if (subString.equals("ArdC") == true) {
          jsonFlag = true;
        } else {
          jsonFlag = false;
        }

        if (jsonFlag == true) {
          try {
            JSONObject json = JSONObject.parse(myString);
            String vArduinoConnected = json.getString("ArdC");
            String btnXForward = json.getString("XF");
            String btnXDownward= json.getString("XD");
            String btnYLeft= json.getString("YL");
            String btnYRight= json.getString("YR");
            String btnZUp= json.getString("ZU");
            String btnZDown= json.getString("ZD");
            String btnInitialise= json.getString("Init");
            String LimitSwitchRotary = json.getString("LimR");
            String LimitSwitchHorizontal = json.getString("LimH");
            String LimitSwitchVertical = json.getString("LimV");
            println(btnXForward);

            if (LimitSwitchHorizontalAxisReached && LimitSwitchRotaryAxisReached && LimitSwitchVerticalAxisReached) {
              image(imgGreen, 550, 965);
            } else {
              image(imgRed, 550, 965);
            }

            if (LimitSwitchHorizontal.equals("1") == true) {
              image(imgGreen, 550, 865);
              LimitSwitchHorizontalAxisReached = true;
            } else {
              image(imgRed, 550, 865);
            }

            if (LimitSwitchRotary.equals("1") == true) {
              image(imgGreen, 550, 765);
              LimitSwitchRotaryAxisReached = true;
            } else {
              image(imgRed, 550, 765);
            }

            if (LimitSwitchVertical.equals("1") == true) {
              image(imgGreen, 550, 665);
              LimitSwitchVerticalAxisReached = true;
            } else {
              image(imgRed, 550, 665);
            }

            if ((btnXForward.equals("1")) == true || (btnXDownward.equals("1"))== true) {
              image(imgGreen, 1030, 665);
            } else {
              image(imgRed, 1030, 665);
            }

            if ((btnYLeft.equals("1") == true) || (btnYRight.equals("1")  == true)) {
              image(imgGreen, 1030, 765);
            } else {
              image(imgRed, 1030, 765);
            }

            if ((btnZUp.equals("1") == true) || (btnZDown.equals("1")  == true)) {
              image(imgGreen, 1030, 865);
            } else {
              image(imgRed, 1030, 865);
            }
          } 

          catch (Exception e) {
            println("An error occured, while trying to parse the jSon object.");
          }
        }

        textSize(30);
        fill(255, 255, 255);
        text("Home Position Finished", 110, 1000);

        fill(255, 255, 255);
        text("Limit Switch Horizontal Axis", 110, 900);

        fill(255, 255, 255);
        text("Limit Switch Rotary Axis", 110, 800);

        fill(255, 255, 255);
        text("Limit Switch Vertical Axis", 110, 700);

        fill(255, 255, 255);
        text("Motor-X Running", 720, 700);

        fill(255, 255, 255);
        text("Motor-Y Running", 720, 800);

        fill(255, 255, 255);
        text("Motor-Z Running", 720, 900);

        textSize(40);
        fill(255, 255, 255);
        text("Motor Direction", 1200, 600);
      }
    }
  }

Maybe following devices built in my notebook are important:
Processors: 4 x Intel® Core™ i7-4710MQ CPU @ 2.50GHz
RAM: 8.00 GB
System type: 64-bit Operating System, x64-based processor
Display Adapters: Intel® HD Graphics 4600,NVIDIA GeForce GT 730M

Thank you very much for your help !
Best wishes,
Niko

I don’t know anything about what you’re trying to do, but even I can tell that the end of your processing code has a few things that are probably ruining the whole thing

here’s the modified version,
https://pastebin.com/7CdGFFXF

since the block of code at the end is running on a loop, you need to not only be changing the bool variables to true, but also back to false if they are deemed false in the next iteration of the loop.

you also have an if statement that depends on the other if statements all returning true:

if (LimitSwitchHorizontalAxisReached && LimitSwitchRotaryAxisReached && LimitSwitchVerticalAxisReached) {
  image(imgGreen, 550, 965);
} else {
  image(imgRed, 550, 965);
}

This needs to be moved to the end of the block of if statements, in case all the other if statements return true in the 1st iteration of the loop. If you don’t do this, it will take until the 2nd iteration of the loop to register that all the values are true & the code can be executed.

I hope this fixes your issue, because that’s as far as my little knowledge goes.

Thanks for your reply !
Stupid me, thanks for the correction. But unfortunately that doesn’t solve the issue. The unreliable behavior also occurs if i just send the signal for i.e “btnXForward”.
To describe the unreliable behavior again: The byte stream (in jSon) format gets recieved correctly (im printing it out on the command window), but the “signal lamp” (the red or green circle) does not always blinks red or green when it should be. Its strange, because it always prints the correct stream in real time, but the image does not show according to that.
Maybe the frame rate is to high, that the image could not be loaded fast enough? Any thoughts?

The image load speed should not be an issue, because it is loaded during setup(), and kept in memory. You can always try to limit the framerate by calling the frameRate() function during setup().

  frameRate(30);

As I said, I don’t have much knowledge so you might have to wait for another person to come by and try to help you

You mentioned Android in your first post. How are you connecting your Arduino to your Android? Or is this via B2?

I see you have two serial connections in your ino? Is that correct?

This problems are hard to debug without running your code. I suggest you create a smaller example showing the problem so you can identify the problem/bug more easily.

Kf

I’m not quite sure what B2 is. The App sends signals to a HC-05 Bluetooth Modul and reads and writes via serial communication.

From there, the Arduino sends the jSon object also via serial communication to the GUI (through USB).

The Arduino sends this if no button has been pressed in the App:

{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}

If i press the Button UP (in this case the XF, for X-Axis Forward) this string gets sent from Arduino to Processing:

{"ArdC":"1","XF":"1","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}

That works fine. It is very reliable and always in Realtime. But the problems occur if I want to process the jSon object. So i.e if I ask: “Is XF == 1”, it jumps into the correct if-case (i know that because i print out a test string on the command window). The strange thing is, that the test string ALWAYS gets printed out, but the image (which is right above the println(“test string”)) DOES NOT always gets shown.

I shortened the Processing code to the minimum:

import processing.serial.*;

String myString = null;
Serial myPort;  // The serial port
PImage imgGreen;
PImage imgRed;
PImage wallpaper;

void setup() {
  fullScreen();
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.clear();
  imgGreen = loadImage("greenEggSmall.png");
  imgRed = loadImage("redEggSmall.png");
  wallpaper = loadImage("Wallpaper4.jpg");

  void draw() {
    background(wallpaper);
    while (myPort.available() > 0) {
      String myString = myPort.readStringUntil('}');

      if (myString != null) {
        try {
          JSONObject json = JSONObject.parse(myString);
          String btnXForward = json.getString("XF");

          if ((btnXForward.equals("1")) == true) {
            image(imgGreen, 1030, 665);
          } else {
            image(imgRed, 1030, 665);
          }

          catch (Exception e) {
            println("An error occured, while trying to parse the jSon object.");
          }
        }
      }
    }
  }

Thanks for your help !
Niko

Niko

B2 I was referring to bluetooth

So from what I understand, you are continuously sending the string where it updates each section of your screen. For instance, Checking XF sets the image on region 1030,665:

String btnXForward = json.getString("XF");
...
 if ((btnXForward.equals("1")) == true || (btnXDownward.equals("1"))== true) {
   image(imgGreen, 1030, 665);
} else {
   image(imgRed, 1030, 665);
}

First question: Are you holding XF in “1” state during a long period?

Notice you are using btnXForward.equals("1"). I suggest that when you extract the value in the parsing process, you also add the trim() function to remove space characters. Not sure if it solves this problem but worth to try. For debugging, instead of printing outside the if statement, place your printing clause inside. It will look messier but you will be able to evaluate the functionality of that statement directly.

So from what I understand, you are continuously sending the string where it updates each section of your screen. For instance, Checking XF sets the image on region 1030,665:

Yes exactly.

First question: Are you holding XF in “1” state during a long period?

No, if I push the button, it gets sent only ONE time.

Notice you are using btnXForward.equals(“1”). I suggest that when you extract the value in the parsing process, you also add the trim() function to remove space characters.

Ok thanks! I’ll give it a try. But I think the data is always valid. I printed out the value and the size of it (1 character). So I think, that doesn’t solve the issue.
Meanwhile thank you very much for your advices !
Niko

If you send it only once, that could be the issue. Maybe I do not have all the information. This is what you could do. Disable all the print statements in your code. Node add the following modification:

println(millis()+" ms reports XF like " + btnXForward +" boolean: " +  ( btnXForward.equals("1") ));
if ((btnXForward.equals("1")) == true || (btnXDownward.equals("1"))== true) {
   image(imgGreen, 1030, 665);
} else {
   image(imgRed, 1030, 665);
}

If you run this, do you see only XF set to 1 only once? Can you paste your output here just few seconds of data.

Kf

Hey, so here is the output as you requested:
(For the record i pushed the button three times)

1406 ms reports XF like 0 boolean: false
1530 ms reports XF like 0 boolean: false
1675 ms reports XF like 0 boolean: false
1800 ms reports XF like 0 boolean: false
1941 ms reports XF like 0 boolean: false
2081 ms reports XF like 0 boolean: false
2206 ms reports XF like 0 boolean: false
2347 ms reports XF like 0 boolean: false
2487 ms reports XF like 0 boolean: false
2612 ms reports XF like 0 boolean: false
2753 ms reports XF like 0 boolean: false
2894 ms reports XF like 0 boolean: false
3019 ms reports XF like 0 boolean: false
3161 ms reports XF like 0 boolean: false
3290 ms reports XF like 0 boolean: false
3428 ms reports XF like 0 boolean: false
3569 ms reports XF like 0 boolean: false
3698 ms reports XF like 0 boolean: false
3839 ms reports XF like 0 boolean: false
3979 ms reports XF like 0 boolean: false
4104 ms reports XF like 0 boolean: false
4243 ms reports XF like 0 boolean: false
4384 ms reports XF like 0 boolean: false
4509 ms reports XF like 0 boolean: false
4649 ms reports XF like 0 boolean: false
4790 ms reports XF like 0 boolean: false
4915 ms reports XF like 0 boolean: false
5055 ms reports XF like 0 boolean: false
5196 ms reports XF like 0 boolean: false
5321 ms reports XF like 0 boolean: false
5467 ms reports XF like 0 boolean: false
5596 ms reports XF like 0 boolean: false
5736 ms reports XF like 1 boolean: true
5861 ms reports XF like 0 boolean: false
6003 ms reports XF like 0 boolean: false
6128 ms reports XF like 0 boolean: false
6268 ms reports XF like 0 boolean: false
6409 ms reports XF like 1 boolean: true
6534 ms reports XF like 0 boolean: false
6690 ms reports XF like 0 boolean: false
6815 ms reports XF like 0 boolean: false
6940 ms reports XF like 0 boolean: false
7081 ms reports XF like 0 boolean: false
7221 ms reports XF like 0 boolean: false
7346 ms reports XF like 1 boolean: true
7487 ms reports XF like 0 boolean: false
7628 ms reports XF like 0 boolean: false
7753 ms reports XF like 0 boolean: false
7893 ms reports XF like 0 boolean: false
8034 ms reports XF like 0 boolean: false
8159 ms reports XF like 0 boolean: false
8300 ms reports XF like 0 boolean: false
8440 ms reports XF like 0 boolean: false

Niko

I had a look at your data. You have about 53 events in 7 secs. This means you have a rate of 7Hz aka 7 events per second on your serial stream.

Processing runs at 60fps, or 60 frames per second. Your draw looks like this:

void draw(){
  background(wallpaper);  //Draws on your canvas 60fps [REF1]

  while (myPort.available() > 0) {  //It gets executed about 7 times per second  [REF2]

      ...process json

       if(XF.equals("1")==true){     // This is a problem. See comment below  [REF3]
       }
  }
  
}

I am going to assume the main problem is in the actual design of your code. I hope it is clear from the comments above. I have to talk about REF3. If you only press the button once, it will be capture by the line in REF3 only once. At the end of draw, it is displayed. However, when I new cycle of draw enters, REF1 will clean your canvas and start with a new fresh background. Then you need to redraw everything there again. You won’t be able to draw the image associated to XF because of two reasons:

  1. You need to enter the while loop so for the image to be drawn. This only happens when you get a valid serial event, at a rate of 7Hz.
  2. Even when you enter the while loop, if you don’t press the button, XF value would be 0, so you will see the imgRed. Based on your code, your imgRed should be flashing as it is drawn only 7 times per second compared to the background’s update rate which is happening at 60fps. In other words, you should see this imgRed 1 every 9 frames (I am not referring to imgGreen as this will be seeing only once when triggered, 1 frame out of 60 frames in a second)

I can suggest modifying your design. Start a small sketch and create a small proof of concept. This is my suggestion:


boolean XFflag=false;  

void draw(){
  background(wallpaper);  //Draws on your canvas 60fps [REF1]

  while (myPort.available() > 0) {  //It gets executed about 7 times per second  [REF2]

      ...process json

         
       XFflag =  btnXForward.equals("1");  //Updates XF field
       
  }

  image(XFflag ? imgGreen : imgRed,1030,665);
  
}

With this suggestion, if you press the button once, the imgGreen should stay up for about 9 frames, enough for you to see it. If the while loop is not triggered (because of no events on the serial queu), you will still see either a imgRed or an imgGreen.

With this layout, you can still modify it further so you could force, for instance, the green image to stay up for a fixed amount of time. However, I did not implement that because:

  1. You need to check this approach and understand if this will work for you
  2. If you are working on a responsive design, then maybe you want to manage all your events real time.

I have a question. The timed data you provided above is great. What would happen if you keep the button pressed for about a second. Would you register continuous '1’s or would you device only emit a single shot per event?

Kf

WOW !
Thank your very much for the detailed explanation!

It only gets sent once, because the signal is triggered by releasing the button. I currently work with a temporary app I created with MIT App Inventor. A college is working on an app with Android Studio, so if you have a suggestion please let me know of it.

Unfortunately it still doesn’t work as desired. I really can’t see any flaws in your approach, but here is the current minimalistic arduino code:

import processing.serial.*;

String myString = null;
Serial myPort;  // The serial port
PImage imgGreen;
PImage imgRed;
PImage wallpaper;
boolean XFflag=false; 

void setup() {
  fullScreen();
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.clear();
  imgGreen = loadImage("greenEggSmall.png");
  imgRed = loadImage("redEggSmall.png");
  wallpaper = loadImage("Wallpaper4.jpg");
}

void draw() {
  background(wallpaper);

  while (myPort.available() > 0) {
    String myString = myPort.readStringUntil('}');

    if (myString != null) {
      print(millis()+" ms   :");
      println(myString);
      try {
        JSONObject json = JSONObject.parse(myString);
        String btnXForward = json.getString("XF");
        XFflag =  btnXForward.equals("1");  //Updates XF field
      } 
      catch (Exception e) {
        println("An error occured, while trying to parse the jSon object.");
      }
    }
  }
  image(XFflag ? imgGreen : imgRed, 1030, 665);
  print(millis()+" ms   :");
  println(XFflag);
}

Here is the output:

1392 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
1527 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
1662 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
1798 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
1933 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2068 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2203 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2338 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2473 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2608 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2743 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
2879 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3014 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3149 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3285 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3419 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3555 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3690 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3825 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
3960 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4095 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4230 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4365 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4501 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4636 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4771 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
4906 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5041 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5177 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5312 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5448 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5582 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5717 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5852 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
5987 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6122 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6257 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6393 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6528 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6663 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6798 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
6934 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7069 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7204 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7339 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7475 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7609 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7744 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7879 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
7880 ms   :false
8014 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8015 ms   :false
8150 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8150 ms   :false
8285 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8285 ms   :false
8420 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8420 ms   :false
8555 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8555 ms   :false
8691 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8691 ms   :false
8826 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8826 ms   :false
8961 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
8961 ms   :false
9096 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9096 ms   :false
9232 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9232 ms   :false
9366 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9366 ms   :false
9501 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9501 ms   :false
9636 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9636 ms   :false
9771 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9772 ms   :false
9907 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
9907 ms   :false
10042 ms   :{"ArdC":"1","XF":"1","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10042 ms   :true
10177 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10177 ms   :false
10312 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10313 ms   :false
10448 ms   :{"ArdC":"1","XF":"1","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10448 ms   :true
10583 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10583 ms   :false
10718 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10718 ms   :false
10857 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
10993 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11127 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11262 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11397 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11533 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11668 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11803 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
11938 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12074 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12209 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12344 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12479 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12614 ms   :{"ArdC":"1","XF":"1","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12750 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
12884 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13019 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13154 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13290 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13425 ms   :{"ArdC":"1","XF":"1","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13560 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13695 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13831 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
13966 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14101 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14236 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14371 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14507 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14641 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14776 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
14911 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15047 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15182 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15317 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15452 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15588 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15723 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15858 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
15993 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16129 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16264 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16398 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16533 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16668 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16804 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
16939 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17074 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17209 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17345 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17480 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17615 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17750 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
17886 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18021 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18155 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18290 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18426 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18561 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18696 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18831 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
18966 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19102 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19237 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19372 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19507 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19508 ms   :false
19643 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19643 ms   :false
19778 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19778 ms   :false
19912 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
19912 ms   :false
20047 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20047 ms   :false
20183 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20183 ms   :false
20318 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20318 ms   :false
20453 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20453 ms   :false
20588 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20588 ms   :false
20723 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20724 ms   :false
20859 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20859 ms   :false
20994 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
20994 ms   :false
21129 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21129 ms   :false
21264 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21265 ms   :false
21400 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21400 ms   :false
21535 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21535 ms   :false
21669 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21669 ms   :false
21804 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21804 ms   :false
21940 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
21940 ms   :false
22075 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
22075 ms   :false
22210 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
22210 ms   :false
22345 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
22345 ms   :false
22481 ms   :{"ArdC":"1","XF":"0","XD":"0","YL":"0","YR":"0","ZU":"0","ZD":"0","Init":"0","Blth":"0","LimR":"0","LimH":"0","LimV":"0","WT":"0"}
22481 ms   :false

As you can see, it stays for a couple of seconds (!!) in the if (myString != null) loop. It still receives the signal (as you can see at 10042 ms and 10448 ms ) when I push the button in the app, but it doesn’t change the image in that period! During the period from i.e 7880 ms to 10718 ms everything works as desired. It receives the signal (as you can see at 10042 ms or 10448 ms) and changes the image. I cant wrap my head around that, do you have any thoughts on that?

Niko

I still don’t know why the above code behave the way it does. But in the meantime I experimented with multi threading (never worked with it until now, but heard it somewhere) and it seems to work:

import processing.serial.*;

String myString = null;
Serial myPort;  // The serial port
PImage imgGreen;
PImage imgRed;
PImage wallpaper;
boolean XFflag = false; 
boolean jsonFlag = false;

void setup() {
  fullScreen();
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.clear();
  imgGreen = loadImage("greenEggSmall.png");
  imgRed = loadImage("redEggSmall.png");
  wallpaper = loadImage("Wallpaper4.jpg");
}

void draw() {
  background(wallpaper);
  thread("jSonProcessing");
  image(XFflag ? imgGreen : imgRed, 1030, 665);
}

void jSonProcessing() {
  while (myPort.available() > 0) {
    String myString = myPort.readStringUntil('}');
    if (myString != null) {
      if (myString.startsWith("{")) {
        jsonFlag = true;
      } else {
        jsonFlag = false;
      }
      if (jsonFlag == true) {
        try {
          JSONObject json = JSONObject.parse(myString);
          String btnXForward = json.getString("XF");
          XFflag =  btnXForward.equals("1");  //Updates XF field
        } 
        catch (Exception e) {
          println("An error occured, while trying to parse the jSon object.");
        }
      }
    }
  }
}

UPDATE:
The second approach with multi threading doesn’t work reliable aswell…