driver_kerl.cpp File Reference

An Erlang Port Driver. More...

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "erl_driver.h"
#include "ei.h"
#include "common_kerl.h"
#include "kerl.h"
#include "ei_extended.h"

Include dependency graph for driver_kerl.cpp:


Functions

static ErlDrvData kerlDriverStart (ErlDrvPort port, char *buff)
static void kerlDriverStop (ErlDrvData handle)
static void doFree (void *state)
static void kerlDriverMain (void *asyncData)
static void kerlDriverOutput (ErlDrvData handle, char *buff, int bufflen)
static void kerlDriverReadyAsync (ErlDrvData drvData, ErlDrvThreadData asyncData)
 DRIVER_INIT (kerl)

Variables

ErlDrvEntry kerlDriverEntry

Detailed Description

An Erlang Port Driver.

Author:
Thomas Lorentsen, Sten Gruener
This contains code required to load a driver into Erlang allowing calls to be made to Player.

Erlang will initialize the driver allowing it to pass calls using Erlang Interface. This driver will wrap up the varibless passed from Erlang and pass it onto kerl.cpp which will allow robot control in player.

This driver runs concurrently.

Driver is explained: http://erlang.org/doc/man/driver_entry.html


Function Documentation

doFree ( void *  state  )  [static]

Parameters:
state is the data passed into the driver Not currently used but called at the end of a function call

DRIVER_INIT ( kerl   ) 

Initialise erlang driver.

kerlDriverMain ( void *  asyncData  )  [static]

Parameters:
asyncData is the kerldata passed into the driver Contains the kerl main functions passed from the async driver. Decoding of the atoms passed from erlang is done here and decides what kerl function is needed to call. If no function can be called then an error is returned.

kerlDriverOutput ( ErlDrvData  handle,
char *  buff,
int  bufflen 
) [static]

Parameters:
handle pointer to the passed port information (todo: not sure ;))
buff erlang port input string
bufflen length of the input string Function calls to the driver go here before they run asynchronously. The memory has to be copied to avoid curruption and then a thread is spawned at the end.

kerlDriverReadyAsync ( ErlDrvData  drvData,
ErlDrvThreadData  asyncData 
) [static]

Parameters:
drvData the driver data passed
asyncData the async data passed This function is called when a async thread has completed This function is called after an asynchronous call has completed. The asynchronous call is started with driver_async.

kerlDriverStart ( ErlDrvPort  port,
char *  buff 
) [static]

Parameters:
port is the port
buff any commands passed
Returns:
the port on success
This is called when the driver is instantiated, when open_port/2 is called.

kerlDriverStop ( ErlDrvData  handle  )  [static]

Parameters:
handle data This is called when the port is closed


Variable Documentation

Initial value:

 {
        NULL,                       
        kerlDriverStart,                
        kerlDriverStop,         
        kerlDriverOutput,       
        NULL,                       
        NULL,                       
        "kerl",                     
        NULL,                       
        NULL,                       
        NULL,                       
        NULL,                       
        NULL,
        kerlDriverReadyAsync, 
        NULL,
        NULL,
        NULL
}
This is the driver entry definition and helps erlang to know how to talk to the driver. The variables change in here depending if it is async of not


Generated on Thu Aug 13 23:20:22 2009 for KERL by  doxygen 1.5.8