-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRead_directly_from_Arduino_Matlab.m
45 lines (41 loc) · 1.29 KB
/
Read_directly_from_Arduino_Matlab.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% Raphael BOICHOT 11/08/2021 Game Boy printer emulator
% This script directly handle the Arduino from Matlab
% for any question : raphael.boichot@gmail.com
% for end of transmission, simply reboot the Arduino
clear
clc
disp('-----------------------------------------------------------')
disp('|Beware, this code is for Matlab ONLY !!! |')
disp('|Beware, this code is not yet compatible Matlab Mobile !!!|')
disp('|Reboot Arduino to end transmission |')
disp('-----------------------------------------------------------')
rng('shuffle');
arduinoObj = serialport("COM6",115200,'TimeOut',3600); %set the Arduino com port here
configureTerminator(arduinoObj,"CR/LF");
flush(arduinoObj);
arduinoObj.UserData = struct("Data",[],"Count",1);
flag=0;
str='Packet Capture V3';
while flag==0
data = readline(arduinoObj);
disp(data)
if not(isempty(strfind(data,str)))
flag=1;
end
end
disp('Entering the capture loop...')
fid=fopen('Entry_file.txt','w');
str='Packet Capture V3';
flag=0;
while flag==0
data = readline(arduinoObj);
disp(data)
fprintf(fid,'%s\r\n',data);
if not(isempty(strfind(data,str)));
flag=1;
end
end
fclose(serial(arduinoObj.Port));
fclose(fid);
disp('Normal termination, printing the images...')
run Main_Decoder.m