spidev / Python错误

时间:2015-12-13 20:39:51

标签: python spi

std::set_terminate([](){
  puts("exception thrown"); 
  //^skip the demangling of the typeid that's normaly done
  try { throw; } 
    catch(const std::exception& e){ puts(e.what()); }
    catch(...){}
  //^rethrow and catch
});

结果:

  

TypeError:参数中的非Int / Long值:b592da58。

1 个答案:

答案 0 :(得分:1)

这是因为你传递了一个字符串列表并且它需要整数 - 你想要:

import spidev
spi = spidev.SpiDev()
spi.open(0, 1)
l = [0x20,0x01,0x00,0x10,0x3D,0x04,0x00,0x05,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00] 
resp = spi.xfer2(l)