readUint32Array()

Description

Reads an unsigned 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

readUint32Array(unsigned long myArray, unsigned int nValues)

Parameters

  • myArray: the uint32_t or unsigned 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 uint32 array from MATLAB

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

ArCOM serialPort(SerialUSB); // Create serial port object

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

void setup() {

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

}

void loop() {

// Read an incoming uint32 array

serialPort.readUint32Array(myArray, 10);

}