Quantcast

[erlang-questions] 'C' Driver Question

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[erlang-questions] 'C' Driver Question

Bob Cowdery-2
Hi

I've just started to use Erlang and this is my first post. I have a requirement to communicate between two parts of a 'C' program. One part will be a C Port and the other a C Driver type implementation. The C Port side is working but I'm having trouble with the C Driver. I have been following the examples in the Interoperability Tutorial, so first off I just wantsed to roughly follow the examples. I have built the shared library but I can't load it. This is under Ubuntu Linux incidentally. I have a library called liber_driver.so and I try to load it with

erl_ddll:load_driver(".", liber_driver).

I know it's loading the file because it first gave me some unresolved errors. When I fixed those it now says

{error,bad_driver_name}

I have no idea what this means, any help appreciated.

Regards
Bob

_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [erlang-questions] 'C' Driver Question

Serge Aleynikov
What this means is that the driver name doesn't match filename.  Most
likely you gave an inconsistent name to your driver in the ErlDrvEntry
structure, it should be:

ErlDrvEntry sample_driver_entry = {
     ...
     "liber_driver",   /* char *driver_name, the argument to open_port */
     ...
};

Also you can make the error reason more verbose by using
erl_ddll:format_error/1:

case erl_ddll:load_driver(".", liber_driver) of
ok ->
    ...;
{error, Reason} ->
    {error, erl_ddll:format_error(Reason)}
end.

Regards,

Serge

Bob Cowdery wrote:

> Hi
>
> I've just started to use Erlang and this is my first post. I have a requirement to communicate between two parts of a 'C' program. One part will be a C Port and the other a C Driver type implementation. The C Port side is working but I'm having trouble with the C Driver. I have been following the examples in the Interoperability Tutorial, so first off I just wantsed to roughly follow the examples. I have built the shared library but I can't load it. This is under Ubuntu Linux incidentally. I have a library called liber_driver.so and I try to load it with
>
> erl_ddll:load_driver(".", liber_driver).
>
> I know it's loading the file because it first gave me some unresolved errors. When I fixed those it now says
>
> {error,bad_driver_name}
>
> I have no idea what this means, any help appreciated.
>
> Regards
> Bob
>

_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [erlang-questions] 'C' Driver Question

Jani Hakala
In reply to this post by Bob Cowdery-2
"Bob Cowdery" <[hidden email]> writes:

> Hi
>
> I've just started to use Erlang and this is my first post. I have a
> requirement to communicate between two parts of a 'C' program. One
> part will be a C Port and the other a C Driver type
> implementation. The C Port side is working but I'm having trouble with
> the C Driver. I have been following the examples in the
> Interoperability Tutorial, so first off I just wantsed to roughly
> follow the examples. I have built the shared library but I can't load
> it. This is under Ubuntu Linux incidentally. I have a library called
> liber_driver.so and I try to load it with
>
> erl_ddll:load_driver(".", liber_driver).
>
> I know it's loading the file because it first gave me some unresolved
> errors. When I fixed those it now says
>
> {error,bad_driver_name}
>
> I have no idea what this means, any help appreciated.
>
Do you have DRIVER_INIT(liber_driver) in your C code?

Jani Hakala
_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [erlang-questions] 'C' Driver Question

Bob Cowdery-2
In reply to this post by Bob Cowdery-2
Serge

Thank you, that fixed it. It wasn't obvious to me the name had to be the filename. Nice to see this group looks fairly active, good to know when starting out.

Regards
Bob

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]]On Behalf Of Serge Aleynikov
Sent: 07 September 2006 14:20
To: Erlang/OTP discussions
Subject: Re: [erlang-questions] 'C' Driver Question


What this means is that the driver name doesn't match filename.  Most
likely you gave an inconsistent name to your driver in the ErlDrvEntry
structure, it should be:

ErlDrvEntry sample_driver_entry = {
     ...
     "liber_driver",   /* char *driver_name, the argument to open_port */
     ...
};

Also you can make the error reason more verbose by using
erl_ddll:format_error/1:

case erl_ddll:load_driver(".", liber_driver) of
ok ->
    ...;
{error, Reason} ->
    {error, erl_ddll:format_error(Reason)}
end.

Regards,

Serge

Bob Cowdery wrote:

> Hi
>
> I've just started to use Erlang and this is my first post. I have a requirement to communicate between two parts of a 'C' program. One part will be a C Port and the other a C Driver type implementation. The C Port side is working but I'm having trouble with the C Driver. I have been following the examples in the Interoperability Tutorial, so first off I just wantsed to roughly follow the examples. I have built the shared library but I can't load it. This is under Ubuntu Linux incidentally. I have a library called liber_driver.so and I try to load it with
>
> erl_ddll:load_driver(".", liber_driver).
>
> I know it's loading the file because it first gave me some unresolved errors. When I fixed those it now says
>
> {error,bad_driver_name}
>
> I have no idea what this means, any help appreciated.
>
> Regards
> Bob
>

_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Loading...