<div>First, I would like to say.:Yes, the erl_interface documentation is lacking in details and examples. </div><div><br></div>Secondly, I would like to reframe your question. Should I use erl_interface to communicate with my port driver in the first place? Many examples point to that fact but I would disagree.<div>
<br></div><div>erl_interface, (ei), should be used for c-nodes where we want to talk to our c-program over erlang distribution. When I want my c-program to simulate an erlang node. This is, I think, a rare case though.</div>
<div><br></div><div>In most situations I would construct a packet protocol instead and handle this protocol on the erlang side with bitsyntax. Handling "c-data" in erlang is much easier than using erlang terms in c. Look at efile_drv and inet_drv, none of those use erl_interface. The protocol becomes far simpler and probably faster.</div>
<div><br></div><div>We have only one other case where it makes sense to encode and decode terms in c and that is when our data are in the erlang process heap, i.e. when we use NIFs. But, in this case we have an entirely different API so we wouldn't use ei here either.</div>
<div><br></div><div>So, while I agree that ei could be better documented, I question if you really need it. I think it complicates more things than it solves.</div><div><br></div><div>// Björn-Egil</div>