ArCOMObject()
Description
Returns an ArCOM interface object
Chooses the best interface by default (MATLAB/Java, Psychtoolbox IOPort or Octave)
Creates a serial port object
Opens the serial port
Syntax
myPort = ArCOMObject(Port, BaudRate, [interface])
Parameters
Port: The name of the serial port as it is known to the operating system.
In Windows, this will look like 'COMX' (i.e. 'COM3').
In OSX, this will look like '/dev/tty.usbmodemXXXX' or '/dev/tty.usbserial'
In Linux, this will look like '/dev/ttyACM0'.
BaudRate: The same baud rate used in your Arduino sketch (i.e. 9600, 115200, etc).
Interface: An optional string argument to force use of a specific interface (i.e. MATLAB/Java instead of Psychtoolbox/IOPort). Options are:
'java'
'psychtoolbox'
Returns
An ArCOM object with the following fields:
Port (the handle to the serial port, opened using the chosen interface)
UseOctave (0 if running in MATLAB, 1 if in Octave)
UsePsychtoolbox (0 if false, 1 if true)
Interface (a byte code for the interface used: 0 = MATLAB/Java, 1 = IOPort, 2 = Octave)
BaudRate (the baud rate of the port)
ValidDataTypes (a cell array of strings listing supported data types)
Example
% This code opens two serial ports using ArCOM, in a MATLAB environment with PsychToolbox installed and ArCOMObject.m in the MATLAB path. One port is forced to use MATLAB's native serial interface.
MyHappyPort = ArCOMObject('COM3', 115200);
MySadPort = ArCOMObject('COM4', 115200, 'java');