-
Notifications
You must be signed in to change notification settings - Fork 356
Using IOIO With a PC
Starting in software release V3.30, IOIO boards can be used with a PC. When using a IOIO-OTG board, the connection can be either wired (as a USB device) or wireless (over Bluetooth). With the original (V1) IOIO boards, only Bluetooth is supported.
The PC-side code is using the PureJavaComm library. This library is a key component in the PC-port of IOIOLib, enabling a cross-platform access to serial devices from Java. Special thanks to Kustaa "Kusti" Nyholm for making this great library and for spending time answering questions and addressing issues.
The first step in getting the IOIO to work with a PC is to have the PC detect it as a virtual serial port. The process is different depending on whether a Bluetooth or USB connection is used, but once this step is complete, the rest is completely identical.
If you are using Bluetooth, follow the instructions on this page, and then skip to the next section. The rest of this section is about connection IOIO-OTG boards to the PC as USB devices.
- Make sure the host mode switch on the board is in the auto ("A") position. This will enable the IOIO to act as a USB device (whereas the other mode forces it to host mode).
- Connect the IOIO to a PC with a micro-B USB cable. If it is not externally powered, it should power up at this point (red
pwr
LED is constantly on). - If you are running on Windows, you may be prompted for drivers. Grab them from the Downloads page.
- If you are running on Linux, it is highly recommended that you download a udev rules file from the Downloads page, and copy it to your rules directory (
sudo cp 50-ioio.rules /etc/udev/rules.d
). Then restart udev (sudo restart udev
orsudo /etc/init.d/udev restart
). This is a one-time process.-
If you are running modem-manager, like Ubuntu is, to make sure it is not interfering with the serial port add following rule:
`ATTRS{idVendor}=="1b4f", ATTRS{idProduct}=="0008", ENV{ID_MM_DEVICE_IGNORE}="1"`
to
/etc/udev/rules.d/78-mm-usb-device-blacklist-local.rules
. If you do not have such file already create one with following content (sudo vi /etc/udev/rules.d/78-mm-usb-device-blacklist-local.rules
) and then restart udev:ACTION!="add|change|move", GOTO="mm_usb_device_blacklist_end" SUBSYSTEM!="usb", GOTO="mm_usb_device_blacklist_end" ENV{DEVTYPE}!="usb_device", GOTO="mm_usb_device_blacklist_end" ATTRS{idVendor}=="1b4f", ATTRS{idProduct}=="0008", ENV{ID_MM_DEVICE_IGNORE}="1" LABEL="mm_usb_device_blacklist_end"
-
At this point, your PC should have an additional virtual serial port visible.
This step is not absolutely required, but highly recommended: your PC assigns an identifier to the new serial port which the IOIO is disguised as. You want to know this name so that you can later pass it do your application, to let it know how it could find the IOIO. If you don't, the application will try to auto-detect by scanning all the serial ports.
Finding the port identifier is OS specific:
- On Windows 7, open the "Devices and Printers" application from the start menu. You should see something like IOIO-OTG (COMxx). Note the COM number.
- On earlier versions of Windows, right click "My Computer" > Manage > Device Manager > expand Ports (COM & LPT) and find the COM number of IOIO-OTG.
- On OSX, run
ls /dev/tty.usb*
from a command shell and note the output. If there is more than one, the simplest thing to do it to run this twice with and without the IOIO connected and note the difference. - On Linux, assuming you installed the udev rules file as explained above,
run
ls /dev/IOIO*
and note the output.
Alternately, you can attempt to run a IOIO application once without providing the port identifier, and let it try to auto-detect. If it succeeds, the port identifier will appear in its logs.
Assuming you are using the IOIOLib Application Framework, your application will seamlessly support establishing a connection to the IOIO without caring about the gory details. It will even work will multiple IOIO board connected to the same host PC concurrently. When launching the application, it is highly recommended to tell the application which port (or ports) is used by the IOIO. Otherwise, the application will attempt to auto-detect the IOIO port upon launch, by attempting to establish a IOIO connection on every available serial port. This is both inefficient and inaccurate. In addition, if you do provide an explicit identifier to the application, your application will wait for the IOIO to connect even if it was not when the application was launched.
The IOIO serial ports are passed to the application using the Java system property called ioio.SerialPorts. It is expected to be a colon-separated list of port identifiers. One simple way of setting system properties is by passing them on the command line. For example, let's say we are working on Windows, and have identified COM13 to be the IOIO port, we can launch our application JAR as follows:
java -Dioio.SerialPorts=COM13 -jar HelloIOIO.jar