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

Add I2cTransferResult and I2cTransferStatus #11

Merged

Conversation

josesimoes
Copy link
Member

@josesimoes josesimoes commented Oct 27, 2020

Description

  • Add I2cTransferResult and I2cTransferStatus.
  • Changed this into a "core libray".

Motivation and Context

  • These are required to provide a "developer friendly" feedback regarding the I2C bus transaction.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@nfbot
Copy link
Member

nfbot commented Oct 27, 2020

Hi @josesimoes,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@josesimoes josesimoes force-pushed the add-return-to-read-write-calls branch from 11d9e28 to 1b197f8 Compare October 27, 2020 12:06
Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just _buffer which should be a SpanByte

private bool _disposed;

// speeds up the execution of ReadByte and WriteByte operations
private readonly byte[] _buffer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now should be SpanByte

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do...
CS8345 Field or auto-implemented property cannot be of type 'SpanByte' unless it is an instance member of a ref struct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, then it makes less sense to do this. We can tweak SpanByte to be a ref struct (it's technically one on the Span world.

return bufferSingleOperation[0];
lock (_syncLock)
{
var buffer = new SpanByte(_buffer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed as _buffer should be a SpanByte directly

{
var buffer = new SpanByte(_buffer);

NativeTransmit(null, buffer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here it's directly _buffer

// copy value
_buffer[0] = value;

return NativeTransmit(new SpanByte(_buffer), null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed, _buffer should now be a SpanByte

_connectionSettings = settings;

// create the buffer
_buffer = new byte[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok, it's just than _buffer should be a SpanByte, this new allocation won't change

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understand why can't be SpanByte for _buffer, then all good like this

@josesimoes josesimoes merged commit 96aab04 into nanoframework:develop Oct 27, 2020
@josesimoes josesimoes deleted the add-return-to-read-write-calls branch October 27, 2020 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants