1、创建一个send_buff.c文件,并将文件,放入到LR脚本存放路径下,文件内容如下:
int z=0;
int p;
char sernd_buf[2048];
char * send_buffer(char * send_Buffer)
{
int r;
char * send_psrc;
char send_dst[2048];
send_psrc=send_Buffer;
for(r=0;*send_psrc;r++){
strcpy(send_dst,"\x");
strncat(send_dst,send_psrc,2);
send_psrc+=2;
for(p=0;p<strlen(send_dst);p++) {
sernd_buf[z++]=send_dst[p];
}
}
z=0;
return sernd_buf;
}
2、在LR vuser中引入send_buff.c文件,如下图:
3、在vuser_init中引入send_buff.c包头,如下图
4、在action中就可以引用了,如下:
Action()
{
char * send_buffer_val;
char buffer_2[2048]="010b0701c0";
send_buffer_val = send_buffer(buffer_2);
lr_output_message(">>>最终send_buffer>>>>>%s ",send_buffer_val);
lr_save_string(send_buffer_val,"Param_data");
lr_output_message(">>>>>>>>>>>>>>01:%s
",lr_eval_string("<Param_data>"));
lr_save_int(strlen(lr_eval_string("<Param_data>"))/4,"Param_length");
lr_output_message(">>>>>>>>>>>>>>02:%s
",lr_eval_string("<Param_length>"));
lrs_send("socket6", "buf5", LrsLastArg);
}
5、修改data.ws:
;WSRData 2 1
send buf5 <Param_length>
"<Param_data>"
recv buf6 8
"x01x0bx07x00x02x59x47xdb"
-1
---------------------
作者:深圳-雄少
来源:CSDN
原文:https://blog.csdn.net/zouxiongqqq/article/details/81102495
版权声明:本文为博主原创文章,转载请附上博文链接!