Welcome, Guest

Author Topic: pyA10Lime 0.2 : SPI OSError  (Read 4299 times)

oryx_r

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
pyA10Lime 0.2 : SPI OSError
« on: September 16, 2014, 12:03:18 PM »
Hi,
I test spi program of olimex a10lime but it doesn't work.
Code: [Select]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from pyA10Lime import spi

spi.open("/dev/spidev2.0")
spi.read(2)
spi.close()

It put this message :
Code: [Select]
Traceback (most recent call last):
  File "./spi.py", line 7, in <module>
    spi.read(2)
OSError: [Errno 22] Invalid argument
zsh: exit 1     ./spi.py

The spi work well (I test it with /opt/spidev of olimex)

Thanks for your help

gst_retd

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: pyA10Lime 0.2 : SPI OSError
« Reply #1 on: January 30, 2015, 12:54:08 PM »
I have the exact same problem on A20 LIME2 with pyA20Lime2 0.2

read(2), xfer([0x01, 0x02],2) and write([0x01, 0x02]) gave me the same errno 22 return code. So this maybe a problem that is not related to the python code or library but maybe more to the SPI module (I wonder).

Is there someone that have SPI running on thoses cards? And if yes how have you done this?

Best regards.

JohnS

  • Hero Member
  • *****
  • Posts: 1719
  • Karma: +33/-48
Re: pyA10Lime 0.2 : SPI OSError
« Reply #2 on: January 30, 2015, 01:29:58 PM »
Trace through the read call to see why 2 is invalid.

John

gst_retd

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: pyA10Lime 0.2 : SPI OSError
« Reply #3 on: January 30, 2015, 03:15:46 PM »
I made a quick search. The errno 22 is a kernel/module error number that corresponds to "Invalid argument". So I really think that the 2 (or whatever value is used) is not misunderstood by python but more likely something is going wrong when python calls the system the read or write to the device (maybe there is a problem with the module behind the device virtual file system? do you have some clue?

Maybe we can find a small C example that can reproduce this issue it maybe easier, don't you think? 

JohnS

  • Hero Member
  • *****
  • Posts: 1719
  • Karma: +33/-48
Re: pyA10Lime 0.2 : SPI OSError
« Reply #4 on: January 30, 2015, 05:41:01 PM »
I still think you should trace it but good luck.

John

gst_retd

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: pyA10Lime 0.2 : SPI OSError
« Reply #5 on: January 30, 2015, 07:09:51 PM »
Maybe I should trace for sure but I'm not a "Python guy" nor a "driver guy" and I really don't know how to trace such things maybe you may give me some clue?

Best regards.

JohnS

  • Hero Member
  • *****
  • Posts: 1719
  • Karma: +33/-48
Re: pyA10Lime 0.2 : SPI OSError
« Reply #6 on: January 30, 2015, 08:02:10 PM »
I've no board nor SPI to connect up nor any desire to use python for it if i had.  Not a clue without any of those.

Using a dev board and wanting something like this is your big chance to figure stuff out I'd have thought.

John

HenningA

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: pyA10Lime 0.2 : SPI OSError
« Reply #7 on: October 24, 2015, 11:46:27 PM »
The open is wrong, it should be

Code: [Select]
spi.open(2,0)
for opening spidev2.0

Henning