# WebUSB Sept 2021

**URL:** <https://crucible.hubbe.net/t/webusb-sept-2021/709>\
**Category:** ProffieOS\
**Created:** [September 2, 2021, 4:32am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709 "2021-09-02T04:32:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 4:32am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/1 "2021-09-02T04:32:49Z")

</div>

Moving this conversation to it’s own thread.

> [@Countdown to ProffieOS6](https://crucible.hubbe.net/t/countdown-to-proffieos6/698/18):
>
> We should now be able to use WebUSB to set all the edit mode arguments.

Cool. I went to check it out, but the page is 1/2 working on Chrome for me.  
I get control, can do on, off, clash and those ok.  
Tracks load after a long while, but I haven’t seen presets show up yet. Stuck on "waiting to list presets.  
Also, Edit is stuck at “Getting options”

On a side note, I see `EVENT: Stab millis=394294 volts. ` under the volume bar.  
Is this going to be showing messages as serial monitor would report?  
That would be awesome, and more cool if there was a mini-console up in the corner.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 2, 2021, 4:35am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/2 "2021-09-02T04:35:29Z")

</div>

Sounds like there are some communication issues.  
Are you using WebUSB or BLE?

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 2, 2021, 4:36am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/3 "2021-09-02T04:36:37Z")

</div>

Is the saber ignited?  
Is the SD card mounted on the computer?

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 4:36am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/4 "2021-09-02T04:36:47Z")

</div>

Also, in the javascript console there’s this FYI:

```auto
Uncaught (in promise) TypeError: Cannot read property 'replace' of undefined
    at UpdatePresets (app.html:977)
    at Run2 (app.html:1055)

```

Refreshing the page, I get

```auto
Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.

```

Then is says failed to load presets.inim but then proceeds to show the contents.  
But presets don’t appear in the page like tracks do eventually.

````auto
Run2 @ app.html:1057
async function (async)
Run2 @ app.html:1036
Run @ app.html:1024
async function (async)
Run @ app.html:1014
onclick @ app.html:1245

app.html:363 > Failed to open: presets.ini
Failed to open: presets.tmp
FONT=a_DARKSABER/DarkV3;common
TRACK=
STYLE1=builtin 0 1
STYLE2=builtin 0 2
STYLE3=builtin 0 3
STYLE4=builtin 0 4
STYLE5=builtin 0 5
NAME= dark\n v3
VARIATION=0
Failed to open: presets.ini
Failed to open: presets.tmp

FONT=a_DARKSABER/Darkstar;common
TRACK=
STYLE1=builtin 1 1
STYLE2=builtin 1 2
STYLE3=builtin 1 3
STYLE4=builtin 1 4
STYLE5=builtin 1 5
NAME= darkstar
VARIATION=0
Failed to open: presets.ini
Failed to open: presets.tmp

FONT=aa_Greyscale/Analog_Greyscale;common
TRACK=
STYLE1=builtin 2 1
STYLE2=builtin 2 2
STYLE3=builtin 2 3
STYLE4=builtin 2 4
STYLE5=builtin 2 5
NAME=analog
VARIATION=0
Failed to open: presets.ini
Failed to open: presets.tmp

FONT=aa_Greyscale/Assassin_Greyscale;common
TRACK=
STYLE1=builtin 3 1
STYLE2=builtin 3 2
STYLE3=builtin 3 3
STYLE4=builtin 3 4
STYLE5=builtin 3 5
NAME=assassin
VARIATION=0```
````

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 4:37am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/5 "2021-09-02T04:37:50Z")

</div>

> [@profezzorn](#):
>
> Sounds like there are some communication issues.  
> Are you using WebUSB or BLE?

BLE from my computer to the saber.

> [@profezzorn](#):
>
> Is the saber ignited?  
> Is the SD card mounted on the computer?

Not ignited, although it can be as controls on the page work.  
Sd card is in the saber on the bench.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 4:41am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/6 "2021-09-02T04:41:15Z")

</div>

Just refreshed and it’s good now. Am I beating you to a reply saying try it now?  
🙂

Actually, I did a colorchange manually on the saber, writing something to presets.ini. Wonder if that helped.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 2, 2021, 4:45am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/7 "2021-09-02T04:45:51Z")

</div>

I think BLE is ending up dropping some of the data.  
Although, it could be a problem on the web app I suppose.  
I might have to build a more robust protocol.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 4:48am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/8 "2021-09-02T04:48:37Z")

</div>

This is under edit menu. What should be where Undefined is?  
 ![Screen Shot 2021-09-02 at 12.47.51 AM](https://crucible.hubbe.net/uploads/default/original/1X/569ce6e89c0fb2dc76e21fe30109204c4ba10b97.jpeg)

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 2, 2021, 4:49am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/9 "2021-09-02T04:49:34Z")

</div>

You’ll need to reflash your board.  
I’m not sure if you have the last version of the app either.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 5:29am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/10 "2021-09-02T05:29:16Z")

</div>

Updated to Git latest.  
Force refreshed browser page.  
With bluetooth I can confirm prests.ini can’t be read until I do a manual write to it on the saber then it’s ok.

USB connection is fine.  
Some notes about edit page:  
Still seeing UNDEFINED as some option.  
Extension “time” shows as a color choice.  
Blast color shows as a value.  
Things don’t fit in their boxes even resizing the page with zoom. The layout just auto snaps to fit.  
Vid to accompany notes:

[![](https://crucible.hubbe.net/uploads/default/original/1X/13ec20dd0606c3add764eeaf406556da45bba226.jpeg "webusb1") ](https://www.youtube.com/watch?v=xjvakreKCHs)

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 5:42am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/11 "2021-09-02T05:42:55Z")

</div>

Also, how do we save the edited changes? They revert back toggling edit.  
(this is zoom at normal 100% BTW)

[![](https://crucible.hubbe.net/uploads/default/original/1X/044f70e36e39964aa1b8467cf8acf34113dc80c5.jpeg "wu1") ](https://www.youtube.com/watch?v=aWPRCweVi9o)

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 2, 2021, 7:07am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/12 "2021-09-02T07:07:21Z")

</div>

Hmm, I must admit that I didn’t check that things got saved properly.  
I’ll have to look into that.  
Do you have arguments in your code that aren’t checked into github yet?  
(If so, you may need to add some words in the style description string in style\_parser.h as well.)

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 10:00am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/13 "2021-09-02T10:00:08Z")

</div>

> [@profezzorn](#):
>
> Do you have arguments in your code that aren’t checked into github yet?  
> (If so, you may need to add some words in the style description string in style\_parser.h as well.)

No custom arguments, just choosing from the drop down menu of named styles.

When changing style, console reports

```auto
app.html:583 Uncaught TypeError: Cannot read property 'value' of null
    at SaveStyle (app.html:583)
    at OnStyleSelect (app.html:573)
    at HTMLSelectElement.onchange (app.html:1)

```

As far as UNDEFINED descriptor goes, using built in Fire style for example, it’s weird because it looks like it loaded it ok

```auto
Sending describe_named_style fire app.html:366
 > Fire blade, warm color, hot color
Style size = 48
COLOR 65535,0,0
COLOR 65535,65535,0 app.html:1210
(4) ["Fire blade, warm color, hot color", "Style size = 48", "COLOR 65535,0,0", "COLOR 65535,65535,0"]
0: "Fire blade, warm color, hot color"
1: "Style size = 48"
2: "COLOR 65535,0,0"
3: "COLOR 65535,65535,0"length: 
4[[Prototype]]: Array(0)

Fire blade, warm color, hot color app.html:1211 

```

so it seems it didn’t parse “warm color” for some reason.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 10:11am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/14 "2021-09-02T10:11:30Z")

</div>

These just look like they need some reordering:

 ![Screen Shot 2021-09-02 at 6.07.35 AM](https://crucible.hubbe.net/uploads/default/original/2X/6/6e9fb323eb7d59538570115d5a6d180019426ccd.jpeg)

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 10:19am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/15 "2021-09-02T10:19:57Z")

</div>

The UNDEFINED looks like maybe it’s an offset issue, as it’s got a place holder for the base color in the definition, but no base color in the editor?  
Standard lists as “Standard blade, color, clash color, extension time, retraction time”  
But starts with CLASH COLOR in the editor.

 ![Screen Shot 2021-09-02 at 6.14.56 AM](https://crucible.hubbe.net/uploads/default/original/2X/0/089397ca9b6e331f664cbbc7414a9601f82e807a.jpeg)

Looking closer, the Advanced example above is missing COLOR AT HILT, and turns out all the graphicals are missing at least the first argument. (I think I just invented a word.)

Strobe is missing “standby color.”  
Unstable is missing “warm.”  
Cycle is missing the first “start color” and the last “lockup color”, so it’s offset by 2 and has 2 UNDEFINEDs at the bottom.  
and Rainbow is missing “extension time.”

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 2, 2021, 11:22am UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/16 "2021-09-02T11:22:24Z")

</div>

Are builtins going to everything graphically editable like the others as per the addition of all the options to style\_parser.h @line 100?

```auto
    // TODO: Support multiple argument templates.
    "builtin preset styles, "
    "preset number, blade number, "
    "base color, alt color, style option, "
    "ignition option, ignition time, ignition delay, ignition color, ignition power up argument, "
    "blast color, clash color, lockup color, lockup position, drag color, drag size, lb color "
    "stab color, melt size, swing color, swing option, emitter color, emitter size, "
    "preon color, preon option, preon size, "
    "retraction option, retraction time, retraction delay, retraction color, retraction cool down, "
    "postoff color, off color, off option"

```

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 2, 2021, 5:53pm UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/17 "2021-09-02T17:53:47Z")

</div>

Yes, builtins are going to editable too.  
For now we assume that the use Fett263s argument ordering, but the intention is that in the future we can support multiple different argument order templates.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 5, 2021, 6:32pm UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/18 "2021-09-05T18:32:58Z")

</div>

Would you like an issue reported on Github so it’s on a reminder list of sorts?  
Although, while there are several here that are similar but different, I don’t think you want 3 or 4 or 5 issues.  
Or, is this thread enough for now?  
Summary:  
Not saving changes made under Edit.  
Advanced style arguments need re-order.  
Graphic layouts of styles are missing at least the first argument, causing UNDEFINEDs.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 5, 2021, 6:46pm UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/19 "2021-09-05T18:46:51Z")

</div>

I got a little sidetracked on building a packet protocol for communication between the app the board. This would make the communication work properly even if bytes gets lost or something, but it’s a little more involved than I first thought.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 5, 2021, 8:57pm UTC](https://crucible.hubbe.net/t/webusb-sept-2021/709/20 "2021-09-05T20:57:29Z")

</div>

Ok, so I’ve done some testing, however, I have not been able to reproduce most of these bugs.

I found a bug that adds a nonexistant undefined parameter in some cases (in ProffieOS, not in the webusb app) but that was it for bugs so far.

I should point out that saving doesn’t happen when you exit edit mode, it happens every time you change anything.

What URL are you using for the WebUSB app?

[Next page](https://crucible.hubbe.net/t/webusb-sept-2021/709.md?page=2)
