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

Upgrade to SerialPort 5 #178

Closed
wants to merge 1 commit into from

Conversation

reconbot
Copy link
Member

@reconbot reconbot commented Jul 21, 2017

I'm almost out of beta! It's time to see what changes are necessary to upgrade serialport for firmata.js. I'm really hoping this isn't blocked by browser support

I'm still working on getting all the tests passing but so far this looks pretty strait forward.

  • Why is highWaterMark set to 256 bytes?
  • Use SerialPort MockBindings for tests

- Why is highWaterMark set to 256 bytes?
- Use SerialPort MockBindings for tests
- Isolating state between tests a bit
@reconbot
Copy link
Member Author

This pr is getting pretty big due to switching to serialport/mock for tests. I started down that path because the firmatajs mocks didn't cover all the serialport behavior but I wasn't counting on such a big change.

Is that ok?

@rwaldron
Copy link
Collaborator

Is that ok?

It might be! I'm reviewing now

@rwaldron
Copy link
Collaborator

There are a lot of broken tests :(

Copy link
Collaborator

@rwaldron rwaldron left a comment

Choose a reason for hiding this comment

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

Just questions so far...

if (error) {
return callback(error);
}
var port = ports.find(Board.isAcceptablePort);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duh. Thanks for fixing that.

var board = new Board(transport, initNoop);

board.on("connect", function() {
done();
});

transport.emit("open");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does open() result in an "open" event? (I can't find that in the 5.0.0 source)

Copy link
Member Author

Choose a reason for hiding this comment

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

The mock bindings simulate the open call with a next tick and enforce things like the port exists, valid options, etc. https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/master/lib/serialport.js#L221-L242

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I see—and the answer to my question is "yes, it does"

board.on("error", done);
const error = new Error('I am a teapot');
board.on("error", function(err) {
assert.ok(err === error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whenever possible, I try to get rid of ok(...) in favor of assert.equal(actual, expected)

});
transport.on('open', function() {
transport.binding.emitData([REPORT_VERSION]);
transport.binding.emitData([0x02]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why doesn't this transport.binding just emit("data", ...)?

Copy link
Member Author

Choose a reason for hiding this comment

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

The transport (serialport) can emit the data, but the bindings have a whole read/write async thing going. Hence emitData.

Maybe it's not worth using the serialport mock bindings for this? I'm definitely improving them trying to get them to work here, but maybe it's not necessary.

@dceejay
Copy link

dceejay commented Nov 7, 2017

Any joy on serialport 6 yet ? is it needed for node8.x support ?

@rwaldron
Copy link
Collaborator

rwaldron commented Dec 7, 2017

@reconbot I'm going to close this for now

@rwaldron rwaldron closed this Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants