readInt32Array()

Description

Reads an signed 32-bit integer array from the serial port

  • Blocks execution until each byte is available

  • Reads 4 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(long myArray, unsigned int nValues)

Parameters

  • myArray: the int32_t or long 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 int32 array from MATLAB

#include "ArCOM.h" // Include ArCOM library

ArCOM serialPort; // Create serial port object

long myArray[10] = {0}; // Create an array of int32's

void setup() {

SerialUSB.begin(115200); // Initialize USB serial port

}

void loop() {

// Read an incoming int32 array

serialPort.readInt32Array(myArray, 10);

}