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

capture cli mesages #7

Closed
dgeppert opened this issue Apr 12, 2021 · 5 comments
Closed

capture cli mesages #7

dgeppert opened this issue Apr 12, 2021 · 5 comments

Comments

@dgeppert
Copy link

Hello,

not an issue, but a question (hope that's ok here):

is there a way to capture the cli result into e.g. an array to process the result later within the cli?

RFQuack(/dev/ttyUSB0)> a = q.radioA.get_register(0x71)                                                                                               

address = 113
value = 4
0x71 = 0b00000100 (0x04, 4)

result = 0
message = 

RFQuack(/dev/ttyUSB0)> a                                                                                                                         

RFQuack(/dev/ttyUSB0)> print(a)                                                                                                                  
None

redirecting stdout does not seem to help here, maybe because Protobuf is used?

thx in advance

@phretor
Copy link
Contributor

phretor commented Apr 12, 2021

@dgeppert results are automatically collected into the q.data variable, which is of type list().

@phretor phretor closed this as completed Apr 12, 2021
@dgeppert
Copy link
Author

RFQuack(/dev/ttyUSB0)> q.radioA.get_register(0x71)                                                                                               


address = 113
value = 4
0x71 = 0b00000100 (0x04, 4)


result = 0
message = 

RFQuack(/dev/ttyUSB0)> q.data                                                                                                                    
Out[2]: []

RFQuack(/dev/ttyUSB0)> print(q.data)                                                                                                             
[]

@phretor
Copy link
Contributor

phretor commented Apr 12, 2021

Oh, my bad. You want to collect the register values. I don't think we've ever thought about storing those.

Check here https://github.com/rfquack/RFQuack-cli/blob/master/rfquack/core.py#L237

You'll see that we're storing only packets (e.g., transmissions) into self.data. Maybe you can create a self.register = list() and collect Register objects at https://github.com/rfquack/RFQuack-cli/blob/master/rfquack/core.py#L231

If you can do that and send a PR, I'll merge it ;-)

@phretor phretor reopened this Apr 12, 2021
@aguglie
Copy link
Contributor

aguglie commented Apr 12, 2021

Hello @dgeppert ,
q.data stores packets received from the transceiver while in RX mode.

@dgeppert
Copy link
Author

thanks @phretor! for pointing to the right spots ;-)

just two lines of code in rfquack/core.py

class RFQuack(object):
        ...
        self.data = list()
        self.register = list() # <---

        ...

        if isinstance(msg, rfquack_pb2.Register):
            fmt = '0x{addr:02X} = 0b{value:08b} (0x{value:02X}, {value})\n'
            out += fmt.format(
                **dict(addr=msg.address, value=msg.value))
            self.register.append(msg)) # <---
RFQuack(/dev/ttyUSB0)> q.radioA.get_register(0x71)                                                                                               

address = 113
value = 4
0x71 = 0b00000100 (0x04, 4)

result = 0
message = 

RFQuack(/dev/ttyUSB0)> q.register                                                                                                                
Out[2]: 
[address: 113
 value: 4]

@phretor phretor closed this as completed Apr 12, 2021
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

3 participants