Welcome! Log In Create A New Profile

Advanced

Plugin:Passing multiple args from ByPic to Plugin

Posted by g8jcf 
Plugin:Passing multiple args from ByPic to Plugin
August 03, 2014 02:17AM
As I've said before, the C plugin capability of ByPic is fantastic.

Now, how/can I pass 2 or more pointers to a C plugin function ?

eg could I have

int AddLong(char *A, char *B, char *C){

.............function body

}

and then in ByPic do

Call AddLong( ?A(0), ?B(0), ?C(0) )

Thank you in advance

Peter
Re: Plugin:Passing multiple args from ByPic to Plugin
August 03, 2014 01:02PM
Peter,
A plugin will only accept a character pointer as a parameter and so what I have done in the past is to create an array of pointers and pass the address of the first array index to the plug in. An example of this 1-wire that needs strict timing. I can pass timer registers etc:

    owConstants(0) =    TMR
    owConstants(1) =    PR
    owConstants(2) =    IFS
    owConstants(3) =    IFSMASK
    owConstants(4) =    TRIS
    owConstants(5) =    PORT
    owConstants(6) =    LAT
    owConstants(7) =    PORTMASK

and then call the plug in so: return call(?owRead_pi,?owConstants(0))

The plug in takes care of sorting out whats what as all that has been passed really is a block of memory that the bas files has put some values in.
*** don't forget that a plugin cannot call any other functions, it must be one function only ***
Jim
Re: Plugin:Passing multiple args from ByPic to Plugin
August 03, 2014 04:38PM
Hi Jim

Got it, good idea. OK, I'll try that method and see how it goes.

Very many thanks

Peter
Sorry, you do not have permission to post/reply in this forum.