Warning: The specified amount of data was not returned within the Timeout period for
'serialport' unable to read any data. For more information on possible reasons, see
serialport Read Warnings.
Failed to read data from the serial port.
function DMM_Collection()
serialPort = '/dev/tty.usbserial-1430';
serialObject = serialport(serialPort, 9600);
configureTerminator(serialObject, "LF");
fprintf('Error opening serial port: %s\n', fopenError.message);
writeline(serialObject, 'SYSTEM:REMOTE');
fprintf('Error setting remote mode: %s\n', remoteModeError.message);
stopTime = datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss.SSS') + seconds(10);
maxIterations = ceil(seconds(stopTime - datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss.SSS')) / timeInterval);
time = zeros(1, maxIterations);
current = zeros(1, maxIterations);
while datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss.SSS') < stopTime
writeline(serialObject, 'MEAsure:CURRent:DC?');
data = readline(serialObject);
current(count) = str2double(data);
fprintf('Timestamp: %s, Current: %f\n', datestr(time(count), 'yyyy-MM-dd HH:mm:ss.FFF'), current(count));
fprintf('Failed to read data from the serial port.\n');
writeline(serialObject, 'SYSTEM:LOCAL');
fprintf('Error setting local mode: %s\n', localModeError.message);
fprintf('Error cleaning up serial object: %s\n', cleanupError.message);