APSIN x000 API Description

Similar documents
10. I/O System Library

Fundamentals of Programming Session 8

ControlLogix Multi-Vendor Interface Module DH-485 API

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

Linked-List Basic Examples. A linked-list is Linear collection of self-referential class objects, called nodes Connected by pointer links

AMCAT Automata Coding Sample Questions And Answers

This Document describes the API provided by the DVB-Multicast-Client library

Stream Model of I/O. Basic I/O in C

µroar Manual Philipp ph3-der-loewe Schafft

7/21/ FILE INPUT / OUTPUT. Dong-Chul Kim BioMeCIS UTA

Application Programming Interfaces

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

PSK Propagation Reporter DLL Documentation 2013-Mar-10 Philip Gladstone

UDP CONNECT TO A SERVER

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

Kea Messages Manual. Kea Messages Manual

Grove Analog Moisture Sensor on BeagleBone Guide

What s an API? Do we need standardization?

Discussion 6. HW4 and Libraries

Licence API. User guide. MAN1016 Revision 4.1.0

Variation of Pointers

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008

Cisco Terminal Services (TS) Agent Guide, Version 1.1

Cisco Terminal Services (TS) Agent Guide, Version 1.1

ESC101N: Fundamentals of Computing End-sem st semester

#include <tobii/tobii.h> char const* tobii_error_message( tobii_error_t error );

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

M.CS201 Programming language

Project 2: Shell with History1

Ethernet TCP/IP component programming guide

µtasker Document µtasker Multicasting and Internet Group Management Protocol (IGMP)

Network Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions

Unit 4. Input/Output Functions

USB-910H API DLL and Include File Reference Manual

Slides adopted from T. Ferguson Spring 2016

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

(T) x. Casts. A cast converts the value held in variable x to type T

Advanced C Programming Topics

Copper Mountain Technologies ACM8000T and ACM6000T. SCPI Programming Manual Revision 1

Lecture 3. Review. CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions. Conditions: Loops: if( ) / else switch

Programming. Data Structure

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

Standard File Pointers

BIt Systems Market & Clearing API. Market Application Programming Interface C language GK-API

Error num: 1 Meaning: Not owner Error num: 2 Meaning: No such file or directory Error num: 3 Meaning: No such process Error num: 4 Meaning:

libnetfilter_log Reference Manual

ECE264 Fall 2013 Exam 3, November 20, 2013

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017

Cisco Terminal Services (TS) Agent Guide, Version 1.0

ESC101N Fundamentals of Computing

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Keysight N9342C/43C/44C Handheld Spectrum Analyzer

The Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4

// socket for establishing connections

CS240: Programming in C

The TCP Protocol Stack

Contents. A Review of C language. Visual C Visual C++ 6.0

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

Frame Transmission. Frames are transmitted using physical addresses within a network. N Z : network address (same scheme globally) ß R2,N R2 ß B,N B

Structures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures

MATLAB SON Library. Malcolm Lidierth King's College London Updated October 2005 (version 2.0)

Programming Language B

The User Datagram Protocol

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files

Singly linked lists in C.

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

CSCE 463/612 Networks and Distributed Processing Spring 2017

µtasker Document µtasker MQTT/MQTTS

Computer Systems Lecture 9

Introduction to Programming

AET60 API version 1.4 February Introduction...3 Features...3 Application Programming Interface...4

Experiment 6 The Real World Interface

Tutorial 1: C-Language

Question Score 1 / 19 2 / 19 3 / 16 4 / 29 5 / 17 Total / 100

TDRV006-SW-42. VxWorks Device Driver. 64 Digital Inputs/Outputs (Bit I/O) Version 4.0.x. User Manual. Issue December 2017

GIVE W INGS TO YOUR IDEAS

Introduction to C Language

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

Functions. Systems Programming Concepts

Dynamic Memory Allocation

CMSC 104 -Lecture 11 John Y. Park, adapted by C Grasso

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

QVS Distributed Data Services/Controller Services for Windows. Programming Guide. Version 3

6Using the Install and. Licensing APIs 6CHAPTER

Socket programming in C

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.

HIGH LEVEL FILE PROCESSING

AET60 BioCARDKey. Application Programming Interface. Subject to change without prior notice

IBM Content Manager for iseries. Messages and Codes. Version 5.1 SC

COS 318: Operating Systems. Message Passing. Kai Li and Andy Bavier Computer Science Department Princeton University

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

To obtain the current global trace mask, call meitraceget(...). To modify the global trace mask, call meitraceset(...).

Choice 1: audio, a simple audio client server system

BUFFER OVERFLOW. Jo, Heeseung

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Buffer Overflow. Jo, Heeseung

Transcription:

APSIN x000 API Description Contents 1. Introduction to the...2 2. Application Programming Interface...3 3. Accessing the DLL with Matlab...7 4. An C example program using the DLL...8 Company Details...10 Page 1 of 10

1. Introduction to the AnaPico allows customer access to Instrument DLLs for use with alternate interface and control programs. The AnaPico apsinx000.dll allows direct access to the APSIN product family through any software that can call a standard C. Page 2 of 10

2. Application Programming Interface The AnaPico application programming interface (API) consists of the following files: Apsin3000_lib.h Apsin3000_lib.lib Apsin3000_lib.dll The header file defines the following constants: #define VI_SUCCESS 0x00000000 // Operation completed ly #define VI_SUCCESS_MAX_CNT 0x3FFF0006 // Number of bytes read is equal to the input count #define VI_ERROR_SYSTEM_ERROR 0xBFFF0000 // Unknown system error #define VI_ERROR_TMO 0xBFFF0015 // Timeout expired before operation completed #define VI_ERROR_CONN_LOST 0xBFFF00A6 // Connection for the given session has been lost #define VI_ERROR_FILE_ACCESS 0xBFFF00A1 // Error occurred while trying to open the specified file. // Possible reasons include an invalid path or lack of access rights The library provides the following commands: apsin_find int apsin_find( char* devices, unsigned int tmo, int count, int *retcount ) Locates devices in the same LAN subnet (sends broadcast message) and writes information about the located devices into *devices. devices: tmo: count: retcount: pointer to a buffer for the found devices string. search timeout, in ms size of the supplied buffer, in bytes pointer, returning the number of bytes written into the devices buffer, excluding the NULL-termination. Can be NULL. Return Values: VI_ERROR_SYSTEM_ERROR: socket allocation failed The returned devices string will be formatted as follows: "Instr Name:Serial No:IPv4 Addr;Instr Name:Serial No:IPv4 Addr;..." Page 3 of 10

Each valid device will be identified with the instrument name, the instrument s serial number, and the IPv4 adress. The individual devices are separated with a ; (semicolon). If no devices were found, the buffer will be an empty string "" and retcount will be 0. Example: char buf[512]; int retcount; apsin_find( buf, 2000, 512, &retcount ); printf( buf ); will wait 2 seconds for devices to react on a broadcast call. If 3 devices were found, the output could be: "INSTR0:31132200000016:192.168.1.55;INSTR0:61132200000049:192.168.1.49;INST R0:62232211000003:192.168.1.46;" apsin_sock_open int apsin_sock_open( char* ipaddr, int port, unsigned int tmo, int* sock_id ) Opens a TCP socket connection to the specified IPv4 address and port. ipaddr: IPv4 address string (e.g. "192.168.1.50"). port: TCP port, default is 18. tmo: connection timeout in ms, usually >= 1000. sock_id: pointer, returning the unique socket ID. Return Values: VI_ERROR_SYSTEM_ERROR: socket allocation failed, connection refused by device, or no device listening at specified address. Description: Opens a TCP socket connection to the specified IPv4 address and port. The connection will be up until apsin_sock_close() is called. After opening, calling apsin_sock_close() is mandatory before exiting the program. apsin_sock_close int apsin_sock_close( int sock_id ) Close a TCP socket connection. sock_id: unique socket ID Return Values: VI_ERROR_SYSTEM_ERROR: invalid socket ID (no socket connection) Page 4 of 10

apsin_sock_clear int apsin_sock_clear( int sock_id ) Clears the socket receive buffer. sock_id: unique socket ID Return Values: VI_ERROR_SYSTEM_ERROR: invalid socket ID (no socket connection) apsin_sock_gets int apsin_sock_gets( int sock_id, char* buf, int count, int *retcount ) Receive a string from a device. sock_id: buf: count: retcount: unique socket ID pointer to the buffer for the string received from the device buffer size, in bytes pointer, returning number of received bytes, can be NULL Return values: VI_SUCCESS_MAX_CNT: VI_ERROR_CONN_LOST: response string is too long for the supplied buffer. Only count characters were stored in the buffer, and the buffer is not NULL-terminated. The remaining characters can be read by calling the function again. Connection lost, nothing was received Description: Use this function to receive requested data information from the APSIN. apsin_sock_puts int apsin_sock_puts( int sock_id, char* buf, int count, int *retcount ) Sends a string to a device. sock_id: buf: count: unique socket ID string being sent to the device string length, can be 0 if string is terminated with NULL or line feed '\n' retcount: pointer, returning number of sent bytes, can be 0 Return values: Page 5 of 10

VI_SUCCESS_MAX_CNT: VI_ERROR_CONN_LOST: String is too long. Only the first 1024 characters were sent. The remaining characters must be sent again. No termination character was sent. Connection lost, nothing was sent Description: Send a string to a device. The string will be terminated according to the SCPI rules. NULL or "\r\n" (carriage-return line-feed) will be replaced with "\n". Data located after those termination characters will be ignored. If the string contains no termination character, the function will terminate the string with '\n' after count characters. Up to 1024 characters can be sent, including the string terminator. Page 6 of 10

3. Accessing the DLL with Matlab The commands used in Matlab to access DLLs are as follows: Loadlibrary Unloadlibrary Libisloaded Calllib Loads a dll Unloads a dll Checks to see if a library is loaded Calls a loaded dll function To open the apsin3000_lib.dll, the following code sequence is used: if libisloaded('apsin3000')==1, disp(' apsin3000 library is Loaded'); end if libisloaded('apsin3000 ')==0, disp('loading Library...'); loadlibrary apsin3000_lib.dll apsin3000_lib.h alias apsin3000 loadlibrary('apsin3000_lib.lib','apsin3000_lib.h'); ipaddr = '192.168.1.50'; socket_id = calllib( 'apsin3000', 'apsin_sock_open', libpointer('cstring',ipaddr), size(ipaddr,2), 18, 0 ); pause(1); if (sock_id < 0) ( size(ipaddr,2) < 4 ) fprintf(1,'\n Unable to connect, quitting.\nplease verify LAN connection...\n'); return end disp('connection is established ); end The libisloaded command checks to verify if the library has already been loaded. Therefore, this section of code can always be put in front of other commands rather than having to include separate scripts. The loadlibrary command loads a DLL and the associated header. This command and header must be in the Matlab working directory or in a path that will Matlab recognize. Note that the name of the DLL can be aliased. In the above code, it has been aliased to apsin3000. The calllib function calls out a function that is listed in the header and contained within the DLL. The apsin_sock_open function is used here to open communications with the apsin3000. Note that the IP number of the device must be used to call the device and it is sent as a string. We use an IP 192.168.1.50 in the above example. While using the apsin_sock_open function, a 0 is returned if, a <0 if un. Page 7 of 10

4. An C example program using the DLL #include <stdio.h> #include <stdlib.h> #include "apsin3000_lib.h" // APSIN communication library #define DEV_STR_LEN 512 #define TCP_PORT 18 // device communication buffer size // TCP port for socket connection int main() { char buf[dev_str_len]; char ipaddr[32]; int retcount, sock_id; /************************************************************************** * Open connection to device (to known IP address) **************************************************************************/ printf( "Enter IP: " ); scanf( "%s", ipaddr ); printf( "\nopening connection to %s on port %d\n", ipaddr, TCP_PORT ); if ( apsin_sock_open( ipaddr, TCP_PORT, 1000, &sock_id )!= 0 ) { printf( " opening connection failed - enter to quit\n" ); getchar(); return -1; } /************************************************************************** * Communicate with device - commands and queries **************************************************************************/ printf( "\nsending command: FREQ 1000000\n" ); apsin_sock_puts( sock_id, "FREQ 1000000\n", 0, NULL ); printf( "\nsending command: POW 0\n" ); apsin_sock_puts( sock_id, "POW 0\n", 0, NULL ); printf( "\nsending command: OUTP ON\n" ); apsin_sock_puts( sock_id, "OUTP ON\n", 0, NULL ); printf( "\nsending query: *IDN?\n" ); apsin_sock_puts( sock_id, "*IDN?\n", 0, NULL ); buf[0] = '\0'; apsin_sock_gets( sock_id, buf, DEV_STR_LEN, NULL ); printf( " query response: %s", buf ); /************************************************************************** Page 8 of 10

* Close connection **************************************************************************/ printf( "\nclosing connection - enter to quit\n" ); apsin_sock_close( sock_id ); getchar(); } return 0; Page 9 of 10

Company Details Address: Technoparkstr. 1 8005 Zurich Switzerland Phone: +41 (44) 440 00 51 Fax: +41 (44) 440 00 50 Email: Technical Support: support@anapico.com Sales: sales@anapico.com Web site: Page 10 of 10