Example #1
0
/**Prepare data response packet*/
int srv_prepare_data_resp(srv_t *srv) {
//  int i;
//  data_resp_t *resp = (data_resp_t *)srv->resp;
  data_el_t *elems = (data_el_t *)(srv->resp + sizeof(data_resp_t));

  form_data_resp(srv->resp,
		 srv->status,
		 rcli_get_meas_no(srv->rcli),
		 rcli_get_elapsed(srv->rcli));

  //if server is busy (e.g. if test mode is enabled) shrink packet to size of header
  if(srv->fn_rv==RRW_RV_BUSY) {
    #ifdef DBG_SRV
    logprintf("SERVER: busy!\n");
    #endif
    return sizeof(data_resp_t);
  }

  //increment measurement ordinal number
  rcli_incr_meas_no(srv->rcli);

  if(srv->rcli->has_data) {
  //copy last targets data to response buffer
    rcli_copy_last(srv->rcli,(char*)elems);
    return sizeof(data_resp_t)+1024*sizeof(data_el_t);
  } else {
    return sizeof(data_resp_t);
  }

//  logprintf("RESP!\n");

//  return sizeof(data_resp_t)+1024*sizeof(data_el_t);
}
Example #2
0
int srv_prepare_data_alt_resp(srv_t *srv) {
  int i;
  base_req_t *req = (base_req_t *)srv->req;
  data_alt_resp_t *resp = (data_alt_resp_t *)(srv->resp);

  resp->meas_no = rcli_get_meas_no(srv->rcli);
  resp->elapsed = rcli_get_elapsed(srv->rcli);

  rcli_copy_last_raw(srv->rcli,resp->rise,resp->fall);
  resp->ntargets = 0;

//  return sizeof(base_resp_t);

  int sz = sizeof(data_alt_resp_t) - 255*sizeof(target_t);
  printf("SIZE OF RESP %d\n",sz);
  return sz;
//  return sizeof(data_alt_resp_t) - 255*sizeof(target_t);
}
Example #3
0
int srv_prepare_data_resp(srv_t *srv) {
  int i;
  data_resp_t *resp = (data_resp_t *)srv->resp;
  data_el_t *elems = (data_el_t *)(srv->resp + sizeof(data_resp_t));
  
  srv_update_status(srv);
  
  form_data_resp(srv->resp,
		 srv->status,
		 rcli_get_meas_no(srv->rcli),
		 rcli_get_elapsed(srv->rcli));
  
  if(srv->fn_rv==RRW_RV_BUSY)
    return sizeof(data_resp_t);

  rcli_incr_meas_no(srv->rcli);
  
  rcli_copy_last(srv->rcli,(char*)elems);

  return sizeof(data_resp_t)+1024*sizeof(data_el_t);
}