merbanan / rtl_433

Program to decode radio transmissions from devices on the ISM bands (and other frequencies)
GNU General Public License v2.0
6.14k stars 1.33k forks source link

Comments are not properly ignored when reading flex decoder configuration blocks #2954

Open rct opened 5 months ago

rct commented 5 months ago

In config files, comments beginning with # get filtered out, BUT not if they are part of a decoder { .... } block's key value pairs. Should this an enhancement request or is there some bit of flex decoder syntax that prevents that?

So for example if you try to comment out a line in the decoder or add some doc, you get:

zuckschwerdt commented 5 months ago

It is a deficit of the "parser". The whole "block" is parsed as a single string, as if it was given on the command line. I guess a to-end-of-line comment would not work there. We'd need to strip something like /#.*?\n/ beforehand. I.e. at the beginning of flex_create_device(), before getkwargs().

gdt commented 5 months ago

I hear that these days alll the cool kids are using Parsing Expression Grammars.

zuckschwerdt commented 5 months ago

Sounds fun. I've been enjoying Nom and there seems to be a PEG wrapper for it. I might give that a try just to get a feel of PEG.

rct commented 5 months ago

Interesting, seems the simple quick parse a line has been getting the job done.

Somewhat separate question, does the limitation of 8 get= statements come from current parsing limitations or other practical constraints?

zuckschwerdt commented 5 months ago

It should be 16 possible getters. https://github.com/merbanan/rtl_433/blob/master/src/devices/flex.c#L77 A case of simply "good enough" to have fixed number there, no other reason.

rct commented 5 months ago

Hmm, adding the 9th gives me this error:

rtl_433 version 23.11-126-g7f60fff4 branch master at 202405311102 inputs file rtl_tcp RTL-SDR with TLS
Maximum getter slots exceeded (8)!
Use -X <spec> to add a general purpose decoder. For usage use -X help

When I follow the line you pointed to (line 77) it says, #define GETTER_SLOTS 8

zuckschwerdt commented 5 months ago

I confused it with GETTER_MAP_SLOTS… yes it's 8. Is that too limiting?

rct commented 5 months ago

I have bumped up against it. Though it is good motivation to implement a regular decoder instead.