readUint16Array()
Description
Reads an unsigned 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
readUint16Array(unsigned short myArray, unsigned int nValues)
Parameters
myArray: the uint16_t or unsigned 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 uint16 array from MATLAB
#include "ArCOM.h" // Include ArCOM library
ArCOM serialPort(SerialUSB); // Create serial port object
unsigned short myArray[10] = {0}; // Create an array of // uint16's
void setup() {
SerialUSB.begin(115200); // Initialize USB serial port
}
void loop() {
// Read an incoming uint16 array
serialPort.readUint16Array(myArray, 10);
}