On Fri, 2008-02-22 at 17:51 -0800, Kirk Wallace wrote:
> I think hal_joystick.c:
> 
> http://cvs.linuxcnc.org/cgi-bin/cvsweb.cgi/emc2/src/hal/user_comps/devices/hal_joystick.c?rev=1.2;content-type=text%2Fplain
> 
> might be a good model to follow for making my modbus user-land
> component. My guess would be that one would setup HAL and the the HAL
> pins and then loop to update the inputs and outputs, but the joystick
> pins are set up in the main loop. Why is that?
> 
> There is a prefix parameter used to name the pins and buttons but not
> the component itself:
> ...
> snprintf(name, HAL_NAME_LEN-1, "hal_joystick-%d", getpid());
> comp_id = hal_init(name);
> ...
> Is there a reason not to use the prefix here?
> 
> Thanks.
> 

Another bit I don't understand:

    /* STEP 3: allocate shared memory for joystick data */
    js_data = (hal_js_t *) hal_malloc(sizeof(hal_js_t));
    if (js_data == 0) {
        printf( "ERROR: hal_malloc() failed\n");
        hal_exit(comp_id);
        return -1;
    }

hal_js_t is a defined variable type.
sizeof(hal_js_t) is the memory size of this type.
hal_malloc(sizeof(hal_js_t)) returns the memory location of this
variable.
I don't understand what (hal_js_t *) does. hal_js_t is a type so it is
similar to (int *)?

-- 
Kirk Wallace (California, USA
http://www.wallacecompany.com/machine_shop/ 
Hardinge HNC lathe,
Bridgeport mill conversion, doing XY now,
Zubal lathe conversion pending)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to