330 pts.
 Get the ASPs with QYASPOL API from c++
I trying to get the ASP with the QYASPOL API from c++ but the next source code only 
returns data in the info variable , the receiver looks empty :S , could you point me in the right direction ? 
#include <QYASPOL.h> 
#include <stdio.h> 
#include <qusec.h> 
#include <QGYGTLE.h> 
 ...
 
 typedef struct 
 {  YASP_Filter_t filterByNumber ; 
    int  data    ; 
 }FilterInfo_t ;   
 
 
 
int main () {  
 int sz = 1024 ; 
 char receiver [1024 ] ;              
 
 
 YASP_List_Information_t  info ;
 
 int numRecords = -1 ;     
 int numFilters =  1 ;    
 FilterInfo_t filterInfo ; 
 filterInfo.filterByNumber.Key = 1 ;   
 filterInfo.filterByNumber.Data_Size = 4 ;                        
 filterInfo.data = -1 ;                                           
 filterInfo.filterByNumber.Entry_Size = sizeof ( FilterInfo_t) ;  
                                                                  
 char format[] = "YASP0100";                                      
                                                                  
 QYASPOL ( receiver ,&sz,&info ,&numRecords ,                     
       &numFilters ,&filterInfo,  format ,&errorCode ) ;          
   
                                                                    
 printf ( "TR:%d n" , info.Total_Records ) ;                               
 printf ( "RR:%d n" , info.Records_Returned ) ;                            
 printf ( "sz:%d n" , info.Information_Length ) ;   
 printf ( "Device Desc [%s] n" , ((YASP0100_t *) ptr )-> Device_Desc ) ;    
TR:3 
RR:3 
sz:168 
Number:[1] 
Device Desc [       ]


Software/Hardware used:
v5r4, QYASPOL
ASKED: October 21, 2011  12:49 AM
UPDATED: March 19, 2012  12:58 PM
  Help
 Approved Answer - Chosen by GraceP (Question Asker)

int numRecords = -1 ;

Try changing that to:

int numRecords = 1 ;

Since you are requesting format YASP0100 and it's only 64 bytes long, you could probably use:

int numRecords = 16 ;

By specifying Number of records to return as -1, the list will be built synchronously. But because it's a negative 1, you haven't actually asked that any records be returned to your program. All records should then need to be returned through calls to the Get List Entries (QGYGTLE) API.

I haven't quite figured out why this API was created as an "Open List..." API. It wouldn't seem ever to be enough ASPs to demand that much effort.

Tom

ANSWERED:  Oct 21, 2011  2:16 AM (GMT)  by GraceP

 
Other Answers:
Last Wiki Answer Submitted:  October 16, 2012  4:30 pm  by  Michael Tidmarsh   11,380 pts.
Latest Answer Wiki Contributors:  Michael Tidmarsh   11,380 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Thanks TomLiotta!
Changed to 16 and using the QGYGTLE API and it gave me the ASP info :)

  Qgy_Gtle_ListInfo_t  listInfo ;                   
                                                    
                                                    
  char * handler = info.Request_Handle  ;           
  char r2 [1024 ];
                                                    
  QGYGTLE ( r2 ,                                    
            1024 ,                                  
            handler ,                               
            &listInfo,                              
            info.Records_Returned ,                 
            -1 ,       
            &errorCode ) ; 
                             
   ptr = r2  ;                                                     
   for ( int i =0 ; i < info.Total_Records ; i ++ ) {                   
         printf ( "Number:[%d] n" , ((YASP0100_t *) ptr )-> Number ) ; 
         ...
 330 pts.

 

Be aware that this cannot return more than 16 records. If you ever need more, you’ll either need a sufficiently larger receiver variable or enough calls to QGYGETLE to get remaining records.

In any case, you probably should call the Close List (QGYCLST) API after you’re done receiving the list.

Tom

 107,815 pts.

 

Sorry, ignore much of my previous comment. I glossed right over your use of QGYGTLE. Too often eyes see what they expect to see.

Tom

 107,815 pts.

 

Thanks again !

 330 pts.