-
Notifications
You must be signed in to change notification settings - Fork 7
fram size incorrect with len #6
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
same for an I2C fram
|
probably this should be _max_size + 1 |
The description https://github.com/adafruit/Adafruit_CircuitPython_FRAM/blob/master/adafruit_fram.py#L109 is a little confusing -- for the SPI FRAM there are 8192 locations 0 - 8191 so the maximum "register" location is 8191, but the size of the bytearray is 8192. or am I missing something. |
I have the I2C FRAM and will take a look into this. |
Confirmed. My FRAM exhibited the same symptoms. Also, just to be sure it was zero-based:
|
Because of the way that python normally handles arrays:
I think it makes sense to add 1 to the length and to change the description so that it is less confusing. |
I totally agree. |
I think changing the constants makes more sense, not changing the name. People rarely use constants like 8191. |
Agreed -- the len(fram) should be the total size -- 8192 or 32768 in these examples. I just wanted someone else to look over ti to make sure "fixing" it would not break something else that depended on the "max_address" value. |
Changing the constant would require changing all of the checks to make sure it wasn't writing out of range and adding + 1 to the length only required one code change. Either way is fine, just something to keep in mind. |
After thinking about it, I think logically changing all the checks does make a bit more sense. I just need to doublecheck that this doesn't result in an off by one error. |
Yes, keep the name as |
Agreed. |
While testing my code, I found another bug in the code from before I worked on it. With Address Slicing, the addresses are off by one (they don't include the last address and are unable to use the last address by slicing. This is using the original code before my edits:
I can fix this in my changes, but could also open another issue since it's related to the issue, but also is another issue entirely. |
Size issue fixed as well as the slicing issue I found. |
I was experimenting with an SPI FRAM breakout and found that len(fram) only reports the size as 8191 - but I can write to the 8192nd location -- Is this a bug?
The text was updated successfully, but these errors were encountered: