2014-12-20 7 views
3

다음은 BeagleBone Black에서 i2c를 통해 OLED 디스플레이를 구동하는 Adafruit SSD1306 Library의 image.py 예제입니다. 그것은 IOError를 제공하고 있지만 그것이 의미하는 바가 혼란 스럽습니다. IOError는 코드 자체 또는 BeagleBone의 i2c 구성 문제에 문제가 있습니까?Beaglebone Black에서이 i2c 예제 코드를 실행할 때 IOError가 발생하는 이유는 무엇입니까?

import time 

import Adafruit_GPIO.SPI as SPI 
import Adafruit_SSD1306 

import Image 

# Beaglebone Black pin configuration: 
RST = 'P9_12' 
# Note the following are only used with SPI: 
DC = 'P9_15' 
SPI_PORT = 1 
SPI_DEVICE = 0 

# 128x32 display with hardware I2C: 
#disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST) 

# 128x64 display with hardware I2C: 
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST) 

# 128x32 display with hardware SPI: 
# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000)) 

# 128x64 display with hardware SPI: 
# disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000)) 

# Initialize library. 
disp.begin() 

# Clear display. 
disp.clear() 
disp.display() 

# Load image based on OLED display height. Note that image is converted to 1 bit color. 
if disp.height == 64: 
     image = Image.open('happycat_oled_64.ppm').convert('1') 
else: 
     image = Image.open('happycat_oled_32.ppm').convert('1') 

# Alternatively load a different format image, resize it, and convert to 1 bit color. 
#image = Image.open('happycat.png').resize((disp.width, disp.height), Image.ANTIALIAS).convert('1') 

# Display image. 
disp.image(image) 
disp.display() 

참조하십시오 아래의 추적 :

/usr/local/lib/python2.7/dist-packages/setuptools-3.5.1-py2.7.egg/pkg_resources.py:1031: UserWarning: /home/ubuntu/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable). 
Traceback (most recent call last): 
    File "image.py", line 47, in <module> 
    disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST) 
    File "build/bdist.linux-armv7l/egg/Adafruit_SSD1306/SSD1306.py", line 239, in __init__ 
    File "build/bdist.linux-armv7l/egg/Adafruit_SSD1306/SSD1306.py", line 105, in __init__ 
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 64, in get_i2c_device 
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 75, in __init__ 
IOError: [Errno 2] No such file or directory 

답변

-1

시도 :

Image = Image.open('happycat_oled_64.ppm','r').convert('1')

또는

Image = Image.open('happycat_oled_64.ppm','w').convert('1')