Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Callbacks for modem_cmd_send arnt getting called

Hey,

Having some trouble getting the callbacks to invoke with the generic library on zephyr 1.7.1

to my understanding once it gets the data it should call it. have i misunderstood the setup ? 

an example

/* 
//      example data set TODO parse this properly + modify the struct + learn what the other parameters are doing 
//  <UTC>         091635.000,       UTC time (hhmmss.sss)         
//  <latitude>    3913.6952N,       Format: ddmm.mmmm  N/S   dd: 00..90, degrees    || mm.mmmm: 00.0000..59.9999 min || N/S: North/South
//  <longitude>   00904.1505E,      Format: dddmm.mmmm E/W   ddd: 000..180, degrees || mm.mmmm: 00.0000..59.9999 min || E/W: East/West
//  <hdop>        0.7,              Horizontal Dilution of Precision  TODO look this up lol
//  <altitude>    17.9,             altitude - mean-sea-level (geoid) in meters
//  <fix>         3,                fix type status ? whats the difference between 2D and 3D fix ?
//  <cog>         0.0,              Course over Ground (degrees, True) 
//  <spkm>        0.0,              speed over ground (Km/hr) 
//  <spkn>        0.0,              speed over ground (knots)
//  <date>        290920,           date of fix  dd: 01..31, day   mm: 01..12, month   yy: 00..99, year 2000 to 2099
//  <nsat>        10                total number of satellites in use  0-12

 Handler:$GPSACP: 
    <UTC>,              [0]
    <latitude>,         [1]
    <longitude>,        [2]
    <hdop>,             [3]  
    <altitude>,         [4]
    <fix>,              [5]
    <cog>,              [6]
    <spkm>,             [7]
    <spkn>,             [8]
    <date>,             [9]
    <nsat>              [10]
*/ 
MODEM_CMD_DEFINE(on_cmd_GPSACP)
{                         //str->int <buf/
  
      LOG_DBG("UTC %s \n",        argv[0] );
      LOG_DBG("latitude %s\n",    argv[1] );
      LOG_DBG("longitude %s\n",   argv[2] );
      LOG_DBG("hdop %s\n",        argv[3] );
      LOG_DBG("altitude %s\n",    argv[4] );
      LOG_DBG("fix %s\n",         argv[5] );  // should be an integer
      LOG_DBG("cog %s\n",         argv[6] );
      LOG_DBG("spkm %s\n",        argv[7] );
      LOG_DBG("spkn %s\n",        argv[8] );  
      LOG_DBG("date %s\n",        argv[9] );  
      LOG_DBG("nsat %s\n",        argv[10]);   // should be an integer
     
      if(strcmp(argv[5],"1") == 0 || strcmp(argv[5],"0") == 0  ){     //INVALID FIX
         LOG_DBG("Still waiting on Fix ! fix == %s \n",argv[5]);  
      }else{
          strcpy(mdata.utc,       argv[0]);
          strcpy(mdata.latitude,  argv[1]);
          strcpy(mdata.longitude, argv[2]);
          strcpy(mdata.hdop,      argv[3]);
          strcpy(mdata.altitude,  argv[4]);
          strcpy(mdata.fix,       argv[5]);
          strcpy(mdata.cog,       argv[6]);
          strcpy(mdata.spkm,      argv[7]);
          strcpy(mdata.spkn,      argv[8]);
          strcpy(mdata.date,      argv[9]);
          strcpy(mdata.nsat,      argv[10]); 
          mdata.gps_updated =  1;
      }

      k_sem_give(&mdata.sem_response);

      
	return 0;
}


bool readGPS(){

  int ret = 0;
  ///Callback doesnt seem to be called -why? dunno

  static const struct modem_cmd cmd_GPSACP = MODEM_CMD("$GPSACP ", on_cmd_GPSACP, 11U, ",");
        //Get Response
      ret = modem_cmd_send(&mctx.iface, 
                           &mctx.cmd_handler,
                           &cmd_GPSACP,      // gpsp data parse
                           0,
                           "AT$GPSACP",    // Data get
                           &mdata.sem_response,
                           MDM_REGISTRATION_TIMEOUT);

           k_sleep(K_SECONDS(5));

           LOG_DBG(" DATA fix = %s  altitude = %s, utc = %s",mdata.fix,mdata.altitude,mdata.utc);

if (ret < 0) {
	LOG_ERR(" ret:%d", ret);
	LOG_ERR("Closing!!!");
	return -1;
}

    if(mdata.gps_updated == 1){
      
      mdata.gps_updated =0;
      return true;
    }else{
      return false;
    }

}




The output on RTT

Parents Reply
  • Hey, just an update. i found that the arguements are above the standard amount expected (6).
    currently im reading from the rx_buf->data which seems to be a shift register for all the previous commands and outputs as well.

    il update the post when i get some time to test changing the Max_parameter from 6 to 12 and see how it behaves as last time i did try it out it was causing some unwanted behaviour.

Children
Related