Object not subscriptable (anaologRead)

Hi,
I have the GrovePi Board running with temp/hum Sensor, Lightsensor, Led, Button and LCD. Everything works fine- till I get the following error message:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/home/pi/Desktop/GrovePi2Socket/GrovePiConnector.py", line 78, in run
    light = grovepi.analogRead(sensor_light)
  File "/home/pi/Dexter/GrovePi/Software/Python/grovepi.py", line 227, in analogRead
    return number[1] * 256 + number[2]
TypeError: 'int' object is not subscriptable

This happens after an hour or two of running this script. Restart of the Script does not help. Reboot of the Raspberry also does not help.
What helps is starting the firmware_upgrade.sh then it again works for an hour or two.
But this is not really a solution.
Has somebody an idea?
Thanks and Kind Regards,
Marco

Hello @marco.ertel

From what you’re saying it seems the firmware is crashing. Can you run a troubleshooting test for me?
If you’re on Raspbian for Robots, there’s a Test and Troubleshoot icon on the desktop.
If you’re not on Raspbian for Robots , then open a terminal window and enter the following:
sudo bash ~/Dexter/GrovePi/Troubleshooting/all_tests.sh

Either of those will generate a log file on the desktop. Please share the results.

Thank you,
Cleo

Hi,
thanks for looking in the issue. I am not on Raspbian for Robots but on a normal Raspbian and installed the stuff in addition. So I started the script you mentioned.
Here you can find the log file: log.txt (6.3 KB)

Thanks and Kind Regards,
Marco

Thank you @marco.ertel

It seems there may be a couple of issues. Could you send me the contents of
/etc/modprobe.d/raspi-blacklist.conf to be certain?

Thanks,
Cleo

Hi Cleo,
the raspi-blacklist.conf you mentioned is empty.

Kind Regards,
Marco

Instead of just rebooting the Raspberry Pi, does it make any difference if you shut down the RPi, remove power, and then boot it back up (full power cycle for the RPi and GrovePi)?

1 Like

Hi Matt,
after power off and on again the sensors are working again.
Thanks and Kind Regards,
Marco

Unfortunately that thread has been closed and marked as solved- but the power cycle does only help for an hour or so and then the problem occurs again.
Who can reopen this thread?

1 Like

Hi,
I opened the thread (Object not subscriptable (anaologRead)) a few days ago and before I was able to add the latest things it was closed (and marked as solved). As I can’t reopen it let me try it here as a new thread.

Yes I had written that the power off-on cycle has helped. But even after power-off-on the complete stuff only works again one hour or so.

Who can help or has an idea?

Thanks and Kind Regards,
Marco

@marco.ertel, @matt, I’ve moved @marco.ertel’s new thread into this one as he requested and now, this thread is open again.

I was searching for similar cases and the only report of this issue was with this guy here:

He only seems to partially match your situation @marco.ertel and he didn’t came with further replies to the supposed issue.

Really curios, but can you tell me what is the kernel version that you have? Command uname -a will tell you. And I think it’s safe to assume that once you get that exception, there’s no going back, so to speak - that tells me there’s a dead-end somewhere in the firmware.

And I have an idea based on the fact that you may be running multiple sensors simultaneously along with some analog sensor: please run each sensor/device on your GrovePi separately until one of them triggers that exception. What I’m thinking is that maybe some sensor is causing analogRead to fail.

Let’s see where this takes us.

Thank you!

Hi Robert,
thanks for reopen the thread.
uname -a answers:

Linux planthouse300 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux

(oh- it seems that the time of the machine is not correct. For my scripts this is not a problem- can this be a problem for the GrovePi stuff?)

The other test is right now running (only checking one sensor). As it everytime takes one or two hours to run into the exception I am still waiting for this exception.
I also checked if it is a hardware related issue (different Raspberry, different GrovePi Board, same sensors connected but the problematic image with scripts). And yes there it also crashes.

Thanks and Kind Regards,
Marco
(If it helps I can also send you a link to the image of the Raspberry and the used scripts)

Hi @marco.ertel,

The difference in time should not pose a problem.

The other test is right now running (only checking one sensor). As it everytime takes one or two hours to run into the exception I am still waiting for this exception.

Well, then, I’m going to wait and see where you’re getting to. Just make sure to run a sensor at a time.

I also checked if it is a hardware related issue (different Raspberry, different GrovePi Board, same sensors connected but the problematic image with scripts). And yes there it also crashes.

This might indicate an issue with the firmware.

If it helps I can also send you a link to the image of the Raspberry and the used scripts

It would be cool if you could show us some scripts though and tell us the order in which they occur.
Until then, I’m waiting to see where your tests take you.

Thank you!

Hi all,

I am facing the same problem. I am reading from multiple sensors and get the error ,“int object is not subscriptable”. After following the threads I am still not able to understand the solution. Please let me know what is the solution to get rid of this issue. Though the issue resolvess when i completely power off raspberrry pi and reconnect the sensors. But this is not the correct way.Please help me out.

I am performing stream analysis of data from the sensors so shutting down raspberry pi after few hours is not an option for me.

Hi,
I am able to narrow down the problem after following this post:

Its related to the function: ```
read_i2c_block(address)

Since its not able to read value from the address after the number of retries, its involking io error and returning -1 and then finally number expects a list but gets an integer -1 and the code breaks.

def analogRead(pin):
    write_i2c_block(address, aRead_cmd + [pin, unused, unused])
    read_i2c_byte(address)
    number = read_i2c_block(address) // important
    return number[1] * 256 + number[2]

Hi @prashu20,

Can you give this beta version a try and let us know if works for you?

The version you are using, the 1.2.7 is know for having problems.

Thank you!