I'm trying to use
a library that communicates with a SPI device. The system seems to be correctly configured for SPI, and uses the spidev kernel module. This seems to work fine, for example:
Code:
# spi-config -d /dev/spidev32766.1 -q
/dev/spidev32766.1: mode=0, lsb=0, bits=8, speed=40000000
I can also write a super-simple C program that checks if the SPI device can be opened:
Code:
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc, char* argv[])
{
int fd;
fd = open("/dev/spidev32766.1", O_RDWR);
if (fd < 0)
{
int error_value = errno;
printf("Failed to open. Returned fd = %d and errno = %d\n", fd, error_value);
}
else
{
printf("Opened OK!\n");
close(fd);
}
return 0;
}
This works perfectly fine. The device opens and closes without error.
Now, look at the code
here, you will see that the code in this library does exactly that. All I did was change the SPI_DEV_PATH macro to "/dev/spidev32766.1" and compile it. I could then run the
test program that came with the library, and that seemed to run fine also.
However, my
actual application links to the lgw_spi_open() function, and while debugging, I'm finding that the open() returns a -1 (errno is 2). I don't understand how that could be the case. I know the device node exists, I know I can open and close it normally, I know the function gets called correctly from the test program, and yet in the "real" application, open() fails.
Can anyone help me figure out why that might be?
Thanks!