bemasher / rtlamr-collect

Data aggregation for rtlamr.
GNU Affero General Public License v3.0
171 stars 29 forks source link

main.go:427: json unmarshal: json: Unmarshal(nil) #26

Closed brotherdust closed 4 years ago

brotherdust commented 4 years ago

Hi! Thanks for making this great software!

I've run into a bit of a problem... when I run rtlamr-collect, I get the message main.go:427: json unmarshal: json: Unmarshal(nil). I've verified that rtlamr is outputting valid JSON:

$ rtlamr -msgtype="all" -format=json
10:53:34.045567 flags.go:111: Environment variable "RTLAMR_FILTERID" overrides flag "filterid" with "XXX"
10:53:34.046319 decode.go:45: CenterFreq: 912380000
10:53:34.046330 decode.go:46: SampleRate: 2359296
10:53:34.046338 decode.go:47: DataRate: 32768
10:53:34.046356 decode.go:48: ChipLength: 72
10:53:34.046366 decode.go:49: PreambleSymbols: 32
10:53:34.046377 decode.go:50: PreambleLength: 4608
10:53:34.046394 decode.go:51: PacketSymbols: 736
10:53:34.046400 decode.go:52: PacketLength: 105984
10:53:34.046407 decode.go:59: Protocols: scm,scm+,idm,r900
10:53:34.046413 decode.go:60: Preambles: 111110010101001100000,0001011010100011,01010101010101010001011010100011,00000000000000001110010101100100
10:53:34.046419 main.go:111: GainCount: 29
{"Time":"2020-09-13T10:53:43.338550439-06:00","Offset":0,"Length":0,"Message":{"ID":XXX,"Unkn1":163,"NoUse":0,"BackFlow":0,"Consumption":4058505,"Unkn3":0,"Leak":2,"LeakNow":0}}

Any ideas why unmarshaling is returning nil?

Thanks much!

brotherdust commented 4 years ago

Ok. I think I have an idea why this is happening, either: a) my meter(s) don't output some of the expected fields b) the decoder isn't decoding the fields and/or outputting them

As I'm not a Go developer, I have no idea how to make these fields optional. I guess it's time to learn Go! ha.

bemasher commented 4 years ago

The version of rtlamr you are using is not compatible with rtlamr-collect, the output is missing the Type field.

brotherdust commented 4 years ago

The version of rtlamr you are using is not compatible with rtlamr-collect, the output is missing the Type field.

Oh. I just pulled from master. What version should I be using?

brotherdust commented 4 years ago

It would seem that rtlamr should be outputting the Type field:

https://github.com/bemasher/rtlamr/blob/22749a729e9dfb82be1016d2454026ca74126480/main.go#L249

brotherdust commented 4 years ago

Yeah nevermind. I was telling nix to build from an old tag, not master. Serves me right. Thanks!

bemasher commented 4 years ago

I found the issue. I had made a new tag including the commits necessary for compatibility with this version of rtlamr-collect, but had not pushed it to the repository, new clones should behave as intended.