I have written a Chrome app that uses a scale. (I use the Mettler Toledo Ariva-S scale.) Here’s what I learned during the process:
· Chrome’s USB API exposes the bus itself, not the native device drivers. In other words, the USB API allows you to write a device driver in JavaScript. Since I didn’t want to write a device driver the USB API was not an option for me.
· Because I didn’t want to use the USB API I needed an out-of-process solution that would allow me to access the scale
o Chrome has the Native Messaging API for talking to other processes. https://developer.chrome.com/extensions/nativeMessaging It does so by sending text-based messages back and forth via stdin and stdout. I experimented with this API a bit but ultimately decided it wasn’t going to work for me. The major issue was that Chrome can only pass messages to the native app if Chrome itself launches that native app (which it can do) but Chrome doesn’t give you any way to manage the native app’s process (e.g. pre-launch it, make sure it keeps running even if it crashed earlier, etc.)
o I ended up writing a separate RESTful web service to wrap the scale’s native device driver. This service runs locally on the same machine as the Chrome app. Then my Chrome app makes a call to the web service to get data from the scale.
--
You received this message because you are subscribed to the Google Groups "Chromium-Apps-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
chromium-app...@chromium.org.
To post to this group, send email to
chromi...@chromium.org.
Visit this group at
https://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit
https://groups.google.com/a/chromium.org/d/optout.