Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I use "wiringPi" to talk over SPI to some device attached to "RaspberryPi".

With test application (simple user mode app) call to function wiringPiSPISetup() works well, while executed from daemon - fails. Return value is 0 (which indicates error, according to sources/samples of "wiringPi").

Test application that works correctly was written in C, when the daemon - is in C++. I know it has nothing to do with the problem. Just listed all that is different.

The question is what could prevent the wiringPiSPISetup() from working properly while called from daemon ?

I suspect that shared library of "wiringPi" fails to load due to possible library path problem. But I am not sure how to test this, given rather modest error handling capabilities of "wiringPi".

share|improve this question
    
Ok, here is the update. In order to eliminate as much details as possible I added the command line argument to my daemon process which would eliminate the daemon initialization and run the application as a plain user application. After that wiringPiSPISetup() started working correctly. So the problem has something to do with daemon itself. –  opal Jan 4 '13 at 18:28
    
I posted same problem of "wiringPi" author's blog link. Nothing specific so far. :(. –  opal Jan 4 '13 at 18:34
    
Hello, I guess I have a little progress here. If I copy shared libraries to directory where I start the daemon from it actually works. So it is clearly not a "wiringPi" problem. It has to do to daemon library path inheritance. I tried setting LD_LIBRARY_PATH and even PATH prior to daemon start. Tried starting daemon during boot time (not from shell). So far - no luck. –  opal Jan 8 '13 at 14:03

1 Answer 1

I have found a solution to my problem. In fact it was my own fault. I did not check the error code value correctly. wiringPiSPISetup() returns value that is < 0 on error and 0 - on success. I have been considering the <= 0 condition as an error.

Sorry for bothering you guys.

Regards

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.