Comments (9)
I didn't look into this much, but you might need to set the buffer size to 1. Not completely sure. Also, make sure the BusId is correct. I believe it should be 1.
var device = new System.Device.I2c.Drivers.UnixI2cDevice(new I2cConnectionSettings(BusId, address));
device.Write(new byte[] { 0x00 });
byte[] readBuffer = new byte[1];
device.Read(buffer);
from iot.
Because I2C protocol only uses 1 data pin, there is not a method like the TransferFullDuplex that we have in SPI. Internally what we are doing is to just do ioctl on the I2c device and send the information, so I would expect that as long as you set the right size of the read and write buffers that it should work correctly. Did you try what @shaggygi suggested?
from iot.
I tested this (only on Unix) and can repro this when sending Write or Read commands with an empty array or Span similar in @bigdnf example.
@joperezr I don't understand why the ioctl wouldn't take/ignore 0 buffer length, but I guess it is expecting something when doing a write/read function. To fix this, we could put a check in ReadWriteInterfaceTransfer
and FileInterfaceTransfer
to just return if writeBufferLength
and readBufferLength
are both 0.
I don't like this as it is a little more overhead for checking on every Write/Read call and if someone used an empty array/Span... no error would be shown, the buffer would still be empty and you'd probably see another GitHub issue created stating the I2C method wasn't working.
In addition, when cleaning/updating the I2C and SPI summaries in PRs #143/#144, I added comments for buffer size when reading. This would probably help a little.
Close issue as is?
from iot.
Thanks for info - I'm currently on business trip so I can't test anything. I will do it after return and close issue if I can fix it after your suggestions.
from iot.
@bigdnf have you had the chance if @shaggygi suggestions work in your scenario?
I tested this (only on Unix) and can repro this when sending Write or Read commands with an empty array or Span similar in @bigdnf example.
I don't see that in the example @bigdnf is using an empty array or Span, so that might be a different issue.
To fix this, we could put a check in
ReadWriteInterfaceTransfer
andFileInterfaceTransfer
to just return ifwriteBufferLength
andreadBufferLength
are both 0.
I believe that this is an actual bug if we aren't checking the size, and if so, I would probably even throw an exception maybe if the read buffer or writebuffer is 0 as this shouldn't be allowed.
from iot.
@joperezr sorry for my delay with testing this - I will try to give feedback as soon as possible.
from iot.
no worries at all, just wanted to check if that was something you still had in your plans š
from iot.
I think the correct fix should be to throw a descriptive exception when someone passes 0-length buffer to Read or am I missing something?
from iot.
@krwq The original issue was because there were no bytes allocated to perform read. Your suggestion with having a better exception description would help in this case. Other than that, I would label issue as stale and close.
from iot.
Related Issues (20)
- Update Raspberry Pi samples suggesting modifying config.txt settings HOT 5
- Unable to set pin mode on pi5 HOT 4
- Breaking change: Y2038 support for .NET Arm32 HOT 1
- arix.local HOT 1
- Misleading XML summary for ButtonBase.IsPressed HOT 1
- TM16xx is very unstable - shows strange characters most of the time HOT 7
- GPIO input gives segmentation fault on BeagleBone Black in v3.1.0 HOT 20
- Implement Raspberry5Driver and board HOT 1
- Add support for SPI devices that use separate GPIO outputs for Data/Command and Reset HOT 4
- If using gpio on an arm Linux system. How do I make things displayed on the interface? HOT 2
- Unable to get consistent manual exposures HOT 7
- PinNumberingScheme.Board is broken HOT 2
- SPI communication on RPI5 is possibly broken
- ButtonBase.IsPressed not properly initialized HOT 1
- Investigate protocol: matter HOT 3
- Cargo causes GpioController to hang on Raspberry Pi 5 Bookworm HOT 31
- CONTRIBUTING documentation is way out of date HOT 3
- GrovePi device binding fails to read sensor values HOT 4
- SPI_Mcp3008CanRead is frequently failing on CI HOT 1
- Planned breaking changes for v4.0
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 iot.