×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Pb programing an interface under QNX

Pb programing an interface under QNX

Pb programing an interface under QNX

(OP)
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 "ablibs.h"
      #include "abimport.h"
      #include "proto.h"

      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,"r+");
      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("affich.txt","w");

      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,"%f \n",*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 "ablibs.h"
      #include "abimport.h"
      #include "proto.h"

      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,"r+");
      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("affich.txt","w");

      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,"%d \n",*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)
?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources