#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/pmap_cln.h>
#include "vxi11.h"
static void device_async_1();
static void device_core_1();
static void device_intr_1();
void main()
{
SVCXPRT *transp;
#ifdef WIN32
rpc_nt_init();
#endif
(void)pmap_unset(DEVICE_ASYNC, DEVICE_ASYNC_VERSION);
(void)pmap_unset(DEVICE_CORE, DEVICE_CORE_VERSION);
(void)pmap_unset(DEVICE_INTR, DEVICE_INTR_VERSION);
transp = svcudp_create(RPC_ANYSOCK);
if (transp == NULL) {
(void)fprintf(stderr, "cannot create udp service.\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_UDP)) {
(void)fprintf(stderr, "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, udp).\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_UDP)) {
(void)fprintf(stderr, "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, udp).\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_UDP)) {
(void)fprintf(stderr, "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, udp).\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
if (transp == NULL) {
(void)fprintf(stderr, "cannot create tcp service.\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_TCP)) {
(void)fprintf(stderr, "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, tcp).\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_TCP)) {
(void)fprintf(stderr, "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, tcp).\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_TCP)) {
(void)fprintf(stderr, "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, tcp).\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
svc_run();
(void)fprintf(stderr, "svc_run returned\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
#ifdef MULTITHREAD
struct call_params {
struct svc_req *rqstp;
SVCXPRT *transp;
void *arg;
char *(*local)();
bool_t (*xdr_argument)(), (*xdr_result)();
};
static void device_async_1_a ();
#endif
static void
device_async_1(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
{
union {
Device_Link device_abort_1_arg;
} argument;
char *result;
bool_t (*xdr_argument)(), (*xdr_result)();
char *(*local)();
#ifdef MULTITHREAD
DWORD TID = 0;
HANDLE threadHandle = NULL;
struct call_params *params;
#endif
switch (rqstp->rq_proc) {
case NULLPROC:
(void)svc_sendreply(transp, xdr_void, (char *)NULL);
return;
case device_abort:
xdr_argument = xdr_Device_Link;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_abort_1;
break;
default:
svcerr_noproc(transp);
return;
}
bzero((char *)&argument, sizeof(argument));
if (!svc_getargs(transp, xdr_argument, &argument)) {
svcerr_decode(transp);
return;
}
#ifdef MULTITHREAD
params = (struct call_params*) malloc (sizeof(struct call_params));
params->rqstp = (struct svc_req*) malloc (sizeof(struct svc_req));
bcopy(rqstp, params->rqstp, sizeof(struct svc_req));
params->transp = transp;
params->arg = malloc (sizeof(argument));
bcopy(&argument, params->arg, sizeof(argument));
params->local = local;
params->xdr_argument = xdr_argument;
params->xdr_result = xdr_result;
threadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)device_async_1_a, params, 0, &TID);
if (!threadHandle)
device_async_1_a(¶ms);
}
static void
device_async_1_a(params)
struct call_params *params;
{
struct svc_req *rqstp;
SVCXPRT *transp;
void *argument;
void (*destroy_proc)();
char *result;
bool_t (*xdr_argument)(), (*xdr_result)();
char *(*local)();
argument = params->arg;
rqstp = params->rqstp;
transp = params->transp;
xdr_argument = params->xdr_argument;
xdr_result = params->xdr_result;
local = params->local;
destroy_proc = transp->xp_ops->xp_destroy;
transp->xp_ops->xp_destroy = xprt_unregister;
#endif
result = (*local)(&argument, rqstp);
if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
svcerr_systemerr(transp);
}
#ifdef MULTITHREAD
free(params->rqstp);
free(params);
#endif
if (!svc_freeargs(transp, xdr_argument, &argument)) {
(void)fprintf(stderr, "unable to free arguments\n");
#ifdef WIN32
rpc_nt_exit();
#endif
exit(1);
}
#ifdef MULTITHREAD
free(argument);
transp->xp_ops->xp_destroy = destroy_proc;
#endif
}
#ifdef MULTITHREAD
struct call_params {
struct svc_req *rqstp;
SVCXPRT *transp;
void *arg;
char *(*local)();
bool_t (*xdr_argument)(), (*xdr_result)();
};
static void device_core_1_a ();
#endif
static void
device_core_1(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
{
union {
Create_LinkParms create_link_1_arg;
Device_WriteParms device_write_1_arg;
Device_ReadParms device_read_1_arg;
Device_GenericParms device_readstb_1_arg;
Device_GenericParms device_trigger_1_arg;
Device_GenericParms device_clear_1_arg;
Device_GenericParms device_remote_1_arg;
Device_GenericParms device_local_1_arg;
Device_LockParms device_lock_1_arg;
Device_Link device_unlock_1_arg;
Device_EnableSrqParms device_enable_srq_1_arg;
Device_DocmdParms device_docmd_1_arg;
Device_Link destroy_link_1_arg;
Device_RemoteFunc create_intr_chan_1_arg;
} argument;
char *result;
bool_t (*xdr_argument)(), (*xdr_result)();
char *(*local)();
#ifdef MULTITHREAD
DWORD TID = 0;
HANDLE threadHandle = NULL;
struct call_params *params;
#endif
switch (rqstp->rq_proc) {
case NULLPROC:
(void)svc_sendreply(transp, xdr_void, (char *)NULL);
return;
case create_link:
xdr_argument = xdr_Create_LinkParms;
xdr_result = xdr_Create_LinkResp;
local = (char *(*)()) create_link_1;
break;
case device_write:
xdr_argument = xdr_Device_WriteParms;
xdr_result = xdr_Device_WriteResp;
local = (char *(*)()) device_write_1;
break;
case device_read:
xdr_argument = xdr_Device_ReadParms;
xdr_result = xdr_Device_ReadResp;
local = (char *(*)()) device_read_1;
break;
case device_readstb:
xdr_argument = xdr_Device_GenericParms;
xdr_result = xdr_Device_ReadStbResp;
local = (char *(*)()) device_readstb_1;
break;
case device_trigger:
xdr_argument = xdr_Device_GenericParms;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_trigger_1;
break;
case device_clear:
xdr_argument = xdr_Device_GenericParms;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_clear_1;
break;
case device_remote:
xdr_argument = xdr_Device_GenericParms;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_remote_1;
break;
case device_local:
xdr_argument = xdr_Device_GenericParms;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_local_1;
break;
case device_lock:
xdr_argument = xdr_Device_LockParms;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_lock_1;
break;
case device_unlock:
xdr_argument = xdr_Device_Link;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_unlock_1;
break;
case device_enable_srq:
xdr_argument = xdr_Device_EnableSrqParms;
xdr_result = xdr_Device_Error;
local = (char *(*)()) device_enable_srq_1;
break;
case device_docmd:
xdr_argument = xdr_Device_DocmdParms;
xdr_result = xdr_Device_DocmdResp;
local = (char *(*)()) device_docmd_1;
break;
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
windows下vxi11实现示例代码,用于实现仪器的远程发现,远程控制。作为VXI协议族的一部分,VXI-11协议用于解决控制计算机与仪器间通过TCP/IP网络通信的问题。它用于实现仪器间数据传输的核心通道、异常通道以及中断通道,通过发送指令获得仪器的IP地址、仪器名称等标志性信息,并建立控制计算机与仪器间的通信连接。
资源推荐
资源详情
资源评论
收起资源包目录
oncrpc_vxi11_test.rar (63个子文件)
oncrpc_vxi11_test
vxi11_proj
vxi11_proj.sln 1KB
Debug
vxi11_client.exp 921B
vxi11_client.ilk 300KB
oncrpc.dll 587KB
vxi11_server.ilk 321KB
vxi11_server.pdb 748KB
vxi11_server.lib 2KB
vxi11_client.pdb 740KB
vxi11_client.lib 2KB
vxi11_client.exe 38KB
vxi11_server.exe 43KB
vxi11_server.exp 921B
vxi11_server
vxi11_svc.c 13KB
Debug
vxi11_svc.obj 40KB
vxi11_xdr.obj 38KB
vc120.pdb 108KB
vxi11_server.Build.CppClean.log 1KB
vxi11_server_sif.obj 2KB
vxi11_server.log 2KB
vc120.idb 387KB
vxi11_server_srp.obj 40KB
vxi11_server.tlog
cl.command.1.tlog 4KB
vxi11_server.write.1u.tlog 3KB
CL.read.1.tlog 61KB
link.read.1.tlog 4KB
link.write.1.tlog 1KB
CL.write.1.tlog 5KB
link.command.1.tlog 2KB
vxi11_server.lastbuildstate 181B
vxi11_server.vcxproj 5KB
vxi11_server.vcxproj.filters 1KB
vxi11_server_sif.c 0B
vxi11_xdr.c 6KB
vxi11_server_srp.c 4KB
vxi11.h 9KB
vxi11_proj.v12.suo 51KB
vxi11_client
Debug
vxi11_clnt.obj 40KB
vxi11_client.log 2KB
vxi11_xdr.obj 38KB
vc120.pdb 100KB
vc120.idb 387KB
vxi11_client.obj 29KB
vxi11_client.tlog
cl.command.1.tlog 3KB
CL.read.1.tlog 61KB
link.read.1.tlog 3KB
vxi11_client.write.1u.tlog 4KB
link.write.1.tlog 932B
vxi11_client.lastbuildstate 181B
CL.write.1.tlog 2KB
link.command.1.tlog 2KB
vxi11_client.Build.CppClean.log 1KB
vxi11_client.vcxproj 5KB
vxi11_clnt.c 5KB
vxi11_client.vcxproj.user 165B
vxi11_client.vcxproj.filters 1KB
vxi11_xdr.c 6KB
vxi11.h 9KB
vxi11_client.c 2KB
vxi11_proj.sdf 27.88MB
vxi11_svc.c 13KB
vxi11_clnt.c 5KB
vxi11_xdr.c 6KB
vxi11.h 9KB
共 63 条
- 1
资源评论
- suntx1122332021-03-07代码不完整 缺文件 无法使用
ProProG
- 粉丝: 14
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功