You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
port:call(UART, read, 2000) finishes timing out, then a subsequent valid write expecting a response will result with a read that always return a {error, ealready} .
Example:
Length=21,
UART=open_port(
{spawn, "uart"},
[
{peripheral, <<"UART2">>},
{rx, 16},
{tx, 17},
% {controlling_process, self()},% {stop_bits, 2},% {active, false},% {flow_control, hardware},% {timeout, 4000}
{speed, 115200}
]),
Req3=uart_sensor_request(3, 0, Length),
io:format("Req3 = ~p~n", [Req3]),
uart:write(UART, Req3), % Writing a valid requestio:format("read3 ~p~n", [call(UART, read, 2000)]), % Expecting a responseReq4=uart_sensor_request(4, 0, Length),
io:format("Req4 = ~p~n", [Req4]),
uart:write(UART, Req4), % Writing an INVALID requestio:format("read4 ~p~n", [call(UART, read, 2000)]), % Expecting NO response and expecting read to block until timeoutuart:write(UART, Req3), % Writing a valid request againio:format("read3 again ~p~n", [call(UART, read, 2000)]), % Expect a response again BUT errors
Output:
Req3 = [3,4,0,0,0,21,48,39]
read3 {ok,<<3,4,42,0,58,0,9,0,7,0,23,0,5,7,231,8,155,117,175,71,98,136,33,54,176,11,173,11,176,2,117,13,221,1,145,25,66,1,244,0,20,190,31,0,1,127,58>>}
Req4 = [4,4,0,0,0,21,49,144]
read4 {error,timeout}
read3 again {error,ealready} <- Not expecting this!
The text was updated successfully, but these errors were encountered:
port:call(UART, read, 2000)
finishes timing out, then a subsequent valid write expecting a response will result with a read that always return a{error, ealready}
.Example:
Output:
The text was updated successfully, but these errors were encountered: