Exemple #1
0
es_Status es_tcl_track_radio_addpkt(char* arg1, char* arg2, void (*appendResult)(char*,es_ClientData), es_ClientData data) {
  MetadataElement_T_Common_Types_Pkg *hdr = NULL;

  if(arg2==NULL) {
    snprintf(es_msg_buf,ES_MSG_BUF_SIZE,"missing argument: packet data");
    return ES_TCL_ERROR;
  }

  int i;
  int spos = 0;
  for(i=0; i<MAX_NUM_PACKETS; i++) {
    hdr = &(es_tcl_track_radio_buf.Messages.PacketHeaders[i]);
    if( ! hdr->valid )
      break;
    spos = hdr->endAddress + 1;
  }

  if(hdr->valid) {
    snprintf(es_msg_buf,ES_MSG_BUF_SIZE,"cannot add radio packet: maximum number of packets reached");
    return ES_TCL_ERROR;
  }

  hdr->nid_packet = atoi(arg1);
  hdr->q_dir = (hdr->nid_packet / 100000) % 10;
  hdr->valid = true;
  hdr->startAddress = spos;
  size_t len = strlen(arg2) / 2;
  hdr->endAddress = spos + (len/4) - 1;
  if(len > 500 ) {
    snprintf(es_msg_buf,ES_MSG_BUF_SIZE,"cannot add radio packet: packet too big (%lu bytes)",len);
    return ES_TCL_ERROR;
  }
  char buf[500];
  es_hex_to_bytes(len,arg2,buf);
  memcpy(&es_tcl_track_radio_buf.Messages.PacketData[spos],buf,len);

  return ES_OK;
}
Exemple #2
0
es_Status es_tcl_track_radio_load_raw(char* hexdata) {
  es_hex_to_bytes(es_tcl_track_rmsize,hexdata,(char*)&es_tcl_track_radio_buf);
  return ES_OK;
}