getting IOerror [errno 9] bad file descriptor

-1

[enter image description here][1]this is the code for my project to transmit a picture saved in directory by LED.

#!/usr/bin/python
from PIL import Image
import time
import spidev
import RPi.GPIO as GPIO
#set up SPI for LED
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 31200000

buffer = bytearray() #put the bits in an array to rebuild
picture = bytearray() #this is where I store the final bits
file = open("logo.jpg", "rb")
bytes = bytearray(file.read())
for byte in bytes:
 for i in range(8):
 bit = (byte>>i) & 1
 buffer.append(bit)
 #send bits to the LED using SPI
 if bit == 1:
 resp = spi.xfer([0xFFFFFFF])
 else:
 resp = spi.xfer([0x00000000])
 spi.close()

i m getting

resp=spi.xfer([0x00000000])
IOError [errno 9] bad file descriptor

Can someone please help me and tell where i m going wrong..i m new to coding. thank you for you time

python-3.x
asked on Stack Overflow Oct 23, 2018 by dawgxxxx • edited Oct 23, 2018 by dawgxxxx

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0