LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

JSON JKI doble parser turns to default values

Solved!
Go to solution

Hello,

The main function of my program is to show the JSON data received from the serial (Arduino communication). VI program is attached.

To convert the string into a values i used "Unflatten From JSON String", a Variant To Data and a cluster to the variables definition. First of all i began with one json parser and it works with no modification as the file shows. But when i decide to send 2 different JSON data strings the "Indicator"s turns to the default values instead to keep the latest ones. Including the indicator of each variant in a state structure nothing change.

My aim is to update the values only when the JSON is the correct one (showing the last correct value in case of error), discarding the other. I suppose that using a global variable or storing the values in an array could solve the problem but i had been working on that 3 days without any advance.

One iteration of the serial is:

{"setupTime":-6144,"downTime":11267,"changeTime":1,"blowTime":14336,"upTime":-146,"surfaceTime":-769,"angleDown":0,"angleUp":1024,"cycles":-23552,"distance":3379,"heading":-8192,"beta":-15071,"shallowTarget":192,"deepTarget":257,"lattitude":1.12e-41,"longitude":6.92e19}


{"currentState":64,"accx":45,"accy":65,"accz":29,"magx":92,"magy":40,"magz":51,"GPSupdated":85,"currentLattitude":17.00,"currentLongitude":92.00,"pressure":52.00,"goalHeading":55,"currentHeading":55,"pitch":23}


Start Data Science
A
value: 0
D
value: 8486
T
value: 240
End Data Science

Thanks for the help 🙂

0 Kudos
Message 1 of 4
(3,013 Views)
Solution
Accepted by topic author iscapla

@iscapla wrote:

 

My aim is to update the values only when the JSON is the correct one (showing the last correct value in case of error), discarding the other. I suppose that using a global variable or storing the values in an array could solve the problem


I think you just need to use a feedback node to feedback the last known good values into the "Type and Defaults" input. 

0 Kudos
Message 2 of 4
(2,989 Views)

It works. Thanks 🙂

0 Kudos
Message 3 of 4
(2,968 Views)

Hi Can you post the vi in labview 2014.

0 Kudos
Message 4 of 4
(2,648 Views)