SenseHat environment / motion problem

Good question - it turns out I had a VERY old version of that node!
image

Having upgraded it to 0.1.1 - I am now getting the same as you :slight_smile:

When I enable Motion - I get motion events, when I enable environment - I get environment events - when I enable both - I just get motion events

Now we just have to try and work out what change has caused this issue

I may have found a hack to cure the problem

One of the recent changes was to default to using python3 for the background data gathering instead of python2

I changed
home/pi/.node-red/node_modules/node-red-node-pi-sense-hat/sensehat
to just use python2 again and it seems to have made it work again

image

1 Like

Happy to look at a PR if you like.

I'm really struggling to work out how to debug the node as I don't know how to launch it outside of NR and see what's going on :frowning:

@cymplecy Simon, I just did a compare of all the files in v0.1.0 and 0.1.1 and the only change is in the sensehat module that uses python3 if it is avaliable.

The issue is in the python code, in python2, when motion and environment are selected it sends back both, but in python3 it only sends back motion. I'm trying to debug it now.

It has to involve a change in how python3 code works compared to python2

1 Like

Experience has shown that this isn't necessarily true but it probably is :slight_smile:

Can someone exlplain that this python statement does:
ready = select.select(files, [], [], 0.01)[0]

This is in the sensehat.py code and I have a hunch it is the cause of the issue with python3 since there is a change with timeout.

Changed in version 3.5: The function is now retried with a recomputed timeout when interrupted by a signal, except if the signal handler raises an exception (see PEP 475 for the rationale), instead of raising InterruptedError .
from select — Waiting for I/O completion — Python 3.12.1 documentation

  • here it is in context:
  # while still waiting for input on at least one file
  try:
    while files:
      ready = select.select(files, [], [], 0.01)[0]
      if not ready:
        idle_work()
      else:
        print(">>>> else")
        for file in ready:
          if file == sys.stdin:
            line = file.readline()
            if not line: # EOF, remove file from input list
              sys.exit(0)
            elif line.rstrip(): # optional: skipping empty lines
              process_command(line)
          else:
            process_joystick()
  except:
    sys.exit(0)