Using IOIO With a PC
Clone this wiki locally
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.
Connecting the IOIO as a Serial Port
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
pwrLED 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 udevor
sudo /etc/init.d/udev restart). This is a one-time process. Otherwise, look inside that udev rules for some configuration hints.
At this point, your PC should have an additional virtual serial port visible.
Finding Out the Port Identifier
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,
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.
Passing the Port Identifiers to the Application
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