Drivers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Drivers

Karel Van Oudheusden
Hello,


I have written a 'C1.c' file which is supposed to be a linked-in Erlang
driver:

-----------------------------------------
#include <stdio.h>
#include "erl_driver.h"

static int erlang_port;
static long easy_start();
.....
------------------------------------------

Except for a warning message, I have successfully compiled the file with
the following command:

gcc -c -I/mnt/hda2/kvo7B-1/otp_src_R7B-1/erts/emulator/beam C1.c -o C1

However, in the (old) documentation that I downloaded from the net, I am
supposed to change the contents of the 'config.c' file before
compilation and linking. The problem is I cannot find this file. Can
somebody help me with this. And how do I link the file into the Erlang
system? I am using RedHat 7.0.  Where can I find the most up to date
documentation on drivers?


thanx,
KVO.



Reply | Threaded
Open this post in threaded view
|

Drivers

Vance Shipley-2
Karel,

I am also working on a driver now.  The best documentation I have
found is in the ERST User's Guide (3. How to implement an alternative
carrier for the erlang distribution).  This discusses an example
linked in driver.

> However, in the (old) documentation that I downloaded from the net, I am
> supposed to change the contents of the 'config.c' file before
> compilation and linking. The problem is I cannot find this file. Can
> somebody help me with this. And how do I link the file into the Erlang

You will however want to use the new Dynamic Driver Loader and Linker
(erl_ddll) which is documented in the Kernel Reference Manual.  This
allows you to install your new driver on a running system without
having to recompile the kernel.  With this method you won't need to
worry about the above.


> I have written a 'C1.c' file which is supposed to be a linked-in Erlang
> driver:
>
> -----------------------------------------
> #include <stdio.h>
> #include "erl_driver.h"

You are including the newer header file (driver.h was the old) so that's
a good start.

> Except for a warning message, I have successfully compiled the file with
> the following command:
>
> gcc -c -I/mnt/hda2/kvo7B-1/otp_src_R7B-1/erts/emulator/beam C1.c -o C1

To go the dll (dynamically linked library) route you'll need to add -fPIC.


I found it quite a struggle to determine how all of this was supposed to
work, especially because I chose to use threads, asynchronous I/O etc.
My source code now serves to document the new features in the driver code
(as best as I understand them).  I do plan to release all of this when
I'm done.  Contact me directly if you need more help.

        -Vance

Vance Shipley
Motivity Telecom Inc.
+1 519 579 5816



Reply | Threaded
Open this post in threaded view
|

Drivers

Scott Lystig Fritchie-3
>>>>> "vs" == Vance Shipley <vances> writes:

vs> You will however want to use the new Dynamic Driver Loader and
vs> Linker (erl_ddll) which is documented in the Kernel Reference
vs> Manual.  

Another good source of info on that subject is by example.  I'd found
that the "byteorder" driver (found in the User Contributions area,
http://www.erlang.org/user.html) was a good place to start.

-Scott
---
Scott Lystig Fritchie
Professional Governing: Is It Faked?