New pigpio Python module


189 posts   Page 8 of 8   1 ... 4, 5, 6, 7, 8
by joan » Sat Apr 08, 2017 8:00 am
r3bpy wrote:...
PS: I would like to buy you a beer and was looking at your website for a "donate" link and found nothing. Is there such a thing?
...

No need, I have a surgically implanted syringe to drip feed needed supplies. :D

There is another debugging tool which is sometimes useful.

If you enter the command pigs csi 5 that switches on internal diagnostics up to level 5. If you then cat /dev/pigerr& at a Pi terminal you will see a trace of commands sent to the pigpio daemon.
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by r3bpy » Tue Apr 11, 2017 8:12 am
joan wrote:No need, I have a surgically implanted syringe to drip feed needed supplies. :D


I hope you are ok as much as one can be in such situation.

joan wrote:There is another debugging tool which is sometimes useful.


Thank you for the valuable advice.

best,
r3bpy
Posts: 3
Joined: Thu Apr 06, 2017 9:52 am
by Massi » Tue May 02, 2017 12:16 pm
Hello Joan,
i have a single class (che one reading from an ADS1115 ADC) that now and then returns this kind of error:

Code: Select all
 File "/usr/local/bin/classes/peripheals/ads1115.py", line 84, in __init__
    self.i2c = self.pi.i2c_open(1, self.address, 0)
  File "/usr/lib/python3/dist-packages/pigpio.py", line 2580, in i2c_open
    self.sl, _PI_CMD_I2CO, i2c_bus, i2c_address, 4, extents))
  File "/usr/lib/python3/dist-packages/pigpio.py", line 1000, in _pigpio_command_ext
    sl.s.sendall(ext)
AttributeError: 'NoneType' object has no attribute 'sendall'


as far as i can understand, this is not an error related to i2c, but it is related to the connection between python and pigpiod, am i wrong?
how can i debug deeper this?

thanks :)
Posts: 1557
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by joan » Tue May 02, 2017 12:35 pm
Massi wrote:Hello Joan,
i have a single class (che one reading from an ADS1115 ADC) that now and then returns this kind of error:

Code: Select all
 File "/usr/local/bin/classes/peripheals/ads1115.py", line 84, in __init__
    self.i2c = self.pi.i2c_open(1, self.address, 0)
  File "/usr/lib/python3/dist-packages/pigpio.py", line 2580, in i2c_open
    self.sl, _PI_CMD_I2CO, i2c_bus, i2c_address, 4, extents))
  File "/usr/lib/python3/dist-packages/pigpio.py", line 1000, in _pigpio_command_ext
    sl.s.sendall(ext)
AttributeError: 'NoneType' object has no attribute 'sendall'


as far as i can understand, this is not an error related to i2c, but it is related to the connection between python and pigpiod, am i wrong?
how can i debug deeper this?

thanks :)

I think I only see that error when the pigpio connection has never been established (program start) or is being closed down (program exit).

Are either of those scenarios likely? I wouldn't expect the error in the middle of a session.
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Massi » Tue May 02, 2017 8:28 pm
joan wrote:I think I only see that error when the pigpio connection has never been established (program start) or is being closed down (program exit).
Are either of those scenarios likely? I wouldn't expect the error in the middle of a session.


well it seems to me there is nothing strange in my code:

Code: Select all
   def __init__(self, address=0x48, debug=False):
      self.pi = pigpio.pi()
      self.address = address
      self.i2c = self.pi.i2c_open(1, self.address, 0)
      loggerInfo.info("ADS1115 initialized at i2c address {0:x}".format(address))


More or less, all my sensor classes are written in this way. And i get that error only for this class.
I'll add the check on pi connection in the middle, but i can't really understand why..
that error means that self.pi has been created and dies before the i2c_open call, am i right?
Posts: 1557
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by joan » Tue May 02, 2017 8:40 pm
Massi wrote:...
More or less, all my sensor classes are written in this way. And i get that error only for this class.
I'll add the check on pi connection in the middle, but i can't really understand why..
that error means that self.pi has been created and dies before the i2c_open call, am i right?

Have you a small complete error example you can share? I'll see if I can debug it.
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Massi » Thu May 04, 2017 7:56 pm
sorry for the late reply, but i've been trying to reproduce it.
well, today i got an error also from another sensor class so i tried to "stress" a little the pigpio connection.

I understand this is a very "unrealistic" case, but with this code i get the same error:

Code: Select all
import pigpio
import threading
import time

def doThings():
   pi = pigpio.pi()
   handle = pi.i2c_open(1,0x20)
   time.sleep(0.1)
   pi.i2c_close(handle)
   pi.stop()
   
for i in range(1000):
   t = threading.Thread(target=doThings)
   t.start()
   time.sleep(0.01)


Error coming from this code is the same as before, but since i'm testing this from the console i also see the error message of the pigpiod

Code: Select all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)

Do you have permission to access the pigpio daemon?
Perhaps it was started with sudo pigpiod -nlocalhost
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Exception in thread Thread-1209:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "pigtest.py", line 7, in doThings
    handle = pi.i2c_open(1,0x20)
  File "/usr/lib/python2.7/dist-packages/pigpio.py", line 2580, in i2c_open
    self.sl, _PI_CMD_I2CO, i2c_bus, i2c_address, 4, extents))
  File "/usr/lib/python2.7/dist-packages/pigpio.py", line 1000, in _pigpio_command_ext
    sl.s.sendall(ext)
AttributeError: 'NoneType' object has no attribute 'sendall'


Sometimes this returns 1 error
sometimes no errors
sometimes 3 errors
it's random :)

the system has just been dist-upgraded

Indeed, the first time i saw this error was trying to run sensors readings threading the classes..
Posts: 1557
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by joan » Thu May 04, 2017 8:49 pm
Okay, thanks for that. I can repeat the error.

If I find out what's going wrong I'll let you know!
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by joan » Sat May 06, 2017 10:27 pm
Okay, I think I know what is going wrong. A socket operation I thought was atomic doesn't appear to be atomic after all.

I will correct the fault, but I'm not sure when I'll push out the fix.
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Massi » Sun May 07, 2017 6:34 am
take your time, i can live with that error :)
Posts: 1557
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by joan » Sat May 13, 2017 2:05 pm
Massi wrote:take your time, i can live with that error :)

I have just released V63 which I hope corrects the fault you are seeing. Sockets are atomic after all. That was a red herring.
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Massi » Sun May 14, 2017 6:20 am
joan wrote:
Massi wrote:take your time, i can live with that error :)

I have just released V63 which I hope corrects the fault you are seeing. Sockets are atomic after all. That was a red herring.


wow great!
how long do you think it is gonna take to have this in the standard raspbian repositories?

Code: Select all
pi@baguette:~ $ pigs pigpv
60


we are 3 steps late :)

and thanks also for the english course :)
Posts: 1557
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by joan » Sun May 14, 2017 7:23 am
Massi wrote:...
how long do you think it is gonna take to have this in the standard raspbian repositories?
...

I have no idea.

As an aside I don't think it will ever get in the standard Raspbian repository as I think they only accept Debian packages.

The raspberrypi.org image will be fetching it from the separate repository maintained by raspberrypi.org.
User avatar
Posts: 12688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Massi » Thu May 18, 2017 11:47 am
well as of today we are still at v60 in the repositories.. i fear i'll have to install it manually..
Posts: 1557
Joined: Fri May 02, 2014 1:52 pm
Location: Italy