|
|
@ -17,7 +17,9 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { |
|
|
setSerialPorts(await navigator?.serial.getPorts()); |
|
|
setSerialPorts(await navigator?.serial.getPorts()); |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
navigator?.serial?.addEventListener("connect", () => { |
|
|
navigator?.serial?.addEventListener("connect", (event) => { |
|
|
|
|
|
console.log(event); |
|
|
|
|
|
|
|
|
updateSerialPortList(); |
|
|
updateSerialPortList(); |
|
|
}); |
|
|
}); |
|
|
navigator?.serial?.addEventListener("disconnect", () => { |
|
|
navigator?.serial?.addEventListener("disconnect", () => { |
|
|
@ -39,16 +41,22 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { |
|
|
concurrentLogOutput: true, |
|
|
concurrentLogOutput: true, |
|
|
}) |
|
|
}) |
|
|
.catch((e: Error) => console.log(`Unable to Connect: ${e.message}`)); |
|
|
.catch((e: Error) => console.log(`Unable to Connect: ${e.message}`)); |
|
|
|
|
|
console.log(connection); |
|
|
|
|
|
|
|
|
device.addConnection(connection); |
|
|
device.addConnection(connection); |
|
|
subscribeAll(device, connection); |
|
|
subscribeAll(device, connection); |
|
|
|
|
|
|
|
|
closeDialog(); |
|
|
closeDialog(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
console.log(serialPorts); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div className="flex w-full flex-col gap-2 p-4"> |
|
|
<div className="flex w-full flex-col gap-2 p-4"> |
|
|
<div className="flex h-48 flex-col gap-2 overflow-y-auto"> |
|
|
<div className="flex h-48 flex-col gap-2 overflow-y-auto"> |
|
|
{serialPorts.map((port, index) => { |
|
|
{serialPorts.map((port, index) => { |
|
|
|
|
|
console.log(port); |
|
|
|
|
|
|
|
|
const { usbProductId, usbVendorId } = port.getInfo(); |
|
|
const { usbProductId, usbVendorId } = port.getInfo(); |
|
|
return ( |
|
|
return ( |
|
|
<Button |
|
|
<Button |
|
|
@ -59,8 +67,7 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { |
|
|
await onConnect(port); |
|
|
await onConnect(port); |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
{`# ${index} - ${usbVendorId ?? "UNK"} - ${ |
|
|
{`# ${index} - ${usbVendorId ?? "UNK"} - ${usbProductId ?? "UNK" |
|
|
usbProductId ?? "UNK" |
|
|
|
|
|
}`}
|
|
|
}`}
|
|
|
</Button> |
|
|
</Button> |
|
|
); |
|
|
); |
|
|
|