atlas0fd00m / rfcat

RfCat - swiss-army knife of ISM band radio
Other
554 stars 116 forks source link

Typing hints in bits.py causing SyntaxError #134

Closed Bckempa closed 1 year ago

Bckempa commented 1 year ago

After installing the client on Ubuntu 22.04 using Python 2.7 via pip install -e . as instructed in the README running rfcat -r returns the following SyntaxError exception:

Traceback (most recent call last):
  File "/home/bckempa/.local/bin/rfcat", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/bckempa/projects/rfcat/rfcat", line 11, in <module>
    from rflib import *
  File "/home/bckempa/projects/rfcat/rflib/__init__.py", line 8, in <module>
    from .chipcon_nic import *
  File "/home/bckempa/projects/rfcat/rflib/chipcon_nic.py", line 20, in <module>
    from .chipcon_usb import *
  File "/home/bckempa/projects/rfcat/rflib/chipcon_usb.py", line 22, in <module>
    from . import bits
  File "/home/bckempa/projects/rfcat/rflib/bits.py", line 38
    def strBitReverse(string:bytes):
                            ^
SyntaxError: invalid syntax

It appears that in commit 2fc783 a typing hint was added to the function signature for strBitReverse line 316 of rflib/bits.py.

Removing that hint produces a similar exception for another typing hint on line 316 of the same file:

Traceback (most recent call last):
  File "/home/bckempa/.local/bin/rfcat", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/bckempa/projects/rfcat/rfcat", line 11, in <module>
    from rflib import *
  File "/home/bckempa/projects/rfcat/rflib/__init__.py", line 8, in <module>
    from .chipcon_nic import *
  File "/home/bckempa/projects/rfcat/rflib/chipcon_nic.py", line 20, in <module>
    from .chipcon_usb import *
  File "/home/bckempa/projects/rfcat/rflib/chipcon_usb.py", line 22, in <module>
    from . import bits
  File "/home/bckempa/projects/rfcat/rflib/bits.py", line 316
    def detectRepeatPatterns(data:bytes, size=64, minEntropy=.07):
                                 ^
SyntaxError: invalid syntax

After removing those two hints rfcat -r launches as expected.

Should the typing hints be removed from bits.py or should the README be updated to instruct the use of Python3?

atlas0fd00m commented 1 year ago

rfcat should be run on Python3+. while i was attempting to keep backwards compatability for a while, apparently some Py3-only things have found their way in. can you use Python3?

Bckempa commented 1 year ago

Ah, ok. I'm hitting different issues now but that makes sense.

If I get a chance to submit a PR with the python 2 references updated in the README I will but the mystery device I was scanning for turns out to be on 2.4GHz instead of sub-gig like I suspected so I can't justify project time for that.

Appreciate your work on this and thanks for getting back.

ma77carpenter commented 1 year ago

RfCat does support TI's CC2511 dongle as well, which supports 2.4GHz, although it's limited to 500kbps, so YMMV.

good luck!