readInt16Array()
readInt16Array()
Description
Reads an signed 16-bit integer array from the serial port
Blocks execution until each byte is available
Reads 2 bytes per integer, and adds each integer to the array
Unlike in MATLAB, the array is passed as an input argument.
Its memory location is passed to the function.
It does not need to be passed back as an output argument.
Syntax
readInt16Array(short myArray, unsigned int nValues)
Parameters
myArray: the int16_t or short array to receive the data
nValues: the number of ints to read into the array (should not exceed array length)
Returns
None
Example
% This code reads an incoming int16 array from MATLAB
#include "ArCOM.h" // Include ArCOM library
ArCOM serialPort; // Create serial port object
short myArray[10] = {0}; // Create an array of int16's
void setup() {
SerialUSB.begin(115200); // Initialize USB serial port
}
void loop() {
// Read an incoming int16 array
serialPort.readInt16Array(myArray, 10);
}