Hmmm - it looks like nobody ever answered your original questions here.

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
>  
>
Note that this is superseded by hal_input, which also supports joysticks
that use the kernel input event interface.

>might be a good model to follow for making my modbus user-land
>component. 
>
Yes and no.  It's a good model for a basic userland C HAL component
which uses a hardware device interface.  It's not quite applicable with
respect to configuration of modbus-related parameters (like register
ranges to read/write).  It's certainly usable as a starting point though.

>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?
>  
>
The reason is that there's no way to get a complete list of all joystick
devices (axes and buttons) before you get the first "event".  If you try
to enumerate all the axes first, and the joystick gets moved while
you're doing it, then there will be a motion event thrown in the middle
of the capabilities enumeration.  Also, there's no "that's it, those are
all the buttons I've got" message.  You can get notified of a new button
or axis at any time.  So, the best thing to do is to just start the
event loop, and if you receive an "event" that says "this is analog axis
#7", just export a HAL pin.  If it's a button or motion event, then
change the appropriate HAL pin.

(at least that's my recollection of the issues jmkasunich had to deal
with when writing the driver in the first place)

>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?
>  
>
There's no great need to have a user-readable component name, but it is
required that all components have unique names.  If you load two
hal_joystick instances, the component names will be different.  You can
specify a different prefix using the -p option:

loadusr hal_joystick -d /dev/js0 -p wingman_pro
loadusr hal_joystick -d /dev/js1 -p atari_joystick

(it looks like the driver won't automatically choose different prefixes
for different instances, but that's a moot point)

Hope this helps (and is all accurate :) )
- Steve



-------------------------------------------------------------------------
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