⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datademo.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
  strcpy (aa2[1].u.component,"l");/* Packed, two components, reversed order ('l' and 'b' 			*/  mv++;  mv->i.alt_acc_data_packed = SD_TRUE;	  mv->i.alt_acc.num_aa = 2;   mv->i.alt_acc.aa = aa3;   aa3[0].comp_name_pres = SD_FALSE;  aa3[0].sel_type = AA_COMP;  strcpy (aa3[0].u.component,"l");  aa3[1].comp_name_pres = SD_FALSE;  aa3[1].sel_type = AA_COMP;  strcpy (aa3[1].u.component,"b");/* Packed, single component ('s') only					*/  mv++;  mv->i.alt_acc_data_packed = SD_TRUE;	  mv->i.alt_acc.num_aa = 1;   mv->i.alt_acc.aa = aa4;   aa4[0].comp_name_pres = SD_FALSE;  aa4[0].sel_type = AA_COMP;  strcpy (aa4[0].u.component,"s");  confirm_rcvd = SD_FALSE;  if (!(req_ptr = mv_read_variables (chan,num_var,info,mv_info_ptr)))    {    print_req_error ();    chk_free (mv_info_ptr);    }  else    {    while (!confirm_rcvd && !kbhit ())      {      mms_comm_service ();      }       }     }/************************************************************************/static ST_VOID vmdt_rdvars_conf (MMSREQ_PEND *req_ptr)  {struct read_resp_info *rsp_ptr;struct mv_read_req_info  *varlist;ST_INT  i;struct str1_P2 *lbptr;struct str1 *str1ptr;ST_INT16 *sptr;  conf_info_print (req_ptr,"NAMED Read");  if (req_ptr->resp_err)		/* Check for error		*/    list_err_info (req_ptr);		/* print reason if so		*/  else				/* NO error, info is available	*/    {    rsp_ptr = (struct read_resp_info *) req_ptr->resp_info_ptr;    varlist = (struct mv_read_req_info *) req_ptr->req_info_ptr;    i = 0;    if (varlist->o.result == ACC_RSLT_SUCCESS)      {      printf ("\n  Element 's' Read Successful");      str1ptr = (struct str1 *) dest_buf[i];		/* Not packed */      printf ("\n    s = %d", (int) str1ptr->s);      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Element 's' only failed, code = %d", varlist->o.err_code);      }    varlist++;			/* point to next variable	*/    i++;    if (varlist->o.result == ACC_RSLT_SUCCESS)      {      printf ("\n  Elements 's' and 'l' Read Successful");      str1ptr = (struct str1 *) dest_buf[i];		/* Not packed */      printf ("\n    s = %d", (int) str1ptr->s);      printf ("\n    l = %ld", str1ptr->l);      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Elements 's' and 'l' failed, code = %d", varlist->o.err_code);      }    varlist++;			/* point to next variable	*/    i++;    if (varlist->o.result == ACC_RSLT_SUCCESS)      {      printf ("\n  Elements 'l' and 'b' Read Successful");      lbptr = (struct str1_P2 *) dest_buf[i];		/* Packed */      printf ("\n    l = %ld", lbptr->l);      printf ("\n    b = %d", (int) lbptr->b);      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Elements 'l' and 'b' failed, code = %d", varlist->o.err_code);      }    varlist++;			/* point to next variable	*/    i++;    if (varlist->o.result == ACC_RSLT_SUCCESS)      {      printf ("\n  Element 's' only Packed && Reversed Read Successful");      sptr = (ST_INT16 *) dest_buf[i];		/* Packed */      printf ("\n    s = %d", (int) *sptr);      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Element 's' only failed, code = %d", varlist->o.err_code);      }/* free the VM request information */    chk_free (req_ptr->req_info_ptr);    }  conf_info_wait ();/* When any virtual machine request is complete. the user should call	*//* 'ms_clr_mvreq' to free up any buffers reserved for the request.      */  ms_clr_mvreq (req_ptr);	/* clear the VM command info		*/  confirm_rcvd = SD_TRUE;  }/************************************************************************/static ST_VOID vmdt_read_ind (MMSREQ_IND *ind_ctrl)  {struct read_req_info  *read_req_ptr;struct variable_list  *vl;struct mv_read_resp_info *vm_info;struct mv_read_resp_info *vm_ptr;ST_INT i;ST_INT num_rslt;  read_req_ptr = (struct read_req_info *) ind_ctrl->req_info_ptr;  if (mms_debug_sel & MMS_LOG_USR_IND)    {    indic_info_print (ind_ctrl,"Read");    printf ("\n Specification with Result : ");    if (read_req_ptr->spec_in_result)      printf (" YES");    else      printf (" NO");    print_vaspec (&read_req_ptr->va_spec);    }/* for now, assume this is a list of variables				*/  num_rslt = read_req_ptr->va_spec.num_of_variables;;  vm_info = (struct mv_read_resp_info *) 		chk_calloc (num_rslt,sizeof (struct mv_read_resp_info));  vm_ptr = vm_info;  vl = (struct variable_list *) (read_req_ptr +1);    for (i = 0; i < num_rslt; ++i,++vm_ptr, ++vl)    {    vm_ptr->alt_acc_pres = vl->alt_access_pres;    if (!strcmp (vl->var_spec.vs.name.obj_name.vmd_spec,"str1"))      {      vm_ptr->result = ACC_RSLT_SUCCESS;      vm_ptr->type = str1_type;      vm_ptr->data_ptr = (ST_CHAR *) &server_str1;      }    else      {      vm_ptr->result = ACC_RSLT_FAILURE;      vm_ptr->err_code = ARE_OBJ_UNDEFINED;      }    }/* now we are ready to send the response - 				*/  mv_read_response (ind_ctrl,num_rslt,vm_info);  chk_free (vm_info);  indic_info_wait ();			/* allow user to see indic info */  }/************************************************************************//************************************************************************/static ST_VOID  send_test_write (ST_INT indx, ST_INT chan)  {ST_INT num_var;ST_INT i;struct var_acc_spec *info;struct mv_write_req_info *mv;struct mv_write_req_info *mv_info_ptr;struct variable_list *vl;MMSREQ_PEND *req_ptr;struct alt_acc_el aa1[1];struct alt_acc_el aa2[2];struct alt_acc_el aa3[2];struct alt_acc_el aa4[1];struct str1_P2 lbsrc;ST_INT ssrc;static ST_INT z = 0;  num_var = 4;/* Need to calloc a buffer for the VM information, since it needs to be	*//* committed until the confirm is received 				*/  mv_info_ptr = (struct mv_write_req_info *)                 chk_calloc (num_var,sizeof (struct mv_write_req_info));  info	  = (struct var_acc_spec *) ((ST_CHAR *)dest_buffer);  info->var_acc_tag = VA_SPEC_NAMED;  info->num_of_variables = 4;  vl = (struct variable_list *) (info+1);  mv = mv_info_ptr;/* All elements of this write are about the same, except for the way the	*//* returned data is to be handled.					*/  for (i = 0; i < num_var; ++i, ++vl, ++mv)    {    if (i == 3)				/* for the 4th element only	*/      {      vl->alt_access_pres = SD_TRUE;  	/* we supply ASN1.1 AA		*/      vl->alt_access.data =  asn1_aa;      vl->alt_access.len = 5;      }	         else				/* for all others		*/      vl->alt_access_pres = SD_FALSE;  	/* let the VM make ASN1.1 AA 	*/    vl->var_spec.var_spec_tag = VA_SPEC_NAMED;    vl->var_spec.vs.name.object_tag = VMD_SPEC;    strcpy (vl->var_spec.vs.name.obj_name.vmd_spec,"str1");/* Now VM information */    mv->type = str1_type;    mv->alt_acc_pres = SD_TRUE;	    }/* Now do the AA specifications for each variable			*//* Non-packed, single component ('s') only				*/  mv = mv_info_ptr;  client_str1.s = (ST_INT16) z;  mv->data_ptr = (ST_CHAR *) &client_str1;  mv->alt_acc_data_packed = SD_FALSE;	  mv->alt_acc.num_aa = 1;   mv->alt_acc.aa = aa1;   aa1[0].comp_name_pres = SD_FALSE;  aa1[0].sel_type = AA_COMP;  strcpy (aa1[0].u.component,"s");/* Non-packed, two components ('s' and 'l'				*/  mv++;  client_str1.s = 2 + (ST_INT16) z;  client_str1.l = 3 + (ST_INT32) z;  mv->data_ptr = (ST_CHAR *)&client_str1;  mv->alt_acc_data_packed = SD_FALSE;	  mv->alt_acc.num_aa = 2;   mv->alt_acc.aa = aa2;   aa2[0].comp_name_pres = SD_FALSE;  aa2[0].sel_type = AA_COMP;  strcpy (aa2[0].u.component,"s");  aa2[1].comp_name_pres = SD_FALSE;  aa2[1].sel_type = AA_COMP;  strcpy (aa2[1].u.component,"l");/* Packed, two components, reversed order ('l' and 'b' 			*/  mv++;  lbsrc.b = 1;  lbsrc.l = 4 + (ST_INT32) z;  mv->data_ptr = (ST_CHAR *)&lbsrc;  mv->alt_acc_data_packed = SD_TRUE;	  mv->alt_acc.num_aa = 2;   mv->alt_acc.aa = aa3;   aa3[0].comp_name_pres = SD_FALSE;  aa3[0].sel_type = AA_COMP;  strcpy (aa3[0].u.component,"l");  aa3[1].comp_name_pres = SD_FALSE;  aa3[1].sel_type = AA_COMP;  strcpy (aa3[1].u.component,"b");/* Packed, single component ('s') only					*/  mv++;  ssrc = 5 + (ST_INT16) z;  mv->data_ptr = (ST_CHAR *)&ssrc;  mv->alt_acc_data_packed = SD_TRUE;	  mv->alt_acc.num_aa = 1;   mv->alt_acc.aa = aa4;   aa4[0].comp_name_pres = SD_FALSE;  aa4[0].sel_type = AA_COMP;  strcpy (aa4[0].u.component,"s");  confirm_rcvd = SD_FALSE;  if (!(req_ptr = mv_write_variables (chan,num_var,info,mv_info_ptr)))    {    print_req_error ();    chk_free (mv_info_ptr);    }  else    {    chk_free (mv_info_ptr);			/* dont' need to keep		*/    while (!confirm_rcvd && !kbhit ())      {      mms_comm_service ();      }    }     ++z;  }/************************************************************************/static ST_VOID vmdt_wrvars_conf (MMSREQ_PEND *req_ctrl)  {struct write_resp_info *rsp_ptr;struct write_result *rslt;ST_INT  i;  conf_info_print (req_ctrl,"NAMED write");  if (req_ctrl->resp_err)		/* Check for error		*/    list_err_info (req_ctrl);		/* print reason if so		*/  else				/* NO error, info is available	*/    {    rsp_ptr = (struct write_resp_info *) req_ctrl->resp_info_ptr;    rslt = (struct write_result *) (rsp_ptr +1);    i = 0;    if (rslt->resp_tag == WR_RSLT_SUCCESS)      {      printf ("\n  Element 's' Write Successful");      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Element 's Only' Write failed, code = %d", rslt->failure);      }    rslt++;	 			/* point to next variable	*/    i++;    if (rslt->resp_tag == WR_RSLT_SUCCESS)      {      printf ("\n  Elements 's' and 'l' Write  Successful");      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Elements 's' and 'l' failed, code = %d", rslt->failure);      }    rslt++;				/* point to next variable	*/    i++;    if (rslt->resp_tag == WR_RSLT_SUCCESS)      {      printf ("\n  Elements 'l' and 'b' Packed && Reversed Write Successful");      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Elements 'l' and 'b' failed, code = %d", rslt->failure);      }    rslt++;				/* point to next variable	*/    i++;    if (rslt->resp_tag == WR_RSLT_SUCCESS)      {      printf ("\n  Element 's Only' Packed Write Successful");      }    else				/* unsuccessful, print failure	*/      {      printf ("\n  Element 's' only failed, code = %d", rslt->failure);      }    }  conf_info_wait ();/* When any virtual machine request is complete. the user should call	*//* 'ms_clr_mvreq' to free up any buffers reserved for the request.      */  ms_clr_mvreq (req_ctrl);	/* clear the VM command info		*/  confirm_rcvd = SD_TRUE;  }/************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -