Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pb programing an interface under QNX

Status
Not open for further replies.

Edgee

Electrical
Jan 16, 2004
2
hello, I'm currently working on a robot contoled under QNX. I'm making an interface whith PhAB an have a little pb.
I edited the gcc_nto*/Makefile
and added "-Bstatic -l ph -Bdynamic" to the link lines ( LDFLAGS=... and
SDFLAGS=... ) to put PtNumericFloat into the shared library, but it seems I still get pbs whith the PtNumericFloat.

Here is my code :

/* Y o u r D e s c r i p t i o n */
/* AppBuilder Photon Code Lib */
/* Version 2.01 */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Local headers */
#include &quot;ablibs.h&quot;
#include &quot;abimport.h&quot;
#include &quot;proto.h&quot;

PtWidget_t*link_instance;
PtWidget_t*Nfich;
PtWidget_t*g[3];
float *gain[3];
FILE*file;
FILE*aff;
char*nom;


int
gains_acquis( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
int l=0;

/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

link_instance = ApGetInstance(widget);
Nfich = ApGetWidgetPtr(link_instance,ABN_gains_nom);
PtGetResource(Nfich, Pt_ARG_TEXT_STRING, &nom,0);
file = fopen(nom,&quot;r+&quot;);
fseek(file,47*sizeof(float),SEEK_SET);

g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_kp);
g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_kd);
g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_ga);
//ABN_gains_kp and so are PtNumericFloat

l=0;

aff=fopen(&quot;affich.txt&quot;,&quot;w&quot;);

for(l=0;l<3;l++)
{
PtGetResource(g[l],Pt_ARG_NUMERIC_VALUE,&gain[l],0);
fwrite(gain[l],sizeof(float),1,file);
fprintf(aff,&quot;%f \n&quot;,*gain[l]);
}

fclose(aff);
fclose(file);

return( Pt_CONTINUE );

}



But when I open affich.txt, I only obtain
0.0000
0.0000
0.0000
whatever I type in the widgets when running the application.

Then I tried something :


/* Y o u r D e s c r i p t i o n */
/* AppBuilder Photon Code Lib */
/* Version 2.01 */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Local headers */
#include &quot;ablibs.h&quot;
#include &quot;abimport.h&quot;
#include &quot;proto.h&quot;

PtWidget_t*link_instance;
PtWidget_t*Nfich;
PtWidget_t*g[1];
int *gain[1];
FILE*file;
FILE*aff;
char*nom;


int
gains_acquis( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
int l=0;

/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

link_instance = ApGetInstance(widget);
Nfich = ApGetWidgetPtr(link_instance,ABN_gains_nom);
PtGetResource(Nfich, Pt_ARG_TEXT_STRING, &nom,0);
file = fopen(nom,&quot;r+&quot;);
fseek(file,47*sizeof(int),SEEK_SET);

g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_test);
// ABN_gains_test is a PtNumric Integer

l=0;

aff=fopen(&quot;affich.txt&quot;,&quot;w&quot;);

for(l=0;l<1;l++)
{
PtGetResource(g[l],Pt_ARG_NUMERIC_VALUE,&gain[l],0);
fwrite(gain[l],sizeof(int),1,file);
fprintf(aff,&quot;%d \n&quot;,*gain[l]);
}

fclose(aff);
fclose(file);

return( Pt_CONTINUE );

}



I just added a PtNumericInteger in the window, and changed the code to write
this number instead of the three previious ones. Then I obtain an integer
equal to the one I type when running the application.
I don't really need the .txt file, but I'm afraid that the other file
(fwrite(gain[l],sizeof(int),1,file)) won't be written correctly. Is there
another thing to do so that PtNumericFloat would be accepted, or is there a
mistake in my code (sometimes I'm quite lost whith the format in functions)
?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor