-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweb02-webserial.html
66 lines (32 loc) · 953 Bytes
/
web02-webserial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<script>
</script>
<h6>Version 0.0.1-1</h6>
<input type="text" value=45>
<input type="button" value="Connect" onclick="
connectToWebSerial async function(){
var serial = new WebSerial();
const usbVendorId = 0x2341; // Specific for Arduino //usbProductId: ???
const myPort = await serial.requestPort({ filters: [{ usbVendorId }]}).then((port) => {
console.log("myPort");
console.log(myPort);
serial.connect(myPort, {bitrate: 9600}, function(error) {
if (error) {
console.log('Error: ' + error);
} else {
console.log('Connected to serial port');
}
});
return serial;
}
let mySerial = await connectToWebSerial();
">
<input type="button" value="Serial" onclick="
myWebSerialPortRequest async function(){
var mySerial = connectToWebSerial();
var myData = await mySerial.read();
console.log(myData);
return myData;
}
let myWow = await myWebSerialPortRequest();
">
<div id="myDiv01">...</div>