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

'On' event support for Serial / USB adapters #13

Open
ChronSyn opened this issue Sep 4, 2020 · 0 comments
Open

'On' event support for Serial / USB adapters #13

ChronSyn opened this issue Sep 4, 2020 · 0 comments

Comments

@ChronSyn
Copy link

ChronSyn commented Sep 4, 2020

Firstly, thank you for the fantastic library! Having TS built as standard into the library without relying on an external [at]Types definition is wonderful.

Onto the main issue. With node-serialport and node-usb, both support 'on' events, such as 'on data', 'on error', etc. These are usually handled as callbacks - e.g. serialport.on("data", (data: any) => callback(data)) - which triggers each time the serialport device sends data.

At present, this library doesn't provide such functionality. I have tried to implement such functionality myself, but I believe I may be implementing it incorrectly into the library.

One such use case for this is retrieving printer status (usually returned as a stream of bytes of n length). By sending certain thermal printers certain bytes (e.g. 0x10, 0x14, 0x07, 0x01), the device will respond with a stream of bytes (e.g. 0x14, 0x00, 0x00, 0x0f) which can be interpreted as multiple possible statuses such as 'ready', or 'cutter error', or 'paper being fed', etc, or a combination of statuses. The bytes to be sent and the bytes returned vary from printer to printer, so the ability to write bytes, and receive a callback when data is sent from the device would be highly beneficial.

Is it possible for such functionality to be added into this library?

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

1 participant