Exemplo n.º 1
0
static int scpi_vxi_open(void *priv)
{
	struct scpi_vxi *vxi = priv;
	Create_LinkParms link_parms;
	Create_LinkResp *link_resp;

	vxi->client = clnt_create(vxi->address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
	if (vxi->client == NULL) {
		sr_err("Client creation failed for %s", vxi->address);
		return SR_ERR;
	}

	/* Set link parameters */
	link_parms.clientId = (long) vxi->client;
	link_parms.lockDevice = 0;
	link_parms.lock_timeout = VXI_DEFAULT_TIMEOUT;
	link_parms.device = "inst0";

	if (!(link_resp = create_link_1(&link_parms, vxi->client))) {
		sr_err("Link creation failed for %s", vxi->address);
		return SR_ERR;
	}
	vxi->link = link_resp->lid;
	vxi->max_send_size = link_resp->maxRecvSize;

	/* Set a default maxRecvSize for devices which do not specify it */
	if (vxi->max_send_size <= 0)
		vxi->max_send_size = 4096;

	return SR_OK;
}
Exemplo n.º 2
0
int	vxi11_open_link_client(const char *inputip, CLIENT **client, VXI11_LINK **link, char *device) {

Create_LinkParms link_parms;
#ifdef __APPLE__
	char ip[strlen(inputip)];
	strcpy(ip, inputip);
#else
	const char *ip = inputip;
#endif

	/* Set link parameters */
	link_parms.clientId	= (long) *client;
	link_parms.lockDevice	= 0;
	link_parms.lock_timeout	= VXI11_DEFAULT_TIMEOUT;
	link_parms.device	= device;

	*link = (Create_LinkResp *) calloc(1, sizeof(Create_LinkResp));

#ifdef __APPLE__
	Create_LinkResp * tmp;
	if ((tmp = create_link_1(&link_parms, *client)) == NULL) {
#else
	if (create_link_1(&link_parms, *link, *client) != RPC_SUCCESS) {
#endif
		clnt_perror(*client, ip);
		return -2;
		}
#ifdef __APPLE__
	memcpy(*link, tmp, sizeof(*tmp));
#endif
	return 0;
	}


/* CLOSE FUNCTIONS *
 * =============== */
int	vxi11_close_device_client(const char *ip, CLIENT *client, VXI11_LINK *link) {
int	ret;

	ret = vxi11_close_link_client(ip, client, link);

	clnt_destroy(client);

	return ret;
	}
Exemplo n.º 3
0
int vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device) {
  
  Create_LinkParms link_parms;
  
  /* Set link parameters */
  link_parms.clientId	= (long) *client;
  link_parms.lockDevice	= 0;
  link_parms.lock_timeout	= VXI11_DEFAULT_TIMEOUT;
  link_parms.device	= device;
  
  *link = (Create_LinkResp *) calloc(1, sizeof(Create_LinkResp));
  
  if (create_link_1(&link_parms, *link, *client) != RPC_SUCCESS) {
#ifdef darwin
    clnt_perror(*client, (char*)ip);
#else
    clnt_perror(*client, ip);
#endif
    return -2;
  }
  return 0;
}
Exemplo n.º 4
0
static int _vxi11_open_link(VXI11_CLINK * clink, const char *address,
			    char *device)
{
#ifndef WIN32
	Create_LinkParms link_parms;

	/* Set link parameters */
	link_parms.clientId = (long)clink->client;
	link_parms.lockDevice = 0;
	link_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
	link_parms.device = device;

	clink->link = (Create_LinkResp *) calloc(1, sizeof(Create_LinkResp));

	if (create_link_1(&link_parms, clink->link, clink->client) !=
	    RPC_SUCCESS) {
		clnt_perror(clink->client, address);
		return -2;
	}
#endif
	return 0;
}
Exemplo n.º 5
0
void
device_core_1(char *host)
{
	CLIENT *clnt;
	Create_LinkResp  *result_1;
	Create_LinkParms  create_link_1_arg;
	Device_WriteResp  *result_2;
	Device_WriteParms  device_write_1_arg;
	Device_ReadResp  *result_3;
	Device_ReadParms  device_read_1_arg;
	Device_ReadStbResp  *result_4;
	Device_GenericParms  device_readstb_1_arg;
	Device_Error  *result_5;
	Device_GenericParms  device_trigger_1_arg;
	Device_Error  *result_6;
	Device_GenericParms  device_clear_1_arg;
	Device_Error  *result_7;
	Device_GenericParms  device_remote_1_arg;
	Device_Error  *result_8;
	Device_GenericParms  device_local_1_arg;
	Device_Error  *result_9;
	Device_LockParms  device_lock_1_arg;
	Device_Error  *result_10;
	Device_Link  device_unlock_1_arg;
	Device_Error  *result_11;
	Device_EnableSrqParms  device_enable_srq_1_arg;
	Device_DocmdResp  *result_12;
	Device_DocmdParms  device_docmd_1_arg;
	Device_Error  *result_13;
	Device_Link  destroy_link_1_arg;
	Device_Error  *result_14;
	Device_RemoteFunc  create_intr_chan_1_arg;
	Device_Error  *result_15;
	char *destroy_intr_chan_1_arg;

#ifndef	DEBUG
	clnt = clnt_create (host, DEVICE_CORE, DEVICE_CORE_VERSION, "udp");
	if (clnt == NULL) {
		clnt_pcreateerror (host);
		exit (1);
	}
#endif	/* DEBUG */

	result_1 = create_link_1(&create_link_1_arg, clnt);
	if (result_1 == (Create_LinkResp *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_2 = device_write_1(&device_write_1_arg, clnt);
	if (result_2 == (Device_WriteResp *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_3 = device_read_1(&device_read_1_arg, clnt);
	if (result_3 == (Device_ReadResp *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_4 = device_readstb_1(&device_readstb_1_arg, clnt);
	if (result_4 == (Device_ReadStbResp *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_5 = device_trigger_1(&device_trigger_1_arg, clnt);
	if (result_5 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_6 = device_clear_1(&device_clear_1_arg, clnt);
	if (result_6 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_7 = device_remote_1(&device_remote_1_arg, clnt);
	if (result_7 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_8 = device_local_1(&device_local_1_arg, clnt);
	if (result_8 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_9 = device_lock_1(&device_lock_1_arg, clnt);
	if (result_9 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_10 = device_unlock_1(&device_unlock_1_arg, clnt);
	if (result_10 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_11 = device_enable_srq_1(&device_enable_srq_1_arg, clnt);
	if (result_11 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_12 = device_docmd_1(&device_docmd_1_arg, clnt);
	if (result_12 == (Device_DocmdResp *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_13 = destroy_link_1(&destroy_link_1_arg, clnt);
	if (result_13 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_14 = create_intr_chan_1(&create_intr_chan_1_arg, clnt);
	if (result_14 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
	result_15 = destroy_intr_chan_1((void*)&destroy_intr_chan_1_arg, clnt);
	if (result_15 == (Device_Error *) NULL) {
		clnt_perror (clnt, "call failed");
	}
#ifndef	DEBUG
	clnt_destroy (clnt);
#endif	 /* DEBUG */
}