-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to call wiringPiSPIDataRW? #9
Comments
Same question here, I tried string, array of numbers and nothing works. I guess one would need to change the Python binding to make this working, meaning that no-one tried this functionality before :-/ |
Would like to know, too |
So I take it no one has found a solution to this problem? I'm amazed that this still hasn't been fixed or even addressed by any of the package maintainers... |
JFYI: I decided to use https://pypi.python.org/pypi/spidev/2.0 for SPI in the meantime. |
I switched over to https://github.com/quick2wire/quick2wire-python-api |
Amazingly late to the game here, but I have started maintaining WiringPi again in the form of a new version which you can find here: https://github.com/WiringPi/WiringPi2-Python The function wiringPiSPIDataRW now takes two arguments, pin and the string. Length and conversion to the correct datatype is handled internally. You should be able to call it thus: wiringPiSPIDataRW(1,'badger') I am the sole maintainer of this package, and had more pressing distractions. I'm tremendously late in getting it updated and offer my apologies. I'd love to see you guys come back to WiringPi2-Python and test it out; I'll be around to attempt to fix any problems you might have. |
Hi all, Anyone know what I might be doing wrong here? All I get back is a number representing the number of characters I SENT, not the data I expect back from the Arduino.
Been at this since last Thursday - I kid you not. I bought a second logic level shifter just in case the first was dud. SPI.transfer(0x48); every time wiringpi2 sends it a \n. I've put the logic analyzer on all points, I've taken the speed down as low as it will go. And all I get, every single time, is the number 1 returned. If I put two characters like A\n I get "2", if I send "HELLO", I get "4". I've googled myself silly trying to find an answer. Any ideas greatly appreciated. |
I think your problem is that you're setting myData to the return value of wiringpi2.wiringPiSPIDataRW which is, in fact, not the data being read. What you need to do is this:
If this doesn't work, then some nuance of the wrapped library means that the buffer value ( the second parameter ) is not being correctly overwritten in C, or not bubbling back up to Python. There might be a way around this, but I'd have to hack about with the C library itself. Edit: If it doesn't work, and you'd like to post some counterpart Arduino code, I'd be happy to try and replicate your setup. I run my Arduinos on a breadboard at 3.3v so I don't have to worry about logic levels and should be able to get up and running pretty quickly. |
1: You, sir, are a God-like genius. And I should have asked at some point during the weekend. In other words, spot on. Absolutely kicking myself. On the bright side, I now have a spare logic level converter and a useful probe for future use. 2: I never realised you could run the Arduino at 3.3v. Another useful lesson learnt! Once again, massive thanks for your quick reply. I was starting to go spare here! |
Glad to have helped! I build my Arduinos using an ATMega 328P on a breadboard and run it at 3.3v using an FTDI breakout board or a voltage regulator hooked to the Pi's 5v line ( cutting it close to dropout though ). 3.3v @ 16Mhz works, but it's not recommended for any serious usage as far as I understand. You can drive 'em lower than that, too. I've got to get a probe sooner or later. Not because I need it, but the portable ones look so shiny! What did you get, and is it any good? |
Re: probe. I'm pretty sure the purists won't like this, but I got this SALAEA clone. If you're in the UK http://www.ebay.co.uk/itm/161052042090 would be the one. NOTE: It's £9.97 and NOT normally £109.97! Apparently because it's low stock or something to do with not wanting to unlist from ebay but also not wanting to sell the last 3 so the listing stays, and they've got more coming soon - I got it for £10 including postage and a bundle of probes. *Yes, I do realise the "clones don't support development" argument before anyone kicks me, but this is a one-off non-commercial project, no-one is paying me. I'd love to be able to afford £110 for a "real" one, but I can't. |
How are you supposed to pass the data variable into wiringPiSPIDataRW by reference? I've tried a variety of ctypes with no luck.
Trying something like:
All I get is:
TypeError: in method 'wiringPiSPIDataRW', argument 2 of type 'char *'
The text was updated successfully, but these errors were encountered: