<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Hi all<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I just want to make sure that I understand the driver
interface basics correctly.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>driver_command/2<o:p></o:p></p>
<p class=MsoNormal>Takes iodata as data<o:p></o:p></p>
<p class=MsoNormal>Delivers to the output callback as binary or array<o:p></o:p></p>
<p class=MsoNormal>Returns values asynchronously with a driver_output call<o:p></o:p></p>
<p class=MsoNormal>-If the outputv callback is set, this is used instead and
delviers the data as ErlIOVec (which is faster)<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>driver_controll/3<o:p></o:p></p>
<p class=MsoNormal>Takes iodata as data<o:p></o:p></p>
<p class=MsoNormal>Delivers to the controll callback as binary or array<o:p></o:p></p>
<p class=MsoNormal>Returns values synchronously with results in the supplied rbuf
parameter<o:p></o:p></p>
<p class=MsoNormal>-Return values may be either eterm format or binary<o:p></o:p></p>
<p class=MsoNormal>-Fastest according to docs<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>driver_call/3<o:p></o:p></p>
<p class=MsoNormal>Takes an erlang term as data<o:p></o:p></p>
<p class=MsoNormal>Delivers to the call callback as pointer to eterm<o:p></o:p></p>
<p class=MsoNormal>Returns values synchronously with results in the rbuf
parameter<o:p></o:p></p>
<p class=MsoNormal>-Return values must be in eterm format<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>It would seem that each has its own uses.<o:p></o:p></p>
<p class=MsoNormal>driver_controll is useful for exposing C functions
most directly. For this the calling erlnang code should send a binary,
packed with the parameters in the native format. Returned values will be
a binary, again in the native format.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>driver_call is useful if you want to create functions that
look more like erlang functions than C functions. You have to decode the sent
terms and encode the responses through ei.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>driver_command is useful if you need to do asynchronous
calls. Perhaps also useful in a multithreaded driver that does long computations
(in combination with driver_async)?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Some things I don’t quite understand:<o:p></o:p></p>
<p class=MsoNormal>Is the output callbacks format also determined by set_port_controll_flags
like form the controll callback?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Might it be useful to have a controll type callback that
delivers the data as ErlIOVec, for the same optimisation reasons as for the
output callback?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Is driver_output2 useful? Is there an efficeincy issue
with matching on a binary on the erlang side, or does this function predate
binary matching?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Is it more efficeint to use driver_output_binary than
driver_output if it is known beforehand that the port is in binary mode?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Any further insights would be appreciated<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>-]-[einrich<o:p></o:p></p>
</div>
</body>
</html>