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

device.write(data) able to send response with number of bytes written to device? #234

Open
filipinacoder opened this issue Nov 22, 2017 · 1 comment

Comments

@filipinacoder
Copy link

filipinacoder commented Nov 22, 2017

Hello! I would like to ask if it is possible for device.write(data) to be able to give us a response with the number of bytes written to a device?

Would really appreciate it if you can somehow shed some light, or point where to extract this.

Thanks and have a good day.

@natevw
Copy link
Contributor

natevw commented Nov 22, 2017

There is precedent for this in fs.write where:

The callback will be given three arguments (err, bytesWritten, buffer) where bytesWritten specifies how many bytes were written from buffer.

Likewise, the underlying call is to hid_write:

This function returns the actual number of bytes written and -1 on error.

I haven't reviewed when/why the actual number of bytes will be different, but +1 that we should pass the value back to JS.

The C++ write wrapper would need to return that value on success, and then the JS bridge NAN_METHOD(HID::write) needs to take that to use as its NanReturnValue.

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

No branches or pull requests

2 participants