Active5 years, 2 months ago
This is my first attempt at developing with a chrome app or extension. I have a GPS receiver on the USB port which is emulated as a serial device.
Nov 15, 2013 There is no similar functionality to Serial.available in the Chrome serial API, but you should just poll for some reasonable number of bytes and process the data at your own pace. If a read is requested for (say) 1024 bytes and only 8 bytes are available, the read should still succeed quickly with just 8 bytes. If there is an 8-byte message and a 12-byte message available, the read will.
This is my first attempt at developing with a chrome app or extension. I have a GPS receiver on the USB port which is emulated as a serial device. Running this code var onGetDevices = function(po. Use the chrome.serial API to read from and write to a device connected to a serial port. This should be passed as the path argument to chrome.serial.connect in order to connect to this device. Integer (optional) vendorId: A PCI or USB vendor ID if one can be determined for the underlying device. Since Chrome.
Running this code
gets me '/dev/ttyUSB0' in the console, so it appears to be finding the device.
How do I then connect to the device? I've included the serial.connect line above, with the following functions:
but I get the following error:
Error in response to serial.connect: ReferenceError: _this is not defined at Object.onGetDevices [as callback]
I'm not sure exactly what I'm doing right or wrong here so any pointers appreciated.
Xan57.6k1010 gold badges122122 silver badges145145 bronze badges
user2672288
1 Answer
First the example does not work properly. Try this instead:
Now as for the actual reading of the input from the serial connection it will work but converting the ArrayBuffer to a string is a bit harder than expected.
Joe KasavageJoe Kasavage
Note: on Mac OS X Lion, it's necessary to update USB Serial drivers:http://blog.geekscape.org/wordpress/2011/07/22/mac-os-x-17-lion-upgrading-ftdi-usb-serial-dr/
This sample shows a big button that lets you toggle between the on/offstate of an LED connected to an Arduino.
Chrome Serial Api Example
- Install the LED sketch on your Duo.
- Attach a LED to pin 2 (with a resistor to not burn it out).
- Install and launch this packaged app.
- Press the button to toggle the LED.
Future version: use the standard Firmata sketch and build a JS firmata driverfor Chrome packaged apps.