Skip to content

Commit ad50814

Browse files
committed
* private/__recvResponse__.m, private/__sendCommand__.m: dont send
arduino obj to __recvResponse__
1 parent e329d1d commit ad50814

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

inst/@arduino/private/__recvResponse__.m

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
## Private function
1717
## @end deftypefn
1818

19-
function [dataOut, errcode] = __recvResponse__ (obj, libid, cmd, timeout)
19+
function [dataOut, errcode] = __recvResponse__ (dev, libid, cmd, timeout, debug)
2020

2121
dataOut = [];
2222
errcode = 0;
2323

24-
set(obj.connected, "timeout", timeout*10);
24+
set(dev, "timeout", timeout*10);
2525

2626
# TODO: current serial doesnt have a way to know if any data is awaiting
2727
# so try read what we need first without waiting ?
2828

2929
# read in initial part
30-
[tmpdataOut, tmpdataSize] = fread (obj.connected, 4);
31-
if (obj.debug)
30+
[tmpdataOut, tmpdataSize] = fread (dev, 4);
31+
if (debug)
3232
printf("<< "); printf("%d ", tmpdataOut); printf("\n");
3333
endif
3434
if tmpdataSize < 4
@@ -39,14 +39,14 @@
3939
dataOut = "Malformed packet header";
4040
elseif (tmpdataOut(3) == 254)
4141
# got a wait for response value - length is expected to be 0
42-
if (obj.debug)
42+
if (debug)
4343
printf("* wait for response\n");
4444
endif
4545

46-
set(obj.connected, "timeout", -1);
46+
set(dev, "timeout", -1);
4747

48-
[tmpdataOut, tmpdataSize] = fread (obj.connected, 4);
49-
if (obj.debug)
48+
[tmpdataOut, tmpdataSize] = fread (dev, 4);
49+
if (debug)
5050
printf("<< "); printf("%d ", tmpdataOut); printf("\n");
5151
endif
5252
if tmpdataSize < 4
@@ -61,8 +61,8 @@
6161
if(errcode == 0)
6262
expectlen = tmpdataOut(4);
6363
if expectlen > 0
64-
[dataOut, tmpdataSize] = fread (obj.connected, expectlen);
65-
if (obj.debug)
64+
[dataOut, tmpdataSize] = fread (dev, expectlen);
65+
if (debug)
6666
printf("<< "); printf("%d ", dataOut); printf("\n");
6767
endif
6868
else
@@ -81,12 +81,12 @@
8181
endif
8282
elseif tmpdataOut(3) == 253
8383
# valid but was a debug message
84-
if obj.debug
84+
if debug
8585
s = char(dataOut);
8686
printf("DEBUG: %s\n", s);
8787
endif
8888

89-
[dataOut, errcode] = __recvResponse__ (obj, libid, cmd, timeout);
89+
[dataOut, errcode] = __recvResponse__ (dev, libid, cmd, timeout, debug);
9090
else
9191
errcode = 0;
9292
# all is good

inst/@arduino/private/__sendCommand__.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@
6161
printf(">> "); printf("%d ", [hdr data]); printf("\n");
6262
endif
6363

64-
[dataOut, errcode] = __recvResponse__ (obj, libid, cmd, timeout);
64+
[dataOut, errcode] = __recvResponse__ (obj.connected, libid, cmd, timeout, obj.debug);
6565
endfunction

0 commit comments

Comments
 (0)