-
Notifications
You must be signed in to change notification settings - Fork 7
'_SPI_OPCODE_RDID' is not defined (Jetson Nano) #12
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
thats odd because its defined right above |
@ladyada Just tried one on a feather_nrf5280_express -- no problem. |
I haven't used it recently. Perhaps this is something related specifically to the Jetson Nano. |
@ADV-LUT how are you installing? what version python are you running |
@ladyada I have python version 3.6.8 I am grateful for any help. |
It might be a slight syntax error? Need to add a Simple example to demonstrate issue: class Foo:
_SOME_VAR = 23
def foo(self):
return bytearray([_SOME_VAR]) and then: $ python3
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> f = foo.Foo()
>>> dir(f)
['_SOME_VAR', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'foo']
>>> f.foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "foo.py", line 5, in foo
return bytearray([_SOME_VAR])
NameError: name '_SOME_VAR' is not defined
>>> same for CP: Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import foo
>>> f = foo.Foo()
>>> dir(f)
['__class__', '__dict__', '__module__', '__qualname__', 'foo', '_SOME_VAR']
>>> f.foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "foo.py", line 5, in foo
NameError: name '_SOME_VAR' is not defined
>>> |
That makes sense. |
@ADV-LUT please try the example code as is |
I have the same result/issue as @caternuson with the sample code on the Jetson Nano. And how can I fix that? |
@ADV-LUT Do you know how to make pull requests? This looks like a pretty simple issue that would make for a good first one. |
@caternuson I have not made a pull request yet, but I would like to do it. I've just read how it works, but have not quite understood. And if I understand that correctly, the pull request is there for me, that my changes are taken over in the repository. But I do not know, where I have to do changes. |
Check out this guide: |
I am running similar issue on Raspberry Pi. name '_SPI_OPCODE_RDID' is not defined Thanks! pi@raspberrypi:~ $ python3
|
Reopening. I think this works on CircuitPython and not elsewhere because of use of
|
By the way, it worked on M0 Express and Windows 10.
…On Thu, Sep 24, 2020 at 4:16 PM Carter Nelson ***@***.***> wrote:
Reopening.
I think this works on CircuitPython and not elsewhere because of use of
const(). Can re-create same issue on a RPI:
***@***.***:~ $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> import busio
>>> import digitalio
>>> import adafruit_fram
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.D6)
>>> fram = adafruit_fram.FRAM_SPI(spi, cs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/blinka/lib/python3.7/site-packages/adafruit_fram.py", line 330, in __init__
spi.write(bytearray([_SPI_OPCODE_RDID]))
NameError: name '_SPI_OPCODE_RDID' is not defined
>>>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNG52XGDHTYMEYSRK4DXV3SHPHM5ANCNFSM4JRKIDYQ>
.
|
@caternuson I don't think this has to do with const. const should just return the same value. I think this is a slight difference in name lookup between CPython and CircuitPython. I think #12 (comment) is exactly right. I'm not sure why it was closed and not fixed. |
I'm not finding a way to allow use of class level This shoulnd't work, but does: class Foo:
_SOME_VAR = const(23)
def __init__(self):
print(_SOME_VAR) Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
23
>>> While this: class Foo:
_SOME_VAR = const(23)
def __init__(self):
print(Foo._SOME_VAR) leads to this: Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "foo.py", line 6, in __init__
AttributeError: type object 'Foo' has no attribute '_SOME_VAR'
>>> Removing use of class Foo:
_SOME_VAR = 23
def __init__(self):
print(Foo._SOME_VAR) Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
23
>>> |
@caternuson Thanks for the experiments. Removing the const is the best option. In general, it is overused and should only be used at the top level. |
This should be fixed by #22. Please try the 1.3.4 version of the library: |
Closing for now. Can reopen if needed. |
I'm trying to run the SPI fram breakout board with the Jetson nano and always get the following error message when I'm running the example.
Traceback (most recent call last):
File "fram_spi_simpletest.py", line 11, in <module>
fram = adafruit_fram.FRAM_SPI(spi, cs)
File "/home/adves/.local/lib/python3.6/site-packages/adafruit_fram.py", line 301, in __init__
spi.write(bytearray([_SPI_OPCODE_RDID]))
NameError: name '_SPI_OPCODE_RDID' is not defined
Exiting...
Cleaning up pins
The text was updated successfully, but these errors were encountered: