zoukankan      html  css  js  c++  java
  • ubuntu和raspberry下调试python_spi备忘

    Ubuntu12.04 自安装python3.3中头文件Python.h路径:usr/local/python3.3/include/python3.3m

    Ubuntu12.04 自带的Python2.7中头文件Python.h路径:usr/                      include/python2.7

    Ubuntu12.04 自安装python3.3解释器Python路径:usr/local/python3.3/bin

    Ubuntu12.04 自带的Python2.7解释器Python路径:usr/                      bin

    但默认解释器是python2.7,所以无论在哪个目录下输入python都是python2.7(可能是在安装python3.3时建立了连接关系)

    现在将python2.7备份:sudo cp /usr/bin/python ./pythonback

    删除原python:sudo rm usr/bin/python

    建立新连接 sudo ln -s /usr/local/python3.3/bin/python3.3 /usr/bin/python

    之后输入python默认的就是python3.3解释器了,如果想使用python2.7可以在/usr/bin目录下使用pythonback

    如果不想更改默认连接,则可以在/usr/local/python3.3/bin目录下使用python3.3

    在ubuntu12.04上: 

    spi源文件名:spi.c   测试文件名:spi_test.py

    编译2.7版spi.c:

    gcc -fpic -c -I/usr/local/python3.3/include/python3.3m spi.c =>spi.o(用Python3.3的头文件python.h)

    gcc -shared -o spi.so spi.o =>spi.so(产生共享库spi.so文件)

    python spi_test.py

    编译3.3版spi.c

    gcc -fpic -c -I/usr/include/python2.7 spi.c

    gcc -shared -o spi.so spi.o

    pythonback spi_test.py

    在raspberry上:

    nano使用:

    sudo nano /etc/hosts

    完成后按ctrl+x退出,按y保存,回车,OK

    raspberry找不到spidev0.0和spidev0.1的解决办法:

    修改系统配置

    1. $ sudo nano /etc/modprobe.d/raspi-blacklist.conf

    都注释掉,修改为:

    1. # blacklist spi and i2c by default (many users don't need them)
    2. #blacklist spi-bcm2708
    3. #blacklist i2c-bcm2708

    修改加载模块

    1. $ sudo nano /etc/modules

    改为:

    1. snd-bcm2835
    2. i2c-dev
    3. spidev

    主要是增加 spidev
    重启之后,/dev/中会多出两个设备 spidev0.0 与 spidev0.1, 没有出现的话请google排错。

    具体参见:http://www.shumeipai.net/forum.php?mod=viewthread&action=printable&tid=19410

    编译python2.7代码:

    raspberry的python.h路径:/usr/include/python2.7

    raspberry的python2.7解释器路径:/usr/bin    python2.7

    pi@raspberrypi:~/Documents/python_spi/python_spi_2$ gcc -fpic -c -I/usr/include/python2.7 spi.c
    pi@raspberrypi:~/Documents/python_spi/python_spi_2$ gcc -shared -o spi.so -I/usr/include/python2.7 spi.o
    pi@raspberrypi:~/Documents/python_spi/python_spi_2$ python spi_test.py

    #raspberry的python3.2解释器路径:

    #pi@raspberrypi:/usr/bin$ python3.2mu

     #Python.h文件路径:/usr/lib/pypy-upstream/include/

    python3.3的python.h文件路径:/usr/local/Python-3.3..2/include/python3.3m/

    python3.3解释器python3.3文件路径:/usr/local/Python-3.3..2/bin

    将/usr/local/Python-3.3..2/bin添加到PATH路径后,在该路径下即可使用python3.3解释器

    pi@raspberrypi:/usr/local/Python-3.3..2/bin$ python3.3

    编译:

    pi@raspberrypi:~/Documents/python_spi/python_spi_3$ gcc -fpic -c -I/usr/local/Python-3.3..2/include/python3.3m spi.c

    pi@raspberrypi:~/Documents/python_spi/python_spi_3$ gcc -shared -o spi.so -I/usr/local/Python-3.3..2/include/python3.3m spi.o

    pi@raspberrypi:~/Documents/python_spi/python_spi_3$ /usr/local/Python-3.3..2/bin/python3.3 spi_test.py

  • 相关阅读:
    JS中怎样获取当前日期的前一个月和后一个月的日期字符串
    JS中怎样将时间字符串转换成Date并比较大小
    Java中判断两个Date时间段是否有交集的方法
    gRPC中Java和node进行异构通信-互为客户端和服务端
    ffmpeg external libraries 下载地址
    libsvtav1 的 qp 和比特率对照表
    libsvtav1 AV1 编码速度比 libaom 大大提升
    ffmpeg windows 最新编译内部版本下载地址变更
    解开获取 aria2c 帮助信息的误区
    frei0r 过了好几年增加 aech0r 滤镜
  • 原文地址:https://www.cnblogs.com/cj2014/p/3717623.html
Copyright © 2011-2022 走看看