Skip to content
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

System.Device.I2c.I2cDevice.Write transmits more bytes than expected #674

Closed
RolandoMagico opened this issue Dec 27, 2020 · 1 comment · Fixed by nanoframework/nf-interpreter#1819

Comments

@RolandoMagico
Copy link

RolandoMagico commented Dec 27, 2020

Details about Problem

nanoFramework area: C# code

VS version: 2019

VS extension version:

Target: ESP32

Device capabilities output:

Description

System.Device.I2c.I2cDevice.Write transmits all bytes of a byte array even if the length was reduced by a SpanByte.

Detailed repro steps so we can see the same problem

  1. Hardware Setup
    ESP32 board (TTGO T-Beam) with a SH1106 display connected to I2C bus 1.

  2. Code to reproduce

I2cDevice i2cDevice = I2cDevice.Create(new I2cConnectionSettings(1, 0x3C, I2cBusSpeed.StandardMode));
byte[] buffer = new byte[64];
buffer[0] = ControlByteData;
buffer[1] = 0x22;
SpanByte span = new SpanByte(buffer, 0, 2);
this.i2cDevice.Write(span);
  1. Measure the transmitted data with a logic analyzer

Other suggested things

Expected behaviour

Only 2 bytes are transmitted via I2C, not 64 as seen in the logic analyzer screenshot.

Sample Project

https://github.com/RolandoMagico/TTGO-T-Beam-nanoframework/tree/bc9327cad90675bba1b1626e285ceb253556880a

(Enable test code in BaseDisplay constructor to test)

Screenshot

Span in the debugger:
image

I2C communication on the bus (65 bytes because of device address + 64 bytes of data):
image

@AdrianSoundy AdrianSoundy self-assigned this Dec 29, 2020
@RolandoMagico
Copy link
Author

Hello @AdrianSoundy ,
i made a proposal for an fix in the ESP32 target: https://github.com/RolandoMagico/nf-interpreter/commit/ac5e49515b912921cac34b383958b733f99cf5f6
Not quite sure if I can create a pull request for this change.
BR
Roland

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants