LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading String from SPI driver

Spoiler
Spoiler
Spoiler
Hello Guys ,

 

I am reading data from Cheetah Serial Peripheral Interface host adapter. I am expecting a string which will be in Json format, I mean

SPI is directly sending me a JSON string but i am not getting desired string in LabView the way it looks.

Expected string from SPI will looks like this

 

{"nm":"anc",
 "id":21,
"idx":60761165,
"Fs":5333,
"alg":{"err":[0.021106585860, 0.004098004196], "ref":[0.001842514728], "out":[0.000000000000, 0.000000000000],
"w":{"idx":1, "sec":0, "cfs":[0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000]}
}
}

but i am not getting same string in labview and i am using SPI adapter in mode 1 polarity 0 and phase 1

the string that i am getting will looks.

   mn cna di      xdi   †Ïó sF     Õgla  rre  7¿¯‹fer  ·Ò-ütuo            w  xdi       ces       sfc  2

 

Please help me if any of you faced this problem before..........

thank you

 

 

0 Kudos
Message 1 of 3
(3,089 Views)

WIll unflatten JSON string work? 

http://zone.ni.com/reference/en-XX/help/371361K-01/glang/unflatten_from_json/ 

 

It looks like you are getting correct string, but need to reformat it.

JSON string is name-value, so you will not see

"id":21

as a received string.

you will see "idYXXXX" where XXXX is 4 characters corresponding to 32 bits encoding Int32 number 21. May be some type specifying byte(s) Y. Also it is sending strings in reversed order - you get "diYXXXX".

0 Kudos
Message 2 of 3
(3,059 Views)

Hi Alexander , I have tried it yes bits are coming in reverse order.

For unflattening the JSON string i have used it but i am not getting it. To make sure i have used the GUI given by Cheetah for windows and it is also giving me same string as the labVIEW is giving and that to in reverse order. I am  getting error with JSON unflatten when i am using that. I am directly connecting the string to json unflatten module.

 

error is

JKI JSON Serialization.lvlib:JSON Lexer.lvclass:Run.vi:1530001<ERR>
Internal error
<b>Complete call chain:</b>
     JKI JSON Serialization.lvlib:JSON Lexer.lvclass:Run.vi:1530001
     JKI JSON Serialization.lvlib:JSON Lexer.lvclass:Tokenize String.vi:2030001
     JKI JSON Serialization.lvlib:Parser.lvclass:Parse Input String.vi:1590001
     JKI JSON Serialization.lvlib:JSON Parser.lvclass:Parse JSON String.vi
     JKI JSON Serialization.lvlib:JSON Deserializer.lvclass:Unflatten From String.vi:2180001
     JKI JSON Serialization.lvlib:Unflatten From JSON String.vi:4940001
     Cheetah Example SPI.vi

0 Kudos
Message 3 of 3
(3,047 Views)