Comments (7)
Also, my understanding is that many SPI devices require you to write something in order to read it, which is why an API like transaction
exists. So maybe you're just not telling the device to send any data, so it isn't.
from robotpy-wpilib.
bytes are readonly in python. I believe if you use a bytearray
instead then it will work.
It should give a good error message when you pass in a bytes
... what error message do you get when you do that? We can try to make the error better in the future.
from robotpy-wpilib.
I will try that today. I get no type error when invoking the function (but I do when trying to pass something like []
instead of bytes), it just gives me a segmentation fault with a traceback to the read
function. Is there any way I can specify the size of the read? Will it just be the size of my bytearray
?
from robotpy-wpilib.
Yes, it should be the size of your bytearray.
I'll see if I can take a look tonight.
from robotpy-wpilib.
The function returns the size of my bytearray, so I think you're right. However, when I try to initiate a read the bytearray
is unmodified and the function doesn't error even when no SPI device is connected. Is this intended behavior?
from robotpy-wpilib.
The binding looks right to me. Here's what robotpy-build autogenerates to bind the function:
.def("read", [](frc::SPI * __that,bool initiate, const py::buffer& dataReceived) {
int size = 0;
auto __dataReceived = dataReceived.request(true);
size = __dataReceived.size * __dataReceived.itemsize;
auto __ret =__that->Read(initiate, (uint8_t*)__dataReceived.ptr, size );
return __ret;
},
Looking at SPI::Read it looks like the return value should be ... something undocumented. According to HAL, it looks like the return value should be whatever ioctl
is going to return: ... which is likely going to be the length of data written?
from robotpy-wpilib.
I'm going to close this as I don't believe there's a bug here, just the error message needs improvement.
from robotpy-wpilib.
Related Issues (20)
- Command based robot? HOT 1
- Reported segfault in SmartDashboard.putStringArray HOT 3
- TrajectoryGenerator and SplineParameterizer don't get units type caster
- Design physics/simulation support HOT 2
- Add Swerve Drive support HOT 5
- Auto-generated type annotations? HOT 2
- Broken link in readme.md
- 2021 - import wpilib and sim issues after pip install -U robotpy[all] HOT 2
- SmartDashboard::putData doesn't keep objects alive HOT 10
- CTRL-C in gui on Linux segfaults HOT 1
- wpilib.shuffleboard not implemented HOT 4
- `OSError: Failure` on Linux HOT 2
- Fix Mechanism2D HOT 2
- wpilib.simulation.DCMotorSim missing
- [BUG]: OSError with robotpy-hal library HOT 1
- Unable to find wpilib.shuffleboard in 2021 or 2022 libraries HOT 3
- [BUG]: makeCompressor crashes HOT 1
- [BUG]: Exceptions from startCompetition don't terminate code on roboRIO HOT 2
- [BUG]: bad error message for SpeedControllerGroup construction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robotpy-wpilib.