Gps data collating satellite info on GPGSV messages

Hi all,
I'm working on some gps data using GSV messages.
what i would like to do and am failing miserably at is to collate the data into a json message.
GSV sends 19 blocks of data.
blocks are
1 Total Number of messages
2 Message number
3 Total number of Sv's in view
4-7. Are info on sat1 of this message number, elevation, azimuth SNR
8-11. second satellite
12-15. third satellite
16-20. fourth satellite and checksum
The message is sent multiple times one after the other.
I would like to get each message section and collate the 4 satelites per message into one array.
ive tried multiple things so far and i can get the data into an array of objects but only per message im not sure how to join the multiple results into one array.

[[{"Sat_Number":26,"Elevation":79,"Azimuth":200,"SNR":24},{"Sat_Number":16,"Elevation":56,"Azimuth":297,"SNR":14},{"Sat_Number":27,"Elevation":27,"Azimuth":263,"SNR":33},{"Sat_Number":31,"Elevation":31,"Azimuth":20,"SNR":null}]]

the last SNR is null as i haven't removed the check sum yet
what id like is to use the Number of satellites to set an array size, then insert message 1 satellites then message 2 Satellites etc.
then append others if they appear.
any ideas on what would be the best approach for this?
thanks in advance

Would this node help?

I think the OP wants to create A message not parse one.

@vikingsraven The first 3 values seem to be similar, i.e 4 messages 4 satellites etc.
so could you explain a bit more about what these values should be and how they change.

You can get all the values of the incoming json into an array or an array of arrays using JSONata.
e.g.

[{"id":"baf409c9.fa41f","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"sensor/hall","payload":"[[{\"Sat_Number\":26,\"Elevation\":79,\"Azimuth\":200,\"SNR\":24},{\"Sat_Number\":16,\"Elevation\":56,\"Azimuth\":297,\"SNR\":14},{\"Sat_Number\":27,\"Elevation\":27,\"Azimuth\":263,\"SNR\":33},{\"Sat_Number\":31,\"Elevation\":31,\"Azimuth\":20,\"SNR\":null}]]","payloadType":"json","x":210,"y":2660,"wires":[["225951dd.1e6fce","9ddcc24b.ab8158"]]},{"id":"9ddcc24b.ab8158","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload[0].[$.*]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":2700,"wires":[["298f044.73ac97c"]]},{"id":"225951dd.1e6fce","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$spread($$.payload).*","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":2660,"wires":[["298f044.73ac97c"]]},{"id":"298f044.73ac97c","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":2620,"wires":[]}]

lastly what is the checksum?

He did say "collate", I assumed he wanted to parse it.

thanks guys, maybe not worded it correctly, typing from brain directly lol.
@ghayne thanks , i have used that node, works fine for base data, im pulling the message out ok using s the serial node a switch and csv nodes.
@E1cid sort of what im thinking.
i have the previous data coming out of the function node.
[[{"Sat_Number":26,"Elevation":79,"Azimuth":200,"SNR":24},{"Sat_Number":16,"Elevation":56,"Azimuth":297,"SNR":14},{"Sat_Number":27,"Elevation":27,"Azimuth":263,"SNR":33},{"Sat_Number":31,"Elevation":31,"Azimuth":20,"SNR":null}]]
so this is one full list that's coming out, if you have 12 satellite's you'll get 3 sets of messages, different values. 20 satellites 5 messages.
what id like to do is add all of the output data into one long packet (im not sure on correct term, array or object still getting head round that!)
then i can pull all the positions out from that and plot them as required.
Re the checksum on a message that has less than 4 satellites on it is separated by a comma otherwise its part of the last SNR reading. fortunately it has a * in front of it for splitting.
Hope that makes more sense. ill re read it and check.

You will need to join the incoming messages, something like this. I have simulated 3 incoming messages, and used a trigger node to work out when last message has arrived and complete the join, then I used a JSONata expression to flatten the array into a array of objects.
e.g.

[{"id":"34390b6c.7694dc","type":"function","z":"bf9e1e33.030598","name":"simulate incoming messages","func":"delete msg.parts;\nmsg.payload =[[{\"Sat_Number\":26,\"Elevation\":79,\"Azimuth\":200,\"SNR\":24},\n{\"Sat_Number\":16,\"Elevation\":56,\"Azimuth\":297,\"SNR\":14},\n{\"Sat_Number\":27,\"Elevation\":27,\"Azimuth\":263,\"SNR\":33},\n{\"Sat_Number\":31,\"Elevation\":31,\"Azimuth\":20,\"SNR\":null}]]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":2500,"wires":[["75ff8ac4.9a9b7c","535ac1a9.259ca8"]]},{"id":"ee08a859.2a057","type":"split","z":"bf9e1e33.030598","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":290,"y":2500,"wires":[["34390b6c.7694dc"]]},{"id":"75ff8ac4.9a9b7c","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":830,"y":2560,"wires":[["65a3a5c3.c5b2d4"]]},{"id":"535ac1a9.259ca8","type":"trigger","z":"bf9e1e33.030598","name":"","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":450,"y":2560,"wires":[["a34007fa.059ae8"]]},{"id":"f337cc92.6884b8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3]","payloadType":"json","x":350,"y":2460,"wires":[["ee08a859.2a057"]]},{"id":"a34007fa.059ae8","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":2560,"wires":[["75ff8ac4.9a9b7c"]]},{"id":"65a3a5c3.c5b2d4","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.*","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":2560,"wires":[["136cf474.a14224"]]},{"id":"136cf474.a14224","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1210,"y":2560,"wires":[]}]```

The trigger node waits for a gap of 1 second in messages to send msg.complete. Hope it helps.

@E1cid thanks , that's done the job. Not used the complete option before, will look into it more. thanks again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.