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

Autogenerated Python Code from GRC does not work for File Meta Source when trying to change filename #7302

Open
nuena opened this issue May 2, 2024 · 0 comments

Comments

@nuena
Copy link

nuena commented May 2, 2024

What happened?

When using File Meta Source with a parameter, runtime-adjusting the file name does not work with the automatically generated Python code, at least if detatched header = False. I'm pretty sure it also won't work with detached_header = True, but I didn't test it.

The automatically generated Python code is invalid and will cause an exception/error when used.

    def set_file(self, file):
        self.file = file
        self.blocks_file_meta_source_0.open(self.file, True)

For the file source block, the auto-generated code works as expected.

System Information

OS: Ubuntu 20.04 LTS (x86-64)
GR Installation Method: radioconda

GNU Radio Version

3.10 (maint-3.10)

Specific Version

3.10.9.2

Steps to Reproduce the Problem

  1. Create a GRC flowgraph with a File Meta Source (connected to a Null sink) and a Parameter block with the parameter name "file". Use this parameter as file name. Other parameter names are acceptable of course, but will change the name of the set-method created
  2. instantiate Top Block from Python and call set_file(<...>) after instantiation.
>>> from crash import crash
>>> tb = crash(filename = "test.bin")
>>> tb.set_filename("/dev/zero")         # <--- the file name you speficy here does not matter, the error will always occur. 

Relevant log output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/<username>/tests/crash_python/crash.py", line 59, in set_file
    self.blocks_file_meta_source_0.open(self.file, True)
TypeError: open(): incompatible function arguments. The following argument types are supported:
    1. (self: gnuradio.blocks.blocks_python.file_meta_source, filename: str, hdr_filename: str = '') -> bool

Invoked with: <gnuradio.blocks.blocks_python.file_meta_source object at 0x7f73f30be970>, '/dev/zero', True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant