1

I have system working in php, I try to get the data from scale TOLEDO S60 , in a Form HTML Using JAVASCRIPT, I try with Web USB API , but does't work

this is my code:

    <a href="#" onclick="conectar()">CONECTAR</a>

<script type="text/javascript">


    function conectar(){

        navigator.usb.requestDevice({ filters: [{ vendorId:'0eb8' }] })
        .then(device => {
          console.log(device.productName);      
          console.log(device.manufacturerName); 
        })
        .catch(error => { console.log(error); });


    }
</script>

I got this response from Chrome: enter image description here

this is the Scale Information: enter image description here

this is the scale webpage --> https://www.mt.com/us/en/home/phased_out_products/Transport_and_Logistics_Solutions/postal_scales_transp_log/PS_family_transp_logistic/PS60_Scale.html

Comadrexa
  • 21
  • 4
  • My experimentation shows that the vendorId is to be specified in decimal, not in hexadecimal. However, it seems only certain types of devices can be connected in this way, but I do not know why. – Palo Jun 13 '20 at 21:15
  • I tried with decimal values and does not work... – Comadrexa Jun 15 '20 at 17:28
  • Try removing the filter completely. You will probably see that some devices are accessible, but the scales you'd like to talk to aren't. Somehow only few devices are available to this library. I do not know why and if anything can be done with it. – Palo Jun 15 '20 at 17:32
  • does not work without filters , I tried already – Comadrexa Jun 15 '20 at 23:06
  • When I tried `filters: [{ }]` on my notebook, it did find some devices, but not all of them, only a few. – Palo Jun 16 '20 at 22:40
  • now a I got all the device , but I can not see my USB HID – Comadrexa Jun 17 '20 at 00:57
  • Were you able to solve it? – gANDALF Sep 07 '20 at 10:10

1 Answers1

1

The vendorId filter expects an integer rather than a string. Remove the single quotes and call requestDevice like this,

navigator.usb.requestDevice({ filters: [{ vendorId: 0x0eb8 }] })
Reilly Grant
  • 5,590
  • 1
  • 13
  • 23