On 27 January 2011 02:25, Kirk Wallace <kwall...@wallacecompany.com> wrote:

> I haven't seen any documentation on modparam. Does anyone have a link to
> more information?

I don't think there is any documentation on "modparam" as part of a
comp module.
This is possibly because it doesn't work particularly well.

You can add a line:
modparam int mp-name "documentation goes here"
to the ,comp file headers, and then
loadrt my_comp mp-name=22
would allow you to access the value 22 in the function code as the
variable variable-name. (rather like a pin)
However, I have not managed to make it pass a value to more than one
instance of the component (loadrt my_comp count=3 mp-name=21,22,23
appears not to work, but I didn't look too hard)

you can use:
modparam dummy "This is the documentation"
to create documentation-only for a modparam in the man pages.

What I have been using instead is the macros here
http://linuxcnc.org/docs/html/man/man3/RTAPI_MP_INT.3rtapi.html

These let you read parameters into an array at load time, in the case
of the gearchange comp we have (from memory)

;;
int num_gears[8]
RTAPI_MP_ARRRAY_INT(num_gears, 8, "Comment here, not sure if it shows
up anywhere")

The  (global, shared, runs once) count_function then iterates through
the num_gears array counting non-zeros to determine how many instances
to create (MP_ARRAY_STRING might be better to use, you can look for
null instead)

the (per instance, individual, runs for each instance) EXTRA_SETUP
function can then get the actual parameter for each instance by
indexing into the num_gears array with the extra_arg variable.
(created in the intermediate C file by comp). As the pin creation code
only acts on the value if the "personality" variable you need to set
the personality from the num_gears array for conditional pin creation.
At it's simplest
personality = num_gears[extra_arg];
(This is a proper array, not the psuedo-arrays created by the
conditional pins, so uses [] rather than the () you use elsewhere in
comp code)

One problem is that the auto-created docs will define the conditional
pins in terms of the "personality" which might be completely opaque to
the users. In the case of bldc.comp, for example, the string modparam
is parsed into a bitfield in personality to create the required pins.
This means that the bldc.9 manpage ends up not being a helpful way to
determine how to create certain pins.

I am tempted to suggest that it might be best _not_ to document
conditional pin conditions in the manpages, leaving it to the author
to describe it in the pin description text.

-- 
atp
"Torque wrenches are for the obedience of fools and the guidance of wise men"

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to