Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 07:04pm 08 May 2020
Copy link to clipboard
Print this post
I'm trying to parse data from the UDP port on my router to collect my Weatherflow data
I've managed to figure out how to get the UDP packets
What I need to parse is the coloured sections in the snippet of what's received below
The obs section contains all the relevant data I need to collect like windspeed, direction temp etc
Can anyone help with telling me how to parse this data?
I "think" it could be done by trying to capture the data starting with serial number for example if "serial_number": = "AR-00001937"," then print ,"voltage": if "serial_number": = "AR-00001937"," then print ,"obs": if "serial_number": = "SK-00011961," then print ,"voltage": if "serial_number": = "SK-00011961"," then print ,"obs":
But no idea how to do it I'm using a Pi-Cromite if it makes a difference
This is the code I used to get the UDP packets
DIM a$,b$,c% on error skip udp server 50222 do pause 500 on error skip UDP receive a$,b$,c% if c%>0 then print a$ end if loop on error skip udp close
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 06:37am 09 May 2020
Copy link to clipboard
Print this post
What I'm trying to get is the parts coloured below
I would normally be able to do it by doing something like
voltage$=JSON$(a(),"AR-00001937.voltage")'Voltage I know I can parse the obs bit by using comma parsing but
The problem I have is the UDP port sends out several different packets with different information and I only want the specified bits
Is there a way to do
IF obs_sky then parse obs IF obs_air then parse obs but I need a way to differentiate the results so I can display them properly
if "SK-00011961","type":"device_status" then parse obs (but identify it as obs_sky) if "AR-00001937","type":"device_status" then parse obs (but identify it as obs_air)
Can anyone suggest a way to do this?
This is the sections from the obs that I need to parse
Edited 2020-05-09 19:02 by lew247
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 655
Posted: 09:01am 09 May 2020
Copy link to clipboard
Print this post
G'Day Lew
I am sticking my neck out again. Have you looked at Geoff' GPS software? If nothing else it will give you something to read while you wait for somebody who knows what they are talking about to come in.
Peter
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 09:03am 09 May 2020
Copy link to clipboard
Print this post
I know I can parse the obs bit by using comma parsing but
The problem I have is the UDP port sends out several different packets with different information and I only want the specified bits
Is there a way to do
IF obs_sky then parse obs IF obs_air then parse obs but I need a way to differentiate the results so I can display them properly
if "SK-00011961","type":"obs_sky" then parse obs (but identify it as obs_sky) if "AR-00001937","type":"obs_air" then parse obs (but identify it as obs_air)
Can anyone suggest a way to do this?
This is the sections from the obs that I need to parse