bivab / smbus-cffi

Python bindings for Linux SMBus access through i2c-dev using cffi
GNU General Public License v2.0
61 stars 31 forks source link

crash when using Python 2.7 (arch arm on IMX233) #9

Closed VincentJGeisler closed 10 years ago

VincentJGeisler commented 10 years ago

pip install went ok, but when i try to call the module i get:

[root@alarm ~]# python2 Python 2.7.8 (default, Sep 24 2014, 05:50:37) [GCC 4.8.2 20131219 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from smbus import SMBus /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_BLOCK_DATA': /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:517:30: error: 'I2C_SMBUS_BLOCK_DATA' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_BLOCK_DATA); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:517:30: note: each undeclared identifier is reported only once for each function it appears in o = _cffi_from_c_int_const(I2C_SMBUS_BLOCK_DATA); ^ /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_BLOCK_MAX': /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:531:30: error: 'I2C_SMBUS_BLOCK_MAX' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_BLOCK_MAX); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_BLOCK_PROC_CALL': /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:545:30: error: 'I2C_SMBUS_BLOCK_PROC_CALL' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_BLOCK_PROC_CALL); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_BYTE': /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:559:30: error: 'I2C_SMBUS_BYTE' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_BYTE); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_BYTE_DATA': /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:573:30: error: 'I2C_SMBUS_BYTE_DATA' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_BYTE_DATA); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_I2C_BLOCK_BROKEN': /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:587:30: error: 'I2C_SMBUS_I2C_BLOCK_BROKEN' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_I2C_BLOCK_BROKEN); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_I2C_BLOCK_DATA': /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:601:30: error: 'I2C_SMBUS_I2C_BLOCK_DATA' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_I2C_BLOCK_DATA); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_PROC_CALL': /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:615:30: error: 'I2C_SMBUS_PROC_CALL' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_PROC_CALL); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_QUICK': /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:629:30: error: 'I2C_SMBUS_QUICK' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_QUICK); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_READ': /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:643:30: error: 'I2C_SMBUS_READ' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_READ); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_WORD_DATA': /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:657:30: error: 'I2C_SMBUS_WORD_DATA' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_WORD_DATA); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c: In function '_cffi_const_I2C_SMBUS_WRITE': /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:671:30: error: 'I2C_SMBUS_WRITE' undeclared (first use in this function) o = _cffi_from_c_int_const(I2C_SMBUS_WRITE); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffi__x484c8eddxe317607c.c:54:8: note: in definition of macro '_cffi_from_c_int_const' (((x) > 0) ? \ ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c: In function '_cffi_check_union_i2c_smbus_data': /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:684:12: error: dereferencing pointer to incomplete type (void)((p->byte) << 1); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:685:12: error: dereferencing pointer to incomplete type (void)((p->word) << 1); ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:686:33: error: dereferencing pointer to incomplete type { unsigned char(*tmp)[34] = &p->block; (void)tmp; } ^ /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c: In function '_cffi_layout_union_i2c_smbus_data': /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:691:58: error: field 'y' has incomplete type struct _cffi_aligncheck { char x; union i2c_smbus_data y; }; ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:693:12: error: invalid application of 'sizeof' to incomplete type 'union i2c_smbus_data' sizeof(union i2c_smbus_data), ^ In file included from /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:3:0: /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:695:20: error: invalid use of undefined type 'union i2c_smbus_data' offsetof(union i2c_smbus_data, byte), ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:696:39: error: dereferencing pointer to incomplete type sizeof(((union i2c_smbus_data *)0)->byte), ^ In file included from /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:3:0: /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:697:20: error: invalid use of undefined type 'union i2c_smbus_data' offsetof(union i2c_smbus_data, word), ^ /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:698:39: error: dereferencing pointer to incomplete type sizeof(((union i2c_smbus_data *)0)->word), ^ In file included from /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:3:0: /usr/lib/python2.7/site-packages/smbus/pycache/_cffix484c8eddxe317607c.c:699:20: error: invalid use of undefined type 'union i2c_smbus_data' offsetof(union i2c_smbus_data, block), ^ /usr/lib/python2.7/site-packages/smbus/pycache__/_cffix484c8eddxe317607c.c:700:39: error: dereferencing pointer to incomplete type sizeof(((union i2c_smbus_data *)0)->block), ^ Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/site-packages/smbus/init.py", line 1, in from .smbus import ffi File "/usr/lib/python2.7/site-packages/smbus/smbus.py", line 96, in """, ext_package='smbus', include_dirs=[include_dir]) File "/usr/lib/python2.7/site-packages/cffi/api.py", line 340, in verify lib = self.verifier.load_library() File "/usr/lib/python2.7/site-packages/cffi/verifier.py", line 74, in load_library self._compile_module() File "/usr/lib/python2.7/site-packages/cffi/verifier.py", line 139, in _compile_module outputfilename = ffiplatform.compile(tmpdir, self.get_extension()) File "/usr/lib/python2.7/site-packages/cffi/ffiplatform.py", line 25, in compile outputfilename = _build(tmpdir, ext) File "/usr/lib/python2.7/site-packages/cffi/ffiplatform.py", line 51, in _build raise VerificationError('%s: %s' % (e.class__.name, e)) cffi.ffiplatform.VerificationError: CompileError: command 'gcc' failed with exit status 1

bivab commented 10 years ago

This looks like you are missing the correct i2c/smbus headers. Did you install the i2c-tools package?

VincentJGeisler commented 10 years ago

Thanks for the quick reply

I2c-tools are installed and tested..