linked-in driver

Serge Aleynikov serge@REDACTED
Wed Jun 1 16:59:29 CEST 2005


Thanks Shawn!

I'd like to add a little note that this also works fine with 
erlang:open_port({spawn, "mydrv param1 param2"}, ...)

Shawn Pearce wrote:
> Serge Aleynikov <serge@REDACTED> wrote:
> 
>>I need to pass parameters to the start function of a linked-in driver, 
>>but I am not sure how this can be done.
>>
>>The start function accepts a char* command.  Is there a way to pass 
>>anything there besides the driver's name?
>>
>>int start(ErlDrvPort port, char* command);
>>
>>After examining erlang:open_port/2 I found the {env, Environment} 
>>option, but I believe it only works for port drivers.
>>
>>Any advice on the subject is appreciated.
> 
> 
> 
> Pass the parameters as part of the driver string to open_port.  E.g.
> 
> erlang:open_port("mydrv param1 param2", ...)
> 
> will give you the string "mydrv param1 param2" in the command parameter
> of the start function in your C code.  You will have to parse out the
> parameters on your own.  I believe the only requirement on the format
> of this string is that the characters leading up to the first ASCII
> space match the name of the driver; the rest is left up to the driver.




More information about the erlang-questions mailing list