#ifndef __ZBIND_HEADER #define __ZBIND_HEADER /*****************************************************************************/ /* */ /* Copyright 2007 ZTEC Instruments, Incorporated. All rights reserved. */ /* */ /* ZTEC Instruments ======================================================= */ /* By: ZTEC Instruments, Albuquerque, NM */ /*****************************************************************************/ #include "zerr.h" #include "ztypes.h" #ifdef _WIN32 #define _ZBIND_FUNC _ZT_FUNC __stdcall #else #define _ZBIND_FUNC #endif /*****************************************************************************/ /*= Constants ===============================================================*/ /*****************************************************************************/ #define ZBIND_MCLASS_PARAM_MAX ZT_MAX_STRLEN #define ZBIND_MCLASS_BLOCK_BUFFER 0x80800200 #define ZBIND_MCLASS_UL_BUFF_MAX_LEN 0x00010000 #define ZBIND_MCLASS_DL_BUFF_MAX_LEN 0x00800000 #define ZBIND_MCLASS_LINUX_BUFF_MAX_LEN 0x00010000 #define ZBIND_ERROR_CMD_FAIL (-200) #define ZBIND_ERROR_INVALID_CMD (-201) #define ZBIND_ERROR_INVALID_PARAM (-202) #define ZBIND_ERROR_CMD_REJECTED (-203) #define ZBIND_ERROR_TIMEOUT (-204) #define ZBIND_ERROR_INVALID_DEV (-205) /**Attributes**/ #define ZBIND_ATTR_USER_DATA (0x3FFF0007UL) #define ZBIND_ATTR_TMO_VALUE (0x3FFF001AUL) #define ZBIND_ATTR_SRC_INCREMENT (0x3FFF0040UL) #define ZBIND_ATTR_DEST_INCREMENT (0x3FFF0041UL) #define ZBIND_ATTR_RM_SESSION (0x3FFF00C4UL) #define ZBIND_ATTR_MANF_ID (0x3FFF00D9UL) #define ZBIND_ATTR_MODEL_CODE (0x3FFF00DFUL) #define ZBIND_ATTR_LAN_FIRMWARE (0xFFFF0000UL) #define ZBIND_ATTR_LAN_IPADDR (0xFFFF0001UL) #define ZBIND_ATTR_LAN_NETMASK (0xFFFF0002UL) #define ZBIND_ATTR_LAN_GATEWAY (0xFFFF0003UL) #define ZBIND_ATTR_LAN_NFS (0xFFFF0004UL) #define ZBIND_ATTR_LAN_NTP (0xFFFF0005UL) #define ZBIND_ATTR_LAN_DHCP (0xFFFF0006UL) #define ZBIND_ATTR_LAN_EPICS (0xFFFF0007UL) #define ZBIND_ATTR_LAN_MACADDR_HI (0xFFFF0008UL) #define ZBIND_ATTR_LAN_MACADDR_LO (0xFFFF0009UL) #define ZBIND_ATTR_LAN_DNS (0xFFFF000AUL) /*Attr values*/ #define ZBIND_VAL_TMO_IMMEDIATE (0L) #define ZBIND_VAL_TMO_INFINITE (0xFFFFFFFFUL) #if defined(__cplusplus) || defined(__cplusplus__) extern "C" { #endif /*===========================================================================*/ /* Function: zbind_card */ /* Purpose: This function finds the resource name of an installed z-card */ /* Parameter 1 is the location to store the string in (256 bytes). */ /* Parameter 2 is communication bus type, ex: */ /* ZT_CCLASS, ZT_MCLASS or ZT_VISA */ /* Parameter 3 is the instrument count. Send 0 to find the first */ /* card. Increment and call, repeatedly, until */ /* an error occurs to find all cards. */ /* Return value is ZT_SUCCESS when an instrument of the requested */ /* type and count is found or ZT_FAILURE if it is not found.*/ /*===========================================================================*/ ZT_ERROR _ZT_FUNC zbind_card(ZT_RSRC_NAME _resource_name, u16 *_comm_bus, u32 _count); /*===========================================================================*/ /*------- Functions to Return Information About the Instrument --------*/ /*===========================================================================*/ /*===========================================================================*/ /* Function: zbind_get_idstring */ /* Purpose: This function queries the instrument identification information.*/ /* Parameter 1 is the location to store the string in (256 bytes). */ /* Return value is ZT_SUCCESS. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_get_idstring(ZT_HANDLE dev, s8 *id_string); /*===========================================================================*/ /* Function: zbind_revision_query */ /* Purpose: This function queries the zbind revision information. */ /* Parameter 1 is the location to store the string in (256 bytes). */ /* Return value is ZT_SUCCESS. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_revision_query(s8 driver_rev[]); /*===========================================================================*/ /* Function: zbind_instr_revision_query */ /* Purpose: This function queries the instrument firmware revision. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the firmware rev in the format XX.XX */ /* Return value is ZT_SUCCESS. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_instr_revision_query(ZT_HANDLE _dev, f32 *firmware_rev); /*===========================================================================*/ /* Function: zbind_instr_handle */ /* Purpose: This function returns the instrument session used to */ /* communicate to the instrument; For VISA instruments the */ /* ViSession. */ /* Parameter 1 is the zbind device handle. */ /* Returns the instrument session. */ /*===========================================================================*/ ZT_HANDLE _ZBIND_FUNC zbind_instr_handle(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_comm_bus */ /* Purpose: This function returns the instrument communication bus */ /* Parameter 1 is the zbind device handle. */ /* Returns the communication bus type: */ /* ZT_SIM, ZT_CCLASS, ZT_MCLASS, ZT_LAN, ZT_VISA_PCI_C, */ /* ZT_VISA_PCI_M, ZT_VISA_C, ZT_VISA_M */ /*===========================================================================*/ u16 _ZBIND_FUNC zbind_comm_bus(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_model */ /* Purpose: This function returns the instrument model. */ /* Parameter 1 is the zbind device handle. */ /* Returns the model type: */ /* ZT410_INST, ZT4420_INST, ZT5410_INST, etc. */ /*===========================================================================*/ u32 _ZBIND_FUNC zbind_model(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_block_buffer_addr */ /* Purpose: This function returns address of the buffer to use for */ /* block out transfers (writes). */ /* Parameter 1 is the zbind devince handle. */ /* Returns the buffer address. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_block_buffer_addr(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_maximum_transfer_size */ /* Purpose: This function returns the maximum single bus transfer size. */ /* This function does not account for limits due to */ /* buffer sizes. */ /* Parameter 1 is the zbind device handle. */ /* Returns the maximum transfer size in bytes. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_maximum_transfer_size(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_block_buffer_size */ /* Purpose: This function returns the maximum single transfer size. */ /* The size is instrument dependent and may differ based */ /* on upload or download directions due to varying */ /* buffer sizes. */ /* This function is provided for backwards compatiblity. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 indicates if the value returned is for the upload */ /* or download buffer. */ /* Returns the buffer transfer size. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_block_buffer_size(ZT_HANDLE _dev, ZT_BOOL upload); /*===========================================================================*/ /* Function: zbind_upload_buffer_size */ /* Purpose: This function returns the upload buffer size. This is the */ /* maximum amount of data that may be written without refilling */ /* the transfer buffer. */ /* Parameter 1 is the zbind device handle. */ /* Returns the buffer size. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_upload_buffer_size(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_upload_buffer_size */ /* Purpose: This function returns the download buffer size. This is the */ /* maximum amount of data that may be read without refilling */ /* the transfer buffer. */ /* Parameter 1 is the zbind device handle. */ /* Returns the buffer size. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_download_buffer_size(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_cmd_buffer_size */ /* Purpose: This function returns the command buffer size. This is the */ /* maximum command string length. */ /* Parameter 1 is the zbind device handle. */ /* Returns the buffer size. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_cmd_buffer_size(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_rsp_buffer_size */ /* Purpose: This function returns the response buffer size. This is the */ /* maximum response string length. */ /* Parameter 1 is the zbind device handle. */ /* Returns the buffer size. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_rsp_buffer_size(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_max_param */ /* Purpose: This function returns the maximum number of parameters that can */ /* be transferred to or from the instrument. (C-Class) */ /* M-Class instruments all use ZT_MAX_STRLEN. */ /* Parameter 1 is the zbind device handle. */ /* Returns the maximum number of parameters that can be sent to or */ /* received from the instrument. */ /*===========================================================================*/ s32 _ZBIND_FUNC zbind_max_param(ZT_HANDLE _dev); /*===========================================================================*/ /*------- Functions to control locking --------*/ /*===========================================================================*/ /*===========================================================================*/ /* Function: zbind_clear */ /* Purpose: This function will clear the controller of all cached data */ /* Parameter 1 is the zbind device handle. */ /* Returns ZT_SUCCESS on clear success, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_clear(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_unlock */ /* Purpose: This function will take control of the locking with a */ /* master lock. This will override the current command lock, */ /* from zbind_holdlock, and disallow further commands until */ /* zbind_release_unlock is called. */ /* Parameter 1 is the zbind device handle. */ /* Returns ZT_SUCCESS if the lock is taken, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_unlock(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_release_unlock */ /* Purpose: This function will release control of the master lock, */ /* from zbind_unlock. */ /* Parameter 1 is the zbind device handle. */ /* Returns ZT_SUCCESS if the lock existed, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_release_unlock(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_holdlock */ /* Purpose: This function obtains a standard lock and holds it until */ /* a zbind_releaselock or a zbind_unlock occurs. */ /* Parameter 1 is the zbind device handle. */ /* Returns ZT_SUCCESS if the lock is taken, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR zbind_holdlock(ZT_HANDLE _dev); /*===========================================================================*/ /* Function: zbind_releaselock */ /* Purpose: This function releases a standard lock created from */ /* zbind_holdlock. */ /* Parameter 1 is the zbind device handle. */ /* Returns ZT_SUCCESS if the lock existed, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR zbind_releaselock(ZT_HANDLE _dev); /*===========================================================================*/ /*------- Functions to set timeout values --------*/ /*===========================================================================*/ /*===========================================================================*/ /* Function: zbind_tmo_value */ /* Purpose: This function will return the command timout. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the timout in milliseconds. */ /* Returns ZT_SUCCESS on successful communication, else ZT_FAILURE.*/ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_tmo_value(ZT_HANDLE _dev, u32 *_value); /*===========================================================================*/ /* Function: zbind_tmo_disable */ /* Purpose: This function will disable the command timout. */ /* LXI Instruments will set the timeout to 25 minutes instead. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the old timout in milliseconds */ /* Returns ZT_SUCCESS on successful communication, else ZT_FAILURE.*/ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_tmo_disable(ZT_HANDLE _dev, u32* _value); /*===========================================================================*/ /* Function: zbind_tmo_enable */ /* Purpose: This function will set the command timout. Setting a */ /* timeout value will re-enable the timeout. (Error code -204 */ /* maybe indicate that the timeout duration is too short). */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the timout in milliseconds. */ /* Returns ZT_SUCCESS on successful communication, else ZT_FAILURE.*/ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_tmo_enable(ZT_HANDLE _dev, u32 _value); /*===========================================================================*/ /*------- Functions to Manage Devices --------*/ /*===========================================================================*/ /*===========================================================================*/ /* Function: zbind_add */ /* Purpose: This function will create a binding handle for the instrument */ /* found at the _resource_name address. This creates a zbind */ /* structure that is used to map the instrument to the correct */ /* low-level calls and obtains a communication session. */ /* Parameter 1 is the resource name, ex: */ /* "VXI0:1:INSTR" or "TCPIP::192.168.0.1:3030::INSTR" */ /* Parameter 2 is the communication bus type, ex: */ /* ZT_CCLASS, ZT_MCLASS or ZT_VISA */ /* Parameter 2 is the zbind handle that is used to identify */ /* the instrument command mapping and communication session. */ /* Returns ZT_SUCCESS on successful addition & communication, */ /* else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_add(ZT_RSRC_NAME _resource_name, u16 _comm_bus, ZT_HANDLE *_dev); /*===========================================================================*/ /* Function: zbind_kill_add_semaphore */ /* Purpose: This function will remove the add semaphore. The add semaphore */ /* is opened during zbind_add or zbind_remove calls and this */ /* function should be called when killing an add or remove */ /* operation. */ /*===========================================================================*/ void _ZBIND_FUNC zbind_kill_add_semaphore(void); /*===========================================================================*/ /* Function: zbind_retrieve */ /* Purpose: This function will return a current open binding for a device */ /* that has already been bound using zbind_add. */ /* Parameter 1 is the resource name, ex: */ /* "VXI0:1:INSTR" or "TCPIP::192.168.0.1:3030::INSTR" */ /* Parameter 2 is the zbind handle that is used to identify */ /* the instrument command mapping and communication session. */ /* Returns ZT_SUCCESS if binding is found, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_retrieve(ZT_RSRC_NAME _resource_name, ZT_HANDLE *_dev); /*===========================================================================*/ /* Function: zbind_remove */ /* Purpose: This function will remove a current open binding for a device */ /* that has already been bound using zbind_add. */ /* timeout value will re-enable the timeout. */ /* Parameter 1 is the zbind handle that is used to identify */ /* the instrument command mapping and communication session. */ /* Returns ZT_SUCCESS if binding is removed, else ZT_FAILURE. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_remove(ZT_HANDLE *_dev); /*===========================================================================*/ /*------- Functions to Communicate with the Instrument --------*/ /*===========================================================================*/ /*===========================================================================*/ /* Function: zbind_setattribute */ /* Purpose: This function will set a specific attribute value. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the attribute to be set. */ /* Parameter 3 is the value the attribute will be set to. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_setattribute(ZT_HANDLE _dev, u32 _attribute, u32 _value); /*===========================================================================*/ /* Function: zbind_getattribute */ /* Purpose: This function will query a specific attribute value. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the attribute to check. */ /* Parameter 3 is the value of the attribute. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_getattribute(ZT_HANDLE _dev, u32 _attribute, u32 *_value); /*===========================================================================*/ /* Function: zbind_blkin */ /* Purpose: This function gets a block of data from the instrument */ /* to the pc. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the offset from the base instrument buffer */ /* address. */ /* Parameter 3 is number of bytes to be transfered. */ /* Parameter 4 is data to be transfered. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_blkin(ZT_HANDLE _dev, u32 _offset, u32 _byte_cnt, void *_data); /*===========================================================================*/ /* Function: zbind_blkout */ /* Purpose: This function sends a block of data from the pc to the */ /* instrument. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the offset from the base instrument buffer */ /* address. */ /* Parameter 3 is number of bytes to be transfered. */ /* Parameter 4 is data to be transfered. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_blkout(ZT_HANDLE _dev, u32 _offset, u32 _byte_cnt, void *_data); /*===========================================================================*/ /* Function: zbind_strin */ /* Purpose: This function returns a response string from the instrument. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the command string. */ /* Parameter 3 is number of bytes to be transfered. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_strin(ZT_HANDLE _dev, s8 *_command, u32 _byte_cnt); /*===========================================================================*/ /* Function: zbind_strout */ /* Purpose: This function sends a command string to the instrument. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the command string. */ /* Parameter 3 is number of bytes to be transfered. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_strout(ZT_HANDLE _dev, s8 *_buffer, u32 _byte_cnt); /*===========================================================================*/ /* Function: zbind_send */ /* Purpose: This function sends a command string to the instrument with */ /* optional locking and string formatting. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the lock state. ZT_TRUE will lock subsequent */ /* commands until a zbind_receive or zbind_releaselock occurs. */ /* Parameter 3 is the format string. This should be in standard */ /* formatting, using string conversion specifications. */ /* The format string defines whether additional parameters */ /* are used. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_send(ZT_HANDLE _dev, ZT_BOOL _lock, s8 _format_str[], ...); /*===========================================================================*/ /* Function: zbind_abort */ /* Purpose: This function sends a command string to the instrument by */ /* forcing an unlock of any current communication. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 3 is the format string. This should be in standard */ /* formatting, using string conversion specifications. */ /* The format string defines whether additional parameters */ /* are used. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_abort(ZT_HANDLE _dev, s8 _format_str[], ...); /*===========================================================================*/ /* Function: zbind_receive */ /* Purpose: This function returns a response string from the instrument */ /* with optional locking and string formatting. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the lock state. ZT_TRUE will unlock a current */ /* lock, ZT_FALSE will only call the instrument if it is not */ /* currently locked. */ /* Parameter 3 is the format string. This should be in standard */ /* formatting, using string conversion specifications. */ /* The format string defines whether additional parameters */ /* are used. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_receive(ZT_HANDLE _dev, ZT_BOOL _unlock, s8 _format_str[], ...); /*===========================================================================*/ /* Function: zbind_write_reg */ /* Purpose: This function writes a 16 bit word to the instrument. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the offset from the base instrument buffer */ /* address. */ /* Parameter 3 is data to be transfered. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_write_reg(ZT_HANDLE _dev, u16 _address, u16 _data); /*===========================================================================*/ /* Function: zbind_read_reg */ /* Purpose: This function reads a 16 bit word from the instrument. */ /* Parameter 1 is the zbind device handle. */ /* Parameter 2 is the offset from the base instrument buffer */ /* address. */ /* Parameter 3 is data to be transfered. */ /* Returns the status of the instrument communication. */ /*===========================================================================*/ ZT_ERROR _ZBIND_FUNC zbind_read_reg(ZT_HANDLE _dev, u16 _address, u16 *_data); /*===========================================================================*/ /* Function: zbind_error_description */ /* Purpose: This function returns a string description of an error code */ /* Parameter 1 is the ZTEC error code */ /* Parameter 2 is the returned code description */ /*===========================================================================*/ void _ZBIND_FUNC zbind_error_description (s32 code, s8 description[]); #if defined(__cplusplus) || defined(__cplusplus__) } #endif /*****************************************************************************/ /*=== END INCLUDE FILE ======================================================*/ /*****************************************************************************/ #endif