WebUSB detect if web page is being opened
I am looking for some mechanism that would switch USB device to failsoft mode when connection to the site is broken (i.e. browser crashed, user closed tab with the site that communicates to the device or simply network connection is down).
One of the option I can see is some kind of mechanism of sending keep-alives from browser to the device - unfortunately the only (simple) way of transferring data from browser I found is via CDC (which is using bulk transfer - that the slowest way of sending data). Is there any way to utilize interrupt transfer via WebUSB? Or maybe there is a better way than sending keep-alives to achieve desired behavior?
Currently I am focused on Windows 10.
usb webusb
add a comment |
I am looking for some mechanism that would switch USB device to failsoft mode when connection to the site is broken (i.e. browser crashed, user closed tab with the site that communicates to the device or simply network connection is down).
One of the option I can see is some kind of mechanism of sending keep-alives from browser to the device - unfortunately the only (simple) way of transferring data from browser I found is via CDC (which is using bulk transfer - that the slowest way of sending data). Is there any way to utilize interrupt transfer via WebUSB? Or maybe there is a better way than sending keep-alives to achieve desired behavior?
Currently I am focused on Windows 10.
usb webusb
add a comment |
I am looking for some mechanism that would switch USB device to failsoft mode when connection to the site is broken (i.e. browser crashed, user closed tab with the site that communicates to the device or simply network connection is down).
One of the option I can see is some kind of mechanism of sending keep-alives from browser to the device - unfortunately the only (simple) way of transferring data from browser I found is via CDC (which is using bulk transfer - that the slowest way of sending data). Is there any way to utilize interrupt transfer via WebUSB? Or maybe there is a better way than sending keep-alives to achieve desired behavior?
Currently I am focused on Windows 10.
usb webusb
I am looking for some mechanism that would switch USB device to failsoft mode when connection to the site is broken (i.e. browser crashed, user closed tab with the site that communicates to the device or simply network connection is down).
One of the option I can see is some kind of mechanism of sending keep-alives from browser to the device - unfortunately the only (simple) way of transferring data from browser I found is via CDC (which is using bulk transfer - that the slowest way of sending data). Is there any way to utilize interrupt transfer via WebUSB? Or maybe there is a better way than sending keep-alives to achieve desired behavior?
Currently I am focused on Windows 10.
usb webusb
usb webusb
edited Nov 26 '18 at 22:11
Grzegorz Suder
asked Nov 26 '18 at 22:04
Grzegorz SuderGrzegorz Suder
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
What you want to do is set up your interface with two alternate settings. Alternate setting 0 can be the failsafe mode and is selected by default. When your app opens the device it can call selectAlternateInterface() to select alternate setting 1 which would be your active mode. The OS will automatically send a SET_ALTERNATE(0) command to your interface when you call close(), the page is closed, or the browser crashes.
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489816%2fwebusb-detect-if-web-page-is-being-opened%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
What you want to do is set up your interface with two alternate settings. Alternate setting 0 can be the failsafe mode and is selected by default. When your app opens the device it can call selectAlternateInterface() to select alternate setting 1 which would be your active mode. The OS will automatically send a SET_ALTERNATE(0) command to your interface when you call close(), the page is closed, or the browser crashes.
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
add a comment |
What you want to do is set up your interface with two alternate settings. Alternate setting 0 can be the failsafe mode and is selected by default. When your app opens the device it can call selectAlternateInterface() to select alternate setting 1 which would be your active mode. The OS will automatically send a SET_ALTERNATE(0) command to your interface when you call close(), the page is closed, or the browser crashes.
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
add a comment |
What you want to do is set up your interface with two alternate settings. Alternate setting 0 can be the failsafe mode and is selected by default. When your app opens the device it can call selectAlternateInterface() to select alternate setting 1 which would be your active mode. The OS will automatically send a SET_ALTERNATE(0) command to your interface when you call close(), the page is closed, or the browser crashes.
What you want to do is set up your interface with two alternate settings. Alternate setting 0 can be the failsafe mode and is selected by default. When your app opens the device it can call selectAlternateInterface() to select alternate setting 1 which would be your active mode. The OS will automatically send a SET_ALTERNATE(0) command to your interface when you call close(), the page is closed, or the browser crashes.
answered Nov 30 '18 at 22:42
Reilly GrantReilly Grant
2,2031710
2,2031710
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
add a comment |
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
That seem to be quite nice way to handle that kind of the scenario. I am wondering if there is anything that can be done for scenario when web browser freezes and we want to go failsafe mode...
– Grzegorz Suder
Dec 10 '18 at 19:00
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
For that you'll need to implement some kind of heartbeat sent from your app to the device.
– Reilly Grant
Dec 10 '18 at 21:30
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
So it seems the only way to fullfill my requirements would be to implement keep alive mechanism.
– Grzegorz Suder
Dec 17 '18 at 21:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489816%2fwebusb-detect-if-web-page-is-being-opened%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown