Bug in R8B-1 (and -0) using set_port_control_flags() in driver?
Scott Lystig Fritchie
fritchie@REDACTED
Sun Apr 14 22:23:49 CEST 2002
Please pardon me for this abbreviated bug (?) report and lack of fix.
On a lark, I tried adding a call to set_port_control_flags(port,
PORT_CONTROL_FLAG_BINARY) in my test driver's "start" function.
Without the set_port_control_flags() call in "start", I get a list of
3 bytes. With the call to set_port_control_flags(), I get a bogus
binary of random size instead.
Erlang (BEAM) emulator version 5.1.1 [source] [threads:5]
Eshell V5.1.1 (abort with ^G)
1> P1 = foodrv:open().
#Port<0.29>
2> X = foodrv:do_control(P1, 2,0).
<<64,7,29,8,0,0,0,0,72,0,0,0,24,180,55,8,200,239,191,191,20,180,55,8,212,239,191,191,213,...>>
3> size(X).
3214020608
4> q().
ok
FWIW, here's what do_control() looks like:
do_control(Port, Sec, MSec) ->
case erlang:port_control(Port, ?AS_CMD_ASLEEP, <<Sec:32, MSec:32>>) of
<<0:8, Tag:16>> -> % FIXME Const for OK status
receive
{Port, Tag, M} -> M
end;
XXX ->
XXX
end.
If I leave out the set_port_control_flags() and use this instead, it
works fine.
do_control(Port, Sec, MSec) ->
case erlang:port_control(Port, ?AS_CMD_ASLEEP, <<Sec:32, MSec:32>>) of
[0, Tag1, Tag2] -> % FIXME Const for OK status
Tag = (Tag1 bsl 8) bor Tag2,
receive
{Port, Tag, M} -> M
end;
XXX ->
XXX
end.
I'll just avoid using set_port_control_flags() for now.
-Scott
More information about the erlang-questions
mailing list