graycatlabs / PyBBIO

A Python library for Arduino-style hardware IO support on the Beaglebone
https://github.com/graycatlabs/PyBBIO/wiki
MIT License
251 stars 87 forks source link

TypeError: must be string, not int #58

Closed ghost closed 9 years ago

ghost commented 9 years ago

In a freshly installed Debian (2015-03-01) on Beaglebone Black Rev A6A, the encoder_test.py example shows this error:

Traceback (most recent call last):
  File "encoder_test.py", line 24, in <module>
    run(setup, loop)
  File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/bbio.py", line 60, in run
    loop()
  File "encoder_test.py", line 22, in loop
    delay(1000)
  File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/common.py", line 36, in delay
    time.sleep(ms/1000.0)
TypeError: must be string, not int
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/bbio.py", line 21, in bbio_cleanup
    for cleanup in ADDITIONAL_CLEANUP:
TypeError: must be string, not int
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/bbio.py", line 21, in bbio_cleanup
    for cleanup in ADDITIONAL_CLEANUP:
TypeError: must be string, not int
sahmad98 commented 9 years ago

Code is wrong at time.sleep(ms/1000), is ms previously defined. Check for that because sleep function takes int.

On Saturday, March 14, 2015, Ali Yousuf notifications@github.com wrote:

In a freshly installed Debian (2015-03-01) on Beaglebone Black Rev A6A, the encoder_test.py example shows this error:

Traceback (most recent call last): File "encoder_test.py", line 24, in run(setup, loop) File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/bbio.py", line 60, in run loop() File "encoder_test.py", line 22, in loop delay(1000) File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/common.py", line 36, in delay time.sleep(ms/1000.0) TypeError: must be string, not int Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs func(_targs, _kargs) File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/bbio.py", line 21, in bbio_cleanup for cleanup in ADDITIONAL_CLEANUP: TypeError: must be string, not int Error in sys.exitfunc: Traceback (most recent call last): File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs func(_targs, _kargs) File "/usr/local/lib/python2.7/dist-packages/PyBBIO-0.9.3-py2.7-linux-armv7l.egg/bbio/bbio.py", line 21, in bbio_cleanup for cleanup in ADDITIONAL_CLEANUP: TypeError: must be string, not int

Reply to this email directly or view it on GitHub https://github.com/graycatlabs/PyBBIO/issues/58.

Saleem Ahmad

ghost commented 9 years ago

I have not changed anything in the example. It is in integer already. The error says "must be String" -- I'm also confused at this. Here is the code

#!/usr/bin/env python
"""
 encoder_test.py
 Rekha Seethamraju

 An example to demonstrate the use of the eQEP library
 for PyBBIO.

 This example program is in the public domain.
"""
from bbio import *
from bbio.libraries.RotaryEncoder import RotaryEncoder

encoder = RotaryEncoder(RotaryEncoder.EQEP2b)

def setup():
  encoder.setAbsolute()
  encoder.zero()

def loop():
  print "encoder position : \t"+encoder.getPosition()
  delay(1000)

run(setup, loop)
alexanderhiam commented 9 years ago

Hmm... this is an odd one. Seems that either the RotaryEncoder library itself or the sysfs C extension it uses to read/write the eQEP driver files is the source of the problem (time.sleep most certainly doesn't take a string!). I'm looking into it...

KirkAtWork commented 9 years ago

Just letting you know I'm having the exact same problem with the same code I'm on Beaglebone Black Rev C. Version is: Linux beaglebone 3.8.13-bone70 #1 SMP Fri Jan 23 02:15:42 UTC 2015 armv7l GNU/Linux

Any new ideas on this yet? I'm stuck

alexanderhiam commented 9 years ago

OK got it, I was missing a type check in a C extension, and the TypeError was popping up at a weird time.