-
Notifications
You must be signed in to change notification settings - Fork 48
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
Feedback on a POSIX style wrapper for Web Serial API #125
Comments
Supporting a BYOB reader for on the The |
@reillyeon: Cool. Thanks. I'll investigate the BYOB reader. This post is more along the lines of whether it would be beneficial to have an alternative interface that doesn't involve streams for folks who did not want to get into these kind of details. It seems like such an interface can be provided as a third-party library, so if that's the idea, I understand. |
I just filed #127 because right now the |
I think the first order of business is to make sure that the current API supports all the necessary primitives to implement that kind of library. If it doesn't then there is a behavior that is missing that we'd have to specify before it could be supported natively or through a polyfill. I think we're in good shape on that front, though like I said BYOB readers and abortable reads would simplify things for the library. |
@reillyeon: Sounds fair. BTW, thank you so much for your help! I now have both firmware flashing and 3D printing working great! It's working just as well as it did under Electron! |
When you have the site published please let us know so we can reference it as an example. |
@reillyeon: It’s currently here: https://syndaverco.github.io/firmware/ Source Code: |
Closing this issue as the feature requests discussed are tracked elsewhere. |
This is sort of a follow up on a question that started in thread #123.
I am working on porting some 3D printing and serial flashing code that was originally written in Python, eventually was ported to Electron and now I am rewriting using the Web Serial API.
I've run into a few issues stemming from the fact that the Web Serial API presents a Stream interface rather than a more traditional POSIX interface.
The code I am porting has several functions that look like this:
The very nature of this code lends itself to a Serial interface with the following methods:
Right now, it turns out it is possible to write such an interface using the Web Serial API, but it's not a trivial exercise. Here is the code I am using right now (I am not 100% sure it is correct, but it seems to work pretty well):
I hardly think the kind of code I am trying to port is uncommon; the code looks very much as what you would see in any serial related C++, Python, or Arduino code.
While it is possible to write a wrapper class around the existing Web Serial API, just as I have done, I see potential drawbacks to this:
I feel that this style of serial port is common enough and useful enough that the standard should provide for it. At the very least, this would prevent the creation of hundreds of separate implementations which pretty much do the same thing.
Perhaps the standard it could provide a polyfill, as I have done, but having a common implementation would allow implementers to optimize it by implementing it directly via calls to the host OS, which most likely already has a POSIX-style serial port under the hood anyway.
@reillyeon, @domenic: Thought and comments?
The text was updated successfully, but these errors were encountered: