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

Subclasses of SMBus or I2C cannot have read() or write() methods #22

Closed
rwaldron opened this issue Dec 21, 2017 · 3 comments
Closed

Subclasses of SMBus or I2C cannot have read() or write() methods #22

rwaldron opened this issue Dec 21, 2017 · 3 comments
Labels

Comments

@rwaldron
Copy link
Contributor

Given the following:

import SMBus from "pins/smbus";

class Component extends SMBus {
  constructor(dictionary) {
    super(dictionary);
  }
  read(register) {
    return this.readByte(register);
  }
  write(register, byte) {
    this.writeByte(register, byte);
  }
}

Any attempt to call read() or write() will result in the following:

stack overflow (-1)!
unhandled exception
@phoddie
Copy link
Collaborator

phoddie commented Dec 21, 2017

I think you can solve that in smbus.js by using super.read and super.write in place of this.read and this.write.

@rwaldron
Copy link
Contributor Author

I'd like to work on this this week, but I just hit #28 and cannot build/deploy code anymore :\

@phoddie
Copy link
Collaborator

phoddie commented Jan 18, 2018

Latest revision of smbus.js calls read and write through super so subclasses can safely have their own read and write functions.

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

No branches or pull requests

2 participants