I saw this post, but I have an application written for webUSB and it works with teensy on macOS, but on Windows you can't connect to teensy. I think the reason is that Windows is installing its drivers for Teensy, which makes it impossible to connect to Teensy via webusb.
Most of the users of my application use windows, so it must work well, and I don't want to give up teensy...
Hallo Luni, actually I have no use case, other than satisfying my curiosity about this unfamiliar WebUSB stuff.But maybe I just don't understand the use case for a low level USB communication using a web browser.
<!DOCTYPE html>
<html>
<head>
<title>Page Title2</title>
</head>
<body>
<h1>WebSerial Tester</h1>
<button type="button" id="connectButton">Connect to Teensy</button>
<p></p>
<button type="button" id="sendButton">Say hello to Teensy</button>
<script src="js/main.js"></script>
</body>
</html>
let connectButton = document.getElementById('connectButton');
let writeButton = document.getElementById('sendButton');
// allow connection to the port
connectButton.addEventListener("click", async () => {
const filters = [
{ usbVendorId: 0x16C0 }
];
port = await navigator.serial.requestPort({filters});
});
// write button opens the port and writes a string to the Teensy
writeButton.addEventListener("click", async () => {
await port.open({ baudRate: 9600 }); // baudrate ignored
const writer = port.writable.getWriter();
let utf8Encode = new TextEncoder();
const data = new Uint8Array(utf8Encode.encode("hello World\n")); // hello
await writer.write(data);
writer.releaseLock();
port.close();
});
void setup()
{
while (!SerialUSB1);
SerialUSB1.println("Start");
}
void loop()
{
if(Serial.available())
{
SerialUSB1.write(Serial.read());
}
}
I'm trying this now and it almost works fine, the problem I have is that teensy doesn't always connect correctly, here:WebHID is (probably) your path of least resistance. Yeah, it means changing some of your existing code. I can't see how difficult your code is, but I really doubt it could be worse than dealing with the Windows issues. WebHID really should be worth another look.
Fixed man! awesome!When Teensy implements RawHID, it actually has 2 HID interfaces.
Usage FFAB:0200 is the RawHID interface.
Usage FFC9:0004 is the serial emulation interface. This lets you still use Serial.print() to the Arduino Serial Monitor, even though you're not using USB serial.
I'm not familiar with WebHID, so I can't say how... but I can say you probably need to tell it to open only the FFAB:0200 interface and somehow ignore the FFC9:0004 interface.
Coming back to the topic, I have a question about increasing the package size, I use webhid and it works properly, but the package size of 64 bytes limits me. Is it possible to increase it to 128 bytes, which would be satisfactory for me? If so, will teensy be able to handle it without causing any problems?When Teensy implements RawHID, it actually has 2 HID interfaces.
Usage FFAB:0200 is the RawHID interface.
Usage FFC9:0004 is the serial emulation interface. This lets you still use Serial.print() to the Arduino Serial Monitor, even though you're not using USB serial.
I'm not familiar with WebHID, so I can't say how... but I can say you probably need to tell it to open only the FFAB:0200 interface and somehow ignore the FFC9:0004 interface.