Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rct opened this issue Jun 2, 2024 · 8 comments
Labels
bug There is a defect in the code

Comments

@rct
Copy link
Contributor

rct commented Jun 2, 2024

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:

  • # my comment on a line by itself -- Bad flex spec, unknown keyword (#mycomment)! (white space was removed in the error message)
  • get=name:@24:{1}, # skip the next bit -- Bad flex spec, unknown keyword (#skipthenexbitget)! (note the get added at the end)
@zuckschwerdt
Copy link
Collaborator

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 gdt added the bug There is a defect in the code label Jun 2, 2024
@gdt gdt changed the title Filter comments in flex decoder configuration block syntax issue or enhancement Comments are not properly ignored when reading flex decoder configuration blocks Jun 2, 2024
@gdt
Copy link
Collaborator

gdt commented Jun 2, 2024

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

@zuckschwerdt
Copy link
Collaborator

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
Copy link
Contributor Author

rct commented Jun 4, 2024

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
Copy link
Collaborator

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
Copy link
Contributor Author

rct commented Jun 4, 2024

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
Copy link
Collaborator

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

@rct
Copy link
Contributor Author

rct commented Jun 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug There is a defect in the code
Projects
None yet
Development

No branches or pull requests

3 participants