groupgets / pylepton

Quick and dirty pure python library for interfacing with FLIR lepton
MIT License
208 stars 93 forks source link

Error: Inappropriate ioctl for device #58

Closed AravindSadashiv1998 closed 2 years ago

AravindSadashiv1998 commented 3 years ago

Hi, I'm using the FLIR lepton 3.5 with the breakoutboard v2.0 and when I'm running the command "sudo pylepton_capture output.png", I'm getting the error " Error: Inappropriate ioctl for device ". Can anyone please help me with this as it's urgent.

Also what is the pinlayout specified?

Best, Aravind

OwenTC commented 3 years ago

I am having the same problem right now using it through USB. Did you ever figure out a solution to the error?

Thanks, Owen

mishave commented 3 years ago

@AravindSadashiv1998 just curious to what your output is when you run: cat /sys/module/spidev/parameters/bufsiz

Typical this should typically return 4096 bytes by default.. however when messing around trying to increase this number to the suggested 65535, the buffer returning an error or a very low number i.e. 4 when check with the above cmd. this in turn creates the 'Inappropriate ioctl for device ' to fix it I went ahead and reduced that size down using: sudo nano /boot/cmdline.txt and add in the end: spidev.bufsiz= 131072 Reboot after and check again.

Tylersuard commented 2 years ago

@mishave I just tried that, still the same error.

jcarolinares commented 2 years ago

Hello,

I'm experimenting the same error, in my case I've tried with a Raspberry Pi 4 model B the error message is the same but cat /sys/module/spidev/parameters/bufsiz does not exist

Any idea about what is happening or what are we doing wrong?

Also I'm sorry about the question but I'm not sure what is the correct wiring for the camera, I've found different diagrams across the internet. In my case is a Lepton Thermal Camera Breakout v1.4 if anyone has any clue that would be awesome

Thanks!

Tylersuard commented 2 years ago

Hey, I could not get it to work, I am returning the breakout board and exchanging it for the purethermal2.

On Wed, Oct 6, 2021 at 6:27 AM, Julián Caro Linares @.***> wrote:

Hello,

I'm experimenting the same error, in my case I've tried with a Raspberry Pi 4 model B the error message is the same but cat /sys/module/spidev/parameters/bufsiz does not exist

Any idea about what is happening or what are we doing wrong?

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

mishave commented 2 years ago

@mishave I just tried that, still the same error.

Apologies, just saw this, will set one up over the next week and see what comes up, I do remember it being a pain to set up. from memory, I did it using the lepton3-dev branch i.e.git clone -b lepton3-dev https://github.com/groupgets/pylepton.git keep in mind there are a few things you need to fix within that.

mishave commented 2 years ago

@Tylersuard @jcarolinares Alrighty so, i started with a fresh build so had to reinstall everything first sudo apt-get update sudo apt-get upgrade sudo apt-get install python3-pip sudo pip3 install --upgrade setuptools

OpenCV install - I was having some issues with the install following the current instructions which was throwing a cv2 import error si tried the following method pip3 install opencv-python > would not work getting such on install, so I tried installing the previous build as per below: pip3 install opencv-python==4.5.3.56 also installed NumPy: pip3 install -U numpy

once that was installed I made a copy of the lepton3-dev branch: git clone -b lepton3-dev https://github.com/groupgets/pylepton.git made some tweaks as per: https://github.com/groupgets/pylepton/issues/60#issuecomment-863785313

ran install sudo python3 setup.py install then tried to run pylepton_capture output.png which threw a cv2 import error..

Tried installing the contrib package and some of its dependencies manually using: pip3 install opencv-contrib-python; sudo apt-get install -y libatlas-base-dev libhdf5-dev libhdf5-serial-dev libatlas-base-dev libjasper-dev libqtgui4 libqt4-test

for good measure re-run the install because yolo: sudo python3 setup.py install

after that I was getting the ioctl error: pi@raspberrypi:~/pylepton $ pylepton_capture output.png Traceback (most recent call last): File "/usr/local/bin/pylepton_capture", line 37, in image = capture(flip_v = options.flip_v, device = options.device) File "/usr/local/bin/pyleptoncapture", line 10, in capture a, = l.capture() File "/usr/local/lib/python3.7/dist-packages/pylepton/Lepton3.py", line 55, in capture Lepton.capture_segment(self._handle, self._xmit_buf[:self._msg_size Lepton.ROWS], self._msg_size, self._capture_buf[0]) File "/usr/local/lib/python3.7/dist-packages/pylepton/Lepton.py", line 125, in capture_segment ret = ioctl(handle, iow, xs_buf[xs_size (60 - messages):], True) OSError: [Errno 90] Message too long

So I checked the buf size and it returned: pi@raspberrypi:~/pylepton $ cat /sys/module/spidev/parameters/bufsiz 4096

Extended the buf size: pi@raspberrypi:~/pylepton $ sudo nano /boot/cmdline.txt and add the following to the end: spidev.bufsiz=65535

pi@raspberrypi:~/pylepton $ sudo reboot

Run the in built script pylepton_capture output.png

happy days.

kekiefer commented 2 years ago

66 merged which reduces the spidev buffer size again, because apparently it works with the smaller message sizes. Let me know if there are issues with this approach.