readByteArray()
Description
Reads a byte array from the serial port
Blocks execution until each byte is available
Reads the bytes and adds them 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
readByteArray(byte myArray, unsigned int nBytes)
Parameters
myArray: the byte array to receive the data
nBytes: the number of bytes to read into the array (should not exceed array length)
Returns
None
Example
// This code reads an incoming byte array from MATLAB
#include "ArCOM.h" // Include ArCOM library
ArCOM serialPort(SerialUSB); // Create serial port object
byte myByteArray[10] = {0}; // Create an array of 10 bytes
void setup() {
SerialUSB.begin(115200); // Initialize USB serial port
}
void loop() {
// Read an incoming byte array
serialPort.readByteArray(myByteArray, 10);
}