instrument-control-0.4.0/0000755000000000000000000000000013460206417013572 5ustar0000000000000000instrument-control-0.4.0/COPYING0000644000000000000000000001037613460206417014634 0ustar0000000000000000devel/testtcp.m GPLv3+ inst/clrdevice.m GPLv3+ inst/instrhwinfo.m GPLv3+ inst/@octave_gpib/fclose.m GPLv3+ inst/@octave_gpib/fopen.m GPLv3+ inst/@octave_gpib/fprintf.m GPLv3+ inst/@octave_gpib/fscanf.m GPLv3+ inst/@octave_gpib/fwrite.m GPLv3+ inst/@octave_i2c/fclose.m GPLv3+ inst/@octave_i2c/fopen.m GPLv3+ inst/@octave_serial/fclose.m GPLv3+ inst/@octave_serial/fopen.m GPLv3+ inst/@octave_serial/get.m GPLv3+ inst/@octave_serial/set.m GPLv3+ inst/@octave_serial/srl_baudrate.m GPLv3+ inst/@octave_serial/srl_bytesize.m GPLv3+ inst/@octave_serial/srl_close.m GPLv3+ inst/@octave_serial/srl_flush.m GPLv3+ inst/@octave_serial/srl_parity.m GPLv3+ inst/@octave_serial/srl_stopbits.m GPLv3+ inst/@octave_serial/srl_timeout.m GPLv3+ inst/@octave_tcpip/fclose.m GPLv3+ inst/@octave_tcpip/fopen.m GPLv3+ inst/@octave_udp/fclose.m GPLv3+ inst/@octave_udp/fopen.m GPLv3+ inst/@octave_udp/fprintf.m GPLv3+ inst/@octave_udp/fread.m GPLv3+ inst/@octave_udp/fwrite.m GPLv3+ inst/@octave_udp/get.m GPLv3+ inst/@octave_udp/set.m GPLv3+ inst/@octave_usbtmc/fclose.m GPLv3+ inst/@octave_usbtmc/fopen.m GPLv3+ inst/@octave_vxi11/fclose.m GPLv3+ inst/@octave_vxi11/fopen.m GPLv3+ inst/spoll.m GPLv3+ inst/trigger.m GPLv3+ inst/udp_demo.m GPLv3+ src/gpib/gpib.cc GPLv3+ src/gpib/gpib_class.cc GPLv3+ src/gpib/gpib_class.h GPLv3+ src/gpib/gpib_close.cc GPLv3+ src/gpib/__gpib_clrdevice__.cc GPLv3+ src/gpib/gpib_read.cc GPLv3+ src/gpib/__gpib_spoll__.cc GPLv3+ src/gpib/gpib_timeout.cc GPLv3+ src/gpib/__gpib_trigger__.cc GPLv3+ src/gpib/gpib_write.cc GPLv3+ src/i2c/i2c_addr.cc GPLv3+ src/i2c/i2c.cc GPLv3+ src/i2c/i2c_class.cc GPLv3+ src/i2c/i2c_class.h GPLv3+ src/i2c/i2c_close.cc GPLv3+ src/i2c/i2c_read.cc GPLv3+ src/i2c/i2c_write.cc GPLv3+ src/parallel/parallel.cc GPLv3+ src/parallel/parallel_class.cc GPLv3+ src/parallel/parallel_class.h GPLv3+ src/parallel/pp_close.cc GPLv3+ src/parallel/pp_ctrl.cc GPLv3+ src/parallel/pp_data.cc GPLv3+ src/parallel/pp_datadir.cc GPLv3+ src/parallel/pp_stat.cc GPLv3+ src/resolvehost/resolvehost.cc GPLv3+ src/serial/serial.cc GPLv3+ src/serial/serial_class.h GPLv3+ src/serial/serial_class_lin.cc GPLv3+ src/serial/serial_class_lin.h GPLv3+ src/serial/serial_class_win32.cc GPLv3+ src/serial/serial_class_win32.h GPLv3+ src/serial/__srl_properties__.cc GPLv3+ src/serial/srl_read.cc GPLv3+ src/serial/srl_write.cc GPLv3+ src/octave-wrappers.h.in GPLv3+ src/tcp/tcp.cc GPLv3+ src/tcp/tcp_class.cc GPLv3+ src/tcp/tcp_class.h GPLv3+ src/tcp/tcp_close.cc GPLv3+ src/tcp/tcp_read.cc GPLv3+ src/tcp/tcp_timeout.cc GPLv3+ src/tcp/tcp_write.cc GPLv3+ src/udp/__udp_properties__.cc GPLv3+ src/udp/udp.cc GPLv3+ src/udp/udp_class.cc GPLv3+ src/udp/udp_class.h GPLv3+ src/udp/udp_close.cc GPLv3+ src/udp/udp_read.cc GPLv3+ src/udp/udp_timeout.cc GPLv3+ src/udp/udp_write.cc GPLv3+ src/usbtmc/usbtmc.cc GPLv3+ src/usbtmc/usbtmc_class.cc GPLv3+ src/usbtmc/usbtmc_class.h GPLv3+ src/usbtmc/usbtmc_close.cc GPLv3+ src/usbtmc/usbtmc_read.cc GPLv3+ src/usbtmc/usbtmc_write.cc GPLv3+ src/vxi11/vxi11.cc GPLv3+ src/vxi11/vxi11_class.cc GPLv3+ src/vxi11/vxi11_class.h GPLv3+ src/vxi11/vxi11_close.cc GPLv3+ src/vxi11/vxi11_read.cc GPLv3+ src/vxi11/vxi11_write.cc GPLv3+ src/vxi11/vxi11.x public domain instrument-control-0.4.0/DESCRIPTION0000644000000000000000000000073413460206417015304 0ustar0000000000000000Name: instrument-control Version: 0.4.0 Date: 2019-02-24 Author: Andrius Sutas , Stefan Mahr , John Donoghue Maintainer: Stefan Mahr , John Donoghue Title: Instrument Control Description: Low level I/O functions for serial, i2c, parallel, tcp, gpib, vxi11, udp and usbtmc interfaces. Categories: instrument-control Depends: octave (>= 3.8.0) Autoload: no License: GPLv3+ instrument-control-0.4.0/INDEX0000644000000000000000000000310413460206417014362 0ustar0000000000000000instrument-control >> Low level I/O functions Serial serial seriallist @octave_serial/fopen @octave_serial/fclose @octave_serial/flushinput @octave_serial/flushoutput @octave_serial/get @octave_serial/set srl_read srl_write @octave_serial/srl_baudrate @octave_serial/srl_bytesize @octave_serial/srl_flush @octave_serial/srl_parity @octave_serial/srl_stopbits @octave_serial/srl_timeout @octave_serial/srl_close I2C i2c @octave_i2c/fopen @octave_i2c/fclose i2c_addr i2c_read i2c_write i2c_close Parallel parallel pp_datadir pp_data pp_ctrl pp_stat pp_close TCP tcp tcpip @octave_tcp/fopen @octave_tcp/fclose @octave_tcp/fprintf @octave_tcp/fread @octave_tcp/fwrite @octave_tcp/flushinput @octave_tcp/flushoutput @octave_tcp/get @octave_tcp/set tcp_read tcp_write tcp_timeout tcp_close USBTMC usbtmc @octave_usbtmc/fopen @octave_usbtmc/fclose usbtmc_read usbtmc_write usbtmc_close GPIB gpib gpib_read gpib_write gpib_timeout gpib_close @octave_gpib/fopen @octave_gpib/fclose @octave_gpib/fread @octave_gpib/fwrite @octave_gpib/fprintf @octave_gpib/fscanf spoll trigger clrdevice UDP udp @octave_udp/fopen @octave_udp/fclose @octave_udp/fread @octave_udp/fwrite @octave_udp/fprintf @octave_udp/flushinput @octave_udp/flushoutput @octave_udp/get @octave_udp/set udp_read udp_write udp_timeout udp_close udp_demo VXI11 vxi11 @octave_vxi11/fopen @octave_vxi11/fclose vxi11_read vxi11_write vxi11_close General instrhwinfo resolvehost instrument-control-0.4.0/Makefile0000644000000000000000000002174013460206417015236 0ustar0000000000000000## Copyright 2015-2016 Carnë Draug ## Copyright 2015-2016 Oliver Heimlich ## Copyright 2017 Julien Bect ## Copyright 2017 Olaf Till ## Copyright 2018-2019 John Donoghue ## ## Copying and distribution of this file, with or without modification, ## are permitted in any medium without royalty provided the copyright ## notice and this notice are preserved. This file is offered as-is, ## without any warranty. TOPDIR := $(shell pwd) ## Some basic tools (can be overriden using environment variables) SED ?= sed TAR ?= tar GREP ?= grep CUT ?= cut TR ?= tr ## Note the use of ':=' (immediate set) and not just '=' (lazy set). ## http://stackoverflow.com/a/448939/1609556 package := $(shell $(GREP) "^Name: " DESCRIPTION | $(CUT) -f2 -d" " | \ $(TR) '[:upper:]' '[:lower:]') version := $(shell $(GREP) "^Version: " DESCRIPTION | $(CUT) -f2 -d" ") ## These are the paths that will be created for the releases. target_dir := target release_dir := $(target_dir)/$(package)-$(version) release_tarball := $(target_dir)/$(package)-$(version).tar.gz html_dir := $(target_dir)/$(package)-html html_tarball := $(target_dir)/$(package)-html.tar.gz ## Using $(realpath ...) avoids problems with symlinks due to bug ## #50994 in Octaves scripts/pkg/private/install.m. But at least the ## release directory above is needed in the relative form, for 'git ## archive --format=tar --prefix=$(release_dir). real_target_dir := $(realpath .)/$(target_dir) installation_dir := $(real_target_dir)/.installation package_list := $(installation_dir)/.octave_packages install_stamp := $(installation_dir)/.install_stamp ## These can be set by environment variables which allow to easily ## test with different Octave versions. ifndef OCTAVE OCTAVE := octave endif OCTAVE := $(OCTAVE) --no-gui --silent --norc MKOCTFILE ?= mkoctfile ## Command used to set permissions before creating tarballs FIX_PERMISSIONS ?= chmod -R a+rX,u+w,go-w,ug-s HG := hg HG_CMD = $(HG) --config alias.$(1)=$(1) --config defaults.$(1)= $(1) HG_ID := $(shell $(call HG_CMD,identify) --id | sed -e 's/+//' ) HG_TIMESTAMP := $(firstword $(shell $(call HG_CMD,log) --rev $(HG_ID) --template '{date|hgdate}')) TAR_REPRODUCIBLE_OPTIONS := --sort=name --mtime="@$(HG_TIMESTAMP)" --owner=0 --group=0 --numeric-owner TAR_OPTIONS := --format=ustar $(TAR_REPRODUCIBLE_OPTIONS) ## Detect which VCS is used vcs := $(if $(wildcard .hg),hg,$(if $(wildcard .git),git,unknown)) ifeq ($(vcs),hg) release_dir_dep := .hg/dirstate endif ifeq ($(vcs),git) release_dir_dep := .git/index endif ## .PHONY indicates targets that are not filenames ## (https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html) .PHONY: help ## make will display the command before runnning them. Use @command ## to not display it (makes specially sense for echo). help: @echo "Targets:" @echo " dist - Create $(release_tarball) for release." @echo " html - Create $(html_tarball) for release." @echo " release - Create both of the above and show md5sums." @echo " install - Install the package in $(installation_dir), where it is not visible in a normal Octave session." @echo " check - Execute package tests." @echo " doctest - Test the help texts with the doctest package." @echo " run - Run Octave with the package installed in $(installation_dir) in the path." @echo " clean - Remove everything made with this Makefile." ## ## Recipes for release tarballs (package + html) ## .PHONY: release dist html clean-tarballs clean-unpacked-release ## To make a release, build the distribution and html tarballs. release: dist html md5sum $(release_tarball) $(html_tarball) @echo "Upload @ https://sourceforge.net/p/octave/package-releases/new/" @echo " and note the changeset the release corresponds to" ## dist and html targets are only PHONY/alias targets to the release ## and html tarballs. dist: $(release_tarball) html: $(html_tarball) ## An implicit rule with a recipe to build the tarballs correctly. %.tar.gz: % $(TAR) -cf - $(TAR_OPTIONS) -C "$(target_dir)/" "$(notdir $<)" | gzip -9n > "$@" clean-tarballs: @echo "## Cleaning release tarballs (package + html)..." -$(RM) $(release_tarball) $(html_tarball) @echo ## Create the unpacked package. ## ## Notes: ## * having ".hg/dirstate" (or ".git/index") as a prerequesite means it is ## only rebuilt if we are at a different commit. ## * the variable RM usually defaults to "rm -f" ## * having this recipe separate from the one that makes the tarball ## makes it easy to have packages in alternative formats (such as zip) ## * note that if a commands needs to be run in a specific directory, ## the command to "cd" needs to be on the same line. Each line restores ## the original working directory. $(release_dir): $(release_dir_dep) -$(RM) -r "$@" ifeq (${vcs},hg) hg archive --exclude ".hg*" --type files "$@" endif ifeq (${vcs},git) git archive --format=tar --prefix="$@/" HEAD | $(TAR) -x $(RM) "$@/.gitignore" endif ## Don't fall back to run the supposed necessary contents of ## 'bootstrap' here. Users are better off if they provide ## 'bootstrap'. Administrators, checking build reproducibility, can ## put in the missing 'bootstrap' file if they feel they know its ## necessary contents. ifneq (,$(wildcard src/bootstrap)) cd "$@/src" && ./bootstrap && $(RM) -r "autom4te.cache" endif ## Uncomment this if your src/Makefile.in has these targets for ## pre-building something for the release (e.g. documentation). cd "$@/src" && ./configure && $(MAKE) prebuild && \ $(MAKE) distclean && $(RM) Makefile ## ${FIX_PERMISSIONS} "$@" run_in_place = $(OCTAVE) --eval ' pkg ("local_list", "$(package_list)"); ' \ --eval ' pkg ("load", "$(package)"); ' # html_options = --eval 'options = get_html_options ("octave-forge");' ## Uncomment this for package documentation. html_options = --eval 'options = get_html_options ("octave-forge");' $(html_dir): $(install_stamp) $(RM) -r "$@"; $(run_in_place) \ --eval ' pkg load generate_html; ' \ $(html_options) \ --eval ' generate_package_html ("$(package)", "$@", options); '; $(FIX_PERMISSIONS) "$@"; clean-unpacked-release: @echo "## Cleaning unpacked release tarballs (package + html)..." -$(RM) -r $(release_dir) $(html_dir) @echo ## ## Recipes for installing the package. ## .PHONY: install clean-install octave_install_commands = \ ' llist_path = pkg ("local_list"); \ mkdir ("$(installation_dir)"); \ load (llist_path); \ local_packages(cellfun (@ (x) strcmp ("$(package)", x.name), local_packages)) = []; \ save ("$(package_list)", "local_packages"); \ pkg ("local_list", "$(package_list)"); \ pkg ("prefix", "$(installation_dir)", "$(installation_dir)"); \ pkg ("install", "-local", "-verbose", "$(release_tarball)"); ' ## Install unconditionally. Maybe useful for testing installation with ## different versions of Octave. install: $(release_tarball) @echo "Installing package under $(installation_dir) ..." $(OCTAVE) --eval $(octave_install_commands) touch $(install_stamp) ## Install only if installation (under target/...) is not current. $(install_stamp): $(release_tarball) @echo "Installing package under $(installation_dir) ..." $(OCTAVE) --eval $(octave_install_commands) touch $(install_stamp) clean-install: @echo "## Cleaning installation under $(installation_dir) ..." -$(RM) -r $(installation_dir) @echo ## ## Recipes for testing purposes ## .PHONY: run doctest check ## Start an Octave session with the package directories on the path for ## interactice test of development sources. run: $(install_stamp) $(run_in_place) --persist rungui: $(install_stamp) $(run_in_place) --gui --persist ## Test example blocks in the documentation. Needs doctest package ## https://octave.sourceforge.io/doctest/index.html doctest: $(install_stamp) $(run_in_place) --eval 'pkg load doctest;' \ --eval "targets = '$(shell (ls inst; ls src | $(GREP) .oct) | $(CUT) -f2 -d@ | $(CUT) -f1 -d.)';" \ --eval "targets = strsplit (targets, ' '); doctest (targets);" ## Test package. octave_test_commands = \ ' pkgs = pkg("list", "instrument-control"); \ dirs = {pkgs{1}.dir}; \ __run_test_suite__ (dirs, {}); ' ## the following works, too, but provides no overall summary output as ## __run_test_suite__ does: ## ## else cellfun (@runtests, horzcat (cellfun (@ (dir) ostrsplit (([~, dirs] = system (sprintf ("find %s -type d", dir))), "\n\r", true), dirs, "UniformOutput", false){:})); endif ' check: $(install_stamp) $(run_in_place) --eval $(octave_test_commands) ## ## CLEAN ## .PHONY: clean clean: clean-tarballs clean-unpacked-release clean-install test -e inst/test && rmdir inst/test || true test -e $(target_dir)/fntests.log && rm -f $(target_dir)/fntests.log || true @echo "## Removing target directory (if empty)..." test -e $(target_dir) && rmdir $(target_dir) || true @echo @echo "## Cleaning done" @echo instrument-control-0.4.0/NEWS0000644000000000000000000001137713460206417014302 0ustar0000000000000000Summary of important user-visible changes for instrument-control 0.4.0 ------------------------------------------------------------------- ** SERIAL: added 'status', 'bytesavailable', 'name' and 'type' properties, and the following functions: seriallist flushinput flushoutput ** UDP: added 'status' and 'bytesavailable' properties and the following functions: flushinput flushoutput ** TCP: added properties to object, added overridden functions: get set fprintf fread fwrite flushinput flushoutput ** tcpip(): added wrapper to be matlab compatible(ish) ** distribute rpc generated files ** verify -M option will work on rpcgen ** detect if rpc_error functions allow use of const inputs ** prefer libtirpc over builtin rpc when detecting vxi11 functionality ** add lock functions used on pkg load/unlock to lock .oct files ** implemented instrhwinfo serial list for mac Summary of important user-visible changes for instrument-control 0.3.1: ------------------------------------------------------------------- ** Updated build to allow install on octave 4.4 ** using polling rather than signal handling to break from instrument reads ** insthwinfo() updated to show enabled modules ** added initial builtin tests for each instrument Summary of important user-visible changes for instrument-control 0.3.0: ------------------------------------------------------------------- ** SERIAL: allow non standard baudrates in win32 ** TCP: new functions: resolvehost ** UDP: new interface with functions for: udp udp_timeout udp_read udp_write udp_close udp_demo ** UDP overload functions for: fprintf fread fwrite fclose fopen get set Summary of important user-visible changes for instrument-control 0.2.3: ------------------------------------------------------------------- ** New function: instrhwinfo ** GPIB: Fix EOI handling ** SERIAL: Fix display of bytesize setting ** SERIAL: Win32: Fix srl_read ** TCP: Fix infinite loop on connection lost Summary of important user-visible changes for instrument-control 0.2.2: ------------------------------------------------------------------- ** GPIB: new function: fread ** SERIAL: Add pinstatus property ** SERIAL: Change display for serial object ** SERIAL: Fix MACOS compilation error ** Fix warnings when using Octave 4.0 Summary of important user-visible changes for instrument-control 0.2.1: ------------------------------------------------------------------- ** GPIB: New functions: spoll trigger clrdevice fopen fclose fwrite fprintf fscanf ** I2C, TCPIP, USBTMC, VXI11: New functions: fopen fclose ** SERIAL: Add Win32 support ** SERIAL: New functions: fclose fopen get set ** SERIAL: Deprecate functions, use set and get instead: srl_baudrate srl_bytesize srl_close srl_flush srl_parity srl_stopbits srl_timeout Summary of important user-visible changes for instrument-control 0.2.0: ------------------------------------------------------------------- ** Support for TCP interface I/O ** Support for USBTMC interface I/O ** Support for GPIB interface I/O ** Support for VXI11 interface I/O ** The following functions are new: tcp tcp_read tcp_write tcp_timeout tcp_close usbtmc usbtmc_read usbtmc_write usbtmc_close gpib gpib_read gpib_write gpib_timeout gpib_close vxi11 vxi11_read vxi11_write vxi11_close ** Interfaces are now compiled seperately (i.e. failed compilation of one interface does not mean fail of whole package) ** Parallel and i2c interface support for FreeBSD platform ** i2c_write no longer accepts strings for data parameter Summary of important user-visible changes for instrument-control 0.1.0: ------------------------------------------------------------------- ** Initial release ** Support for Parallel interface I/O ** Support for Serial interface I/O ** Support for i2c interface I/O ** The following functions are new: serial srl_close srl_read srl_write srl_baudrate srl_flush srl_stopbits srl_bytesize srl_parity srl_timeout i2c i2c_addr i2c_read i2c_close i2c_write parallel pp_ctrl pp_stat pp_close pp_data pp_datadir instrument-control-0.4.0/devel/0000755000000000000000000000000013460206417014671 5ustar0000000000000000instrument-control-0.4.0/devel/README0000644000000000000000000000034413460206417015552 0ustar0000000000000000This directory contains functions that have been used to develop, test or debug some of the instrument control functions in the parent directory. This files are not needed at runtime for them to work, so they are not installed. instrument-control-0.4.0/devel/testtcp.m0000644000000000000000000000165113460206417016540 0ustar0000000000000000function testtcp ip="127.0.0.1"; port=8000; echostr="echotest\n"; timeout=1000; tol=0.1; % 10 percent tolerance % test error fd=tcp(ip,port); % test connect, write and read system ("killall socat 2>/dev/null; socat PIPE TCP4-LISTEN:8000 &",0); sleep(1); fd=tcp(ip,port); % test read timeout1 start=tic; result = tcp_read(fd,10000,1000); timeout1 = double(tic - start)/1000 testresult1 = tol > abs(1 - timeout1/timeout); % write to socat tcp_write(fd,echostr); % read 4 chars, no timeout start=tic; result = tcp_read(fd,4,1000); timeout2 = double(tic - start)/1000; testresult2 = timeout2 < timeout; % check read result result = char(result); testresult3 = strcmp(echostr(1:4),result); % close tcp tcp_close(fd); %system ("killall socat"); % printf("timeout test 1: %d (%f)\n",testresult1,timeout1); printf("timeout test 2: %d (%f)\n",testresult2,timeout2); printf("timeout test 3: %d\n",testresult3); instrument-control-0.4.0/inst/0000755000000000000000000000000013460206417014547 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_gpib/0000755000000000000000000000000013460206417017131 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_gpib/fclose.m0000644000000000000000000000160213460206417020561 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes connection to GPIB device @var{obj} ## @end deftypefn ## TODO: function fclose(fd) gpib_close(fd); end instrument-control-0.4.0/inst/@octave_gpib/fopen.m0000644000000000000000000000173013460206417020417 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens connection to GPIB device @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/@octave_gpib/fprintf.m0000644000000000000000000000353013460206417020760 0ustar0000000000000000## Copyright (C) 2013-2019 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} fprintf (@var{obj}, @var{cmd}) ## @deftypefnx {Function File} {} fprintf (@var{obj}, @var{format}, @var{cmd}) ## @deftypefnx {Function File} {} fprintf (@var{obj}, @var{cmd}, @var{mode}) ## @deftypefnx {Function File} {} fprintf (@var{obj}, @var{format}, @var{cmd}, @var{mode}) ## Writes string @var{cmd} to GPIB instrument ## ## @var{obj} is a GPIB object ## ## @var{cmd} String ## @var{format} Format specifier ## @var{mode} sync ## ## @end deftypefn ## TODO: function fprintf (obj, format, cmd, mode) defaultformat = '%s\n'; defaultmode = 'sync'; if ((nargin < 2) || (nargin > 4)) print_usage (); elseif (nargin < 3) format = defaultformat; mode = defaultmode; elseif (nargin < 4) %% decide for syntax if (!isempty (find (format == '%'))) %% detected: fprintf (obj, format, cmd)) mode = defaultmode; else %% fprintf (obj, cmd, mode) mode = cmd; cmd = format; format = defaultformat; end end if (! ( ischar (format) && ischar (mode) )) print_usage (); end if (strcmp (mode, 'async')) error ("async mode not supported yet"); end gpib_write (obj, sprintf (format, cmd)) end instrument-control-0.4.0/inst/@octave_gpib/fread.m0000644000000000000000000000575513460206417020404 0ustar0000000000000000## Copyright (C) 2015 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{data} =} fread (@var{obj}) ## @deftypefnx {Function File} {@var{data} =} fread (@var{obj}, @var{size}) ## @deftypefnx {Function File} {@var{data} =} fread (@var{obj}, @var{size}, @var{precision}) ## @deftypefnx {Function File} {[@var{data},@var{count}] =} fread (@var{obj}, ...) ## @deftypefnx {Function File} {[@var{data},@var{count},@var{errmsg}] =} fread (@var{obj}, ...) ## Reads @var{data} from GPIB instrument ## ## @var{obj} is a GPIB object ## ## @var{size} Number of values to read. (Default: 100) ## @var{precision} precision of data ## ## @var{count} values read ## @var{errmsg} read operation error message ## ## @end deftypefn function [data, count, errmsg] = fread (obj, size, precision) if (nargin < 2) ## TODO: InputBufferSize property not implemented yet warning("fread: InputBufferSize property not implemented yet, using 100 as default"); size = 100; end if (nargin < 3) precision = 'uchar'; end if ((rows(size) == 1) && (columns(size) == 2)) toread = size(1) * size(2); elseif (numel(size) == 1) toread = size; else print_usage(); endif switch (precision) case {"char" "schar" "int8"} toclass = "int8"; case {"uchar" "uint8"} toclass = "uint8"; case {"int16" "short"} toclass = "int16"; toread = toread * 2; case {"uint16" "ushort"} toclass = "uint16"; case {"int32" "int"} toclass = "int32"; toread = toread * 4; case {"uint32" "uint"} toclass = "uint32"; toread = toread * 4; case {"long" "int64"} toclass = "int64"; toread = toread * 8; case {"ulong" "uint64"} toclass = "uint64"; toread = toread * 8; case {"single" "float" "float32"} toclass = "single"; toread = toread * 4; case {"double" "float64"} toclass = "double"; toread = toread * 8; otherwise error ("precision not supported"); end eoi=0; tmp=[]; count=0; while ((!eoi) && (toread > 0)) [tmp1,wasread,eoi] = gpib_read (obj, toread); %% if successful tmp is never negative (uint8) count = count + wasread; toread = toread - wasread; if ((eoi) || (tmp1 < 0)) break; end tmp = [tmp tmp1]; end ## TODO: omit warning messages (if any) and output warning text to errmsg instead errmsg = ''; data = typecast(tmp,toclass); if (numel(size) > 1) data = reshape(data,size); end endfunction instrument-control-0.4.0/inst/@octave_gpib/fscanf.m0000644000000000000000000000353313460206417020553 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fscanf (@var{obj}) ## @deftypefnx {Function File} {@var{res} =} fscanf (@var{obj}, @var{format}) ## @deftypefnx {Function File} {@var{res} =} fscanf (@var{obj}, @var{format}, @var{size}) ## @deftypefnx {Function File} {[@var{res},@var{count}] =} fscanf (@var{obj}, ...) ## @deftypefnx {Function File} {[@var{res},@var{count},@var{errmsg}] =} fscanf (@var{obj}, ...) ## Reads data @var{res} from GPIB instrument ## ## @var{obj} is a GPIB object ## ## @var{format} Format specifier ## @var{size} number of values ## ## @var{count} values read ## @var{errmsg} read operation error message ## ## @end deftypefn ## TODO: function [res, count, errmsg] = fscanf (obj, format, size) if (nargin < 1) print_usage (); end if (nargin < 2) format = '%c'; end % TODO: use a max buffer property? buffersize = 1e6; eoi=0; tmp = []; while (!eoi) [tmp1,~,eoi] = gpib_read (obj, buffersize); %% if successful tmp is never negative (uint8) if ((!eoi) || (tmp < 0)) break; end tmp = [tmp tmp1]; end if (nargin < 3) [res,count,errmsg]=sscanf (tmp,format); else [res,count,errmsg]=sscanf (tmp,format,size); end end instrument-control-0.4.0/inst/@octave_gpib/fwrite.m0000644000000000000000000000451013460206417020607 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} fwrite (@var{obj}, @var{data}) ## @deftypefnx {Function File} {} fwrite (@var{obj}, @var{data}, @var{precision}) ## @deftypefnx {Function File} {} fwrite (@var{obj}, @var{data}, @var{mode}) ## @deftypefnx {Function File} {} fwrite (@var{obj}, @var{data}, @var{precision}, @var{mode}) ## Writes @var{data} to GPIB instrument ## ## @var{obj} is a GPIB object ## ## @var{data} data to write ## @var{precision} precision of data ## @var{mode} sync ## ## @end deftypefn ## TODO: function fwrite(obj, data, precision, mode) defaultmode = "sync"; if (nargin < 2) print_usage (); elseif (nargin < 3) precision = []; mode = defaultmode; elseif (nargin < 4) %% is 3rd argument precision or mode if (strcmp (precision,'sync') || strcmp (precision,'async')) mode = precision; precision = []; else mode = "sync"; end end if (strcmp (mode,'async')) error ("async mode not supported yet"); end switch (precision) case {"char" "schar" "int8"} data = int8 (data); case {"uchar" "uint8"} data = uint8 (data); case {"int16" "short"} data = int16 (data); case {"uint16" "ushort"} data = uint16 (data); case {"int32" "int"} data = int32 (data); case {"uint32" "uint"} data = uint32 (data); case {"long" "int64"} data = int64 (data); case {"ulong" "uint64"} data = uint64 (data); case {"single" "float" "float32"} data = single (data); case {"double" "float64"} data = double (data); case [] %% use data as it is otherwise error ("precision not supported"); end %% should we handle endianess ? gpib_write (obj, typecast(data,'uint8')); end instrument-control-0.4.0/inst/@octave_i2c/0000755000000000000000000000000013460206417016665 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_i2c/fclose.m0000644000000000000000000000156613460206417020326 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes I2C connection @var{obj} ## @end deftypefn ## TODO: function fclose(fd) i2c_close(fd); end instrument-control-0.4.0/inst/@octave_i2c/fopen.m0000644000000000000000000000171513460206417020156 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens I2C connection @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/@octave_serial/0000755000000000000000000000000013460206417017467 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_serial/fclose.m0000644000000000000000000000171413460206417021123 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes SERIAL connection @var{obj} ## @end deftypefn ## TODO: function fclose(serial) if (nargin == 1) __srl_properties__ (serial, 'close'); else print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/flushinput.m0000644000000000000000000000203013460206417022041 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} flushinput (@var{serial}) ## ## Flush the pending input, which will also make the BytesAvailable property be 0. ## ## @var{serial} - instance of @var{octave_serial} class. ## ## @seealso{srl_flush, flushoutput} ## @end deftypefn function flushinput (serial, q) __srl_properties__ (serial, 'flush', 1); end instrument-control-0.4.0/inst/@octave_serial/flushoutput.m0000644000000000000000000000174213460206417022253 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} flushoutput (@var{serial}) ## ## Flush the output buffer. ## ## @var{serial} - instance of @var{octave_serial} class. ## ## @seealso{srl_flush, flushinput} ## @end deftypefn function flushoutput (serial, q) __srl_properties__ (serial, 'flush', 0); end instrument-control-0.4.0/inst/@octave_serial/fopen.m0000644000000000000000000000171713460206417020762 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens SERIAL interface @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/@octave_serial/get.m0000644000000000000000000000363113460206417020427 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{struct} = } get (@var{serial}) ## @deftypefnx {Function File} {@var{field} = } get (@var{serial}, @var{property}) ## Get the properties of serial object. ## ## @seealso{@@octave_serial/set} ## @end deftypefn function retval = get (serial, property) properties = {'name', 'type', 'status', 'baudrate', 'bytesize', 'parity', ... 'stopbits', 'timeout', 'requesttosend', 'dataterminalready', ... 'pinstatus', 'bytesavailable'}; if (nargin == 1) property = properties; elseif (nargin > 2) error ("Too many arguments.\n"); end if !iscell (property) property = {property}; end property = tolower(property); valid = ismember (property, properties); not_found = {property{!valid}}; if !isempty (not_found) msg = @(x) error("serial:get:InvalidArgument", ... "Unknown property '%s'.\n",x); cellfun (msg, not_found); end property = {property{valid}}; func = @(x) __srl_properties__ (serial, x); retval = cellfun (func, property, 'UniformOutput', false); if numel(property) == 1 retval = retval{1}; elseif (nargin == 1) retval = cell2struct (retval',properties); end end instrument-control-0.4.0/inst/@octave_serial/set.m0000644000000000000000000000663413460206417020451 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} set (@var{obj}, @var{property},@var{value}) ## @deftypefnx {Function File} set (@var{obj}, @var{property},@var{value},@dots{}) ## Set the properties of serial object. ## ## If @var{property} is a cell so must be @var{value}, it sets the values of ## all matching properties. ## ## The function also accepts property-value pairs. ## ## @table @var ## @item 'baudrate' ## Set the baudrate of serial port. Supported values by instrument-control: ## 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, ## 19200, 38400, 57600, 115200 and 230400. The supported baudrate of your ## serial port may be different. ## ## @item 'bytesize' ## Set the bytesize. Supported values: 5, 6, 7 and 8. ## ## @item 'name' ## Set the stored string name of the serial object. ## ## @item 'parity' ## Set the parity value. Supported values: Even/Odd/None. This Parameter ## must be of type string. It is case insensitive and can be abbreviated ## to the first letter only ## ## @item 'stopbits' ## Set the number of stopbits. Supported values: 1, 2. ## ## @item 'timeout' ## Set the timeout value in tenths of a second. Value of -1 means a ## blocking call. Maximum value of 255 (i.e. 25.5 seconds). ## ## @item 'requesttosend' ## Set the requesttosend (RTS) line. ## ## @item 'dataterminalready' ## Set the dataterminalready (DTR) line. ## ## @end table ## ## @seealso{@@octave_serial/get} ## @end deftypefn function set (serial, varargin) properties = {'name', 'baudrate','bytesize','parity','stopbits','timeout', ... 'requesttosend','dataterminalready'}; if numel (varargin) == 1 && isstruct (varargin{1}) property = fieldnames (varargin{1}); func = @(x) getfield (varargin{1}, x); value = cellfun (func, property, 'UniformOutput', false); elseif numel (varargin) == 2 && iscell (varargin{1}) && iscell (varargin{2}) %% The arguments are two cells, expecting fields and values. property = varargin{1}; value = varargin{2}; else property = {varargin{1:2:end}}; value = {varargin{2:2:end}}; end if numel (property) != numel (value) error ('serial:set:InvalidArgument', ... 'PROPERIES and VALUES must have the same number of elements.'); end property = tolower(property); valid = ismember (property, properties); not_found = {property{!valid}}; if !isempty (not_found) msg = @(x) error ("serial:set:InvalidArgument", ... "Property '%s' not found in serial object.\n",x); cellfun (msg, not_found); end property = {property{valid}}; value = {value{valid}}; for i=1:length(property) __srl_properties__ (serial, property{i}, value{i}); end end instrument-control-0.4.0/inst/@octave_serial/srl_baudrate.m0000644000000000000000000000320113460206417022310 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_baudrate (@var{serial}, @var{baudrate})\ ## @deftypefnx {Loadable Function} {@var{br} = } srl_baudrate (@var{serial}) ## ## Set new or get existing serial interface baudrate parameter. Only standard values are supported. ## ## @var{serial} - instance of @var{octave_serial} class. ## @var{baudrate} - the baudrate value used. Supported values: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600 19200, 38400, 57600, 115200 and 230400. ## ## If @var{baudrate} parameter is omitted, the srl_baudrate() shall return current baudrate value as the result @var{br}. ## ## This function is obsolete. Use get and set method instead. ## ## @end deftypefn function retval = srl_baudrate (serial, baudrate) try if (nargin>1) __srl_properties__ (serial, 'baudrate', baudrate); else retval = __srl_properties__ (serial, 'baudrate'); end catch print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/srl_bytesize.m0000644000000000000000000000303013460206417022357 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_bytesize (@var{serial}, @var{bsize}) ## @deftypefnx {Loadable Function} {@var{bs} = } srl_bytesize (@var{serial}) ## ## Set new or get existing serial interface byte size parameter. ## ## @var{serial} - instance of @var{octave_serial} class. ## @var{bsize} - byte size of type Integer. Supported values: 5/6/7/8. ## ## If @var{bsize} parameter is omitted, the srl_bytesize() shall return current byte size value or in case of unsupported setting -1, as the result @var{bs}. ## ## This function is obsolete. Use get and set method instead. ## ## @end deftypefn function retval = srl_bytesize (serial, bytesize) try if (nargin>1) __srl_properties__ (serial, 'bytesize', bytesize); else retval = __srl_properties__ (serial, 'bytesize'); end catch print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/srl_close.m0000644000000000000000000000210513460206417021630 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_close (@var{serial}) ## ## Close the interface and release a file descriptor. ## ## @var{serial} - instance of @var{octave_serial} class. ## ## This function is obsolete. Use fclose() method instead. ## ## @end deftypefn function srl_close (serial) try __srl_properties__ (serial, 'close'); catch print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/srl_flush.m0000644000000000000000000000254713460206417021656 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_flush (@var{serial}, [@var{q}]) ## ##Flush the pending input/output. ## ## @var{serial} - instance of @var{octave_serial} class. ## @var{q} - queue selector of type Integer. Supported values: 0 - flush untransmitted output, 1 - flush pending input, 2 - flush both pending input and untransmitted output. ## ## If @var{q} parameter is omitted, the srl_flush() shall flush both, input and output buffers. ## ## @end deftypefn function srl_flush (serial, q) try if (nargin>1) __srl_properties__ (serial, 'flush', q); else __srl_properties__ (serial, 'flush'); end catch print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/srl_parity.m0000644000000000000000000000311013460206417022030 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_parity (@var{serial}, @var{parity}) ## @deftypefnx {Loadable Function} {@var{p} = } srl_parity (@var{serial}) ## ## Set new or get existing serial interface parity parameter. Even/Odd/None values are supported. ## ## @var{serial} - instance of @var{octave_serial} class. ## @var{parity} - parity value of type String. Supported values: Even/Odd/None (case insensitive, can be abbreviated to the first letter only) ## ## If @var{parity} parameter is omitted, the srl_parity() shall return current parity value as the result @var{p}. ## ## This function is obsolete. Use get and set method instead. ## ## @end deftypefn function retval = srl_parity (serial, parity) try if (nargin>1) __srl_properties__ (serial, 'parity', parity); else retval = __srl_properties__ (serial, 'parity'); end catch print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/srl_stopbits.m0000644000000000000000000000302313460206417022372 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_stopbits (@var{serial}, @var{stopb}) ## @deftypefnx {Loadable Function} {@var{sb} = } srl_stopbits (@var{serial}) ## ## Set new or get existing serial interface stop bits parameter. Only 1 or 2 stop bits are supported. ## ## @var{serial} - instance of @var{octave_serial} class. ## @var{stopb} - number of stop bits used. Supported values: 1, 2. ## ## If @var{stopb} parameter is omitted, the srl_stopbits() shall return current stop bits value as the result @var{sb}. ## ## This function is obsolete. Use get and set method instead. ## ## @end deftypefn function retval = srl_stopbits (serial, stopbits) try if (nargin>1) __srl_properties__ (serial, 'stopbits', stopbits); else retval = __srl_properties__ (serial, 'stopbits'); end catch print_usage(); end end instrument-control-0.4.0/inst/@octave_serial/srl_timeout.m0000644000000000000000000000320413460206417022212 0ustar0000000000000000## Copyright (C) 2014 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} srl_timeout (@var{serial}, @var{timeout}) ## @deftypefnx {Loadable Function} {@var{t} = } srl_timeout (@var{serial}) ## ## Set new or get existing serial interface timeout parameter used for srl_read() requests. The timeout value is specified in tenths of a second. ## ## @var{serial} - instance of @var{octave_serial} class. ## @var{timeout} - srl_read() timeout value in tenths of a second. Value of -1 means a blocking call. Maximum value of 255 (i.e. 25.5 seconds). ## ## If @var{timeout} parameter is omitted, the srl_timeout() shall return current timeout value as the result @var{t}. ## ## This function is obsolete. Use get and set method instead. ## ## @end deftypefn function retval = srl_timeout (serial, timeout) try if (nargin>1) __srl_properties__ (serial, 'timeout', timeout); else retval = __srl_properties__ (serial, 'timeout'); end catch print_usage(); end end instrument-control-0.4.0/inst/@octave_tcp/0000755000000000000000000000000013460206417016776 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_tcp/fclose.m0000644000000000000000000000156613460206417020437 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes TCP connection @var{obj} ## @end deftypefn ## TODO: function fclose(fd) tcp_close(fd); end instrument-control-0.4.0/inst/@octave_tcp/flushinput.m0000644000000000000000000000177613460206417021370 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} flushinput (@var{tcp}) ## ## Flush the pending input, which will also make the BytesAvailable property be 0. ## ## @var{tcp} - instance of @var{octave_tcp} class. ## ## @seealso{flushoutput} ## @end deftypefn function flushinput (tcp, q) __tcp_properties__ (tcp, 'flush', 1); end instrument-control-0.4.0/inst/@octave_tcp/flushoutput.m0000644000000000000000000000170513460206417021561 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} flushoutput (@var{tcp}) ## ## Flush the output buffer. ## ## @var{tcp} - instance of @var{octave_tcp} class. ## ## @seealso{flushinput} ## @end deftypefn function flushoutput (tcp) __tcp_properties__ (tcp, 'flush', 0); end instrument-control-0.4.0/inst/@octave_tcp/fopen.m0000644000000000000000000000171513460206417020267 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens TCP connection @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/@octave_tcp/fprintf.m0000644000000000000000000000254313460206417020630 0ustar0000000000000000## Copyright (C) 2018-2019 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{numbytes} =} fprintf (@var{obj}, @var{template} ...) ## Writes formatted string @var{template} using optional parameters to ## TCP instrument ## ## @var{obj} is a TCP object ## @var{template} Format template string ## ## @end deftypefn function numbytes = fprintf (varargin) defaultformat = '%s\n'; if (nargin < 2) print_usage (); elseif (nargin < 3) formargs = varargin(2); format = defaultformat; else(nargin < 4) formargs = varargin(3:nargin); format = varargin{2}; end if (! ( ischar (format))) print_usage (); end numbytes = tcp_write (varargin{1}, sprintf (format, formargs{:})); end instrument-control-0.4.0/inst/@octave_tcp/fread.m0000644000000000000000000000563113460206417020242 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{data} =} fread (@var{obj}) ## @deftypefnx {Function File} {@var{data} =} fread (@var{obj}, @var{size}) ## @deftypefnx {Function File} {@var{data} =} fread (@var{obj}, @var{size}, @var{precision}) ## @deftypefnx {Function File} {[@var{data},@var{count}] =} fread (@var{obj}, ...) ## @deftypefnx {Function File} {[@var{data},@var{count},@var{errmsg}] =} fread (@var{obj}, ...) ## Reads @var{data} from TCP instrument ## ## @var{obj} is a TCP object ## ## @var{size} Number of values to read. (Default: 100) ## @var{precision} precision of data ## ## @var{count} values read ## @var{errmsg} read operation error message ## ## @end deftypefn function [data, count, errmsg] = fread (obj, size, precision) if (nargin < 2) ## TODO: InputBufferSize property not implemented yet warning("fread: InputBufferSize property not implemented yet, using 100 as default"); size = 100; end if (nargin < 3) precision = 'uchar'; end if ((rows(size) == 1) && (columns(size) == 2)) toread = size(1) * size(2); elseif (numel(size) == 1) toread = size; else print_usage(); endif switch (precision) case {"char" "schar" "int8"} toclass = "int8"; case {"uchar" "uint8"} toclass = "uint8"; case {"int16" "short"} toclass = "int16"; toread = toread * 2; case {"uint16" "ushort"} toclass = "uint16"; case {"int32" "int"} toclass = "int32"; toread = toread * 4; case {"uint32" "uint"} toclass = "uint32"; toread = toread * 4; case {"long" "int64"} toclass = "int64"; toread = toread * 8; case {"ulong" "uint64"} toclass = "uint64"; toread = toread * 8; case {"single" "float" "float32"} toclass = "single"; toread = toread * 4; case {"double" "float64"} toclass = "double"; toread = toread * 8; otherwise error ("precision not supported"); end eoi=0; tmp=[]; count=0; while ((!eoi) && (toread > 0)) tmp1 = tcp_read (obj, toread, get(obj, 'timeout')); if !isempty(tmp1) wasread = numel(tmp1); count = count + wasread; toread = toread - wasread; else break; end tmp = [tmp tmp1]; end errmsg = ''; data = typecast(tmp,toclass); if (numel(size) > 1) data = reshape(data,size); end endfunction instrument-control-0.4.0/inst/@octave_tcp/fwrite.m0000644000000000000000000000364213460206417020461 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{numbytes} = } fwrite (@var{obj}, @var{data}) ## @deftypefnx {Function File} {@var{numbytes} =} fwrite (@var{obj}, @var{data}, @var{precision}) ## Writes @var{data} to TCP instrument ## ## @var{obj} is a TCP object ## ## @var{data} data to write ## @var{precision} precision of data ## ## returns number of bytes written. ## @end deftypefn function numbytes = fwrite(obj, data, precision) if (nargin < 2) print_usage (); elseif (nargin < 3) precision = []; end switch (precision) case {"char" "schar" "int8"} data = int8 (data); case {"uchar" "uint8"} data = uint8 (data); case {"int16" "short"} data = int16 (data); case {"uint16" "ushort"} data = uint16 (data); case {"int32" "int"} data = int32 (data); case {"uint32" "uint"} data = uint32 (data); case {"long" "int64"} data = int64 (data); case {"ulong" "uint64"} data = uint64 (data); case {"single" "float" "float32"} data = single (data); case {"double" "float64"} data = double (data); case [] %% use data as it is otherwise error ("precision not supported"); end %% should we handle endianess ? numbytes = tcp_write (obj, typecast(data,'uint8')); end instrument-control-0.4.0/inst/@octave_tcp/get.m0000644000000000000000000000352713460206417017742 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{struct} = } get (@var{tcp}) ## @deftypefnx {Function File} {@var{field} = } get (@var{tcp}, @var{property}) ## Get the properties of tcp object. ## ## @seealso{@@octave_tcp/set} ## @end deftypefn function retval = get (tcp, property) properties = {'name', 'remoteport', 'remotehost', ... 'localport', 'type', ... 'status', 'timeout', 'bytesavailable'}; if (nargin == 1) property = properties; elseif (nargin > 2) error ("Too many arguments.\n"); end if !iscell (property) property = {property}; end property = tolower(property); valid = ismember (property, properties); not_found = {property{!valid}}; if !isempty (not_found) msg = @(x) error("tcp:get:InvalidArgument", ... "Unknown property '%s'.\n",x); cellfun (msg, not_found); end property = {property{valid}}; func = @(x) __tcp_properties__ (tcp, x); retval = cellfun (func, property, 'UniformOutput', false); if numel(property) == 1 retval = retval{1}; elseif (nargin == 1) retval = cell2struct (retval',properties); end end instrument-control-0.4.0/inst/@octave_tcp/set.m0000644000000000000000000000516213460206417017753 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} set (@var{obj}, @var{property},@var{value}) ## @deftypefnx {Function File} set (@var{obj}, @var{property},@var{value},@dots{}) ## Set the properties of tcp object. ## ## If @var{property} is a cell so must be @var{value}, it sets the values of ## all matching properties. ## ## The function also accepts property-value pairs. ## ## @table @var ## @item 'name' ## Set the name for the tcp socket. ## ## @item 'remotehost' ## Set the remote host name for the tcp socket. ## ## @item 'remoteport' ## Set the remote port for the tcp socket. ## ## @item 'timeout' ## Set the timeout value in tenths of a second. Value of -1 means a ## blocking call. Maximum value of 255 (i.e. 25.5 seconds). ## ## @end table ## ## @seealso{@@octave_tcp/get} ## @end deftypefn function set (tcp, varargin) properties = {'timeout', 'name' }; if numel (varargin) == 1 && isstruct (varargin{1}) property = fieldnames (varargin{1}); func = @(x) getfield (varargin{1}, x); value = cellfun (func, property, 'UniformOutput', false); elseif numel (varargin) == 2 && iscell (varargin{1}) && iscell (varargin{2}) %% The arguments are two cells, expecting fields and values. property = varargin{1}; value = varargin{2}; else property = {varargin{1:2:end}}; value = {varargin{2:2:end}}; end if numel (property) != numel (value) error ('tcp:set:InvalidArgument', ... 'PROPERIES and VALUES must have the same number of elements.'); end property = tolower(property); valid = ismember (property, properties); not_found = {property{!valid}}; if !isempty (not_found) msg = @(x) error ("tcp:set:InvalidArgument", ... "Property '%s' not found in tcp object.\n",x); cellfun (msg, not_found); end property = {property{valid}}; value = {value{valid}}; for i=1:length(property) __tcp_properties__ (tcp, property{i}, value{i}); end end instrument-control-0.4.0/inst/@octave_udp/0000755000000000000000000000000013460206417017000 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_udp/fclose.m0000644000000000000000000000156713460206417020442 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes UDP connection @var{obj} ## @end deftypefn function fclose(fd) udp_close(fd); end instrument-control-0.4.0/inst/@octave_udp/flushinput.m0000644000000000000000000000177613460206417021372 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} flushinput (@var{udp}) ## ## Flush the pending input, which will also make the BytesAvailable property be 0. ## ## @var{udp} - instance of @var{octave_udp} class. ## ## @seealso{flushoutput} ## @end deftypefn function flushinput (udp, q) __udp_properties__ (udp, 'flush', 1); end instrument-control-0.4.0/inst/@octave_udp/flushoutput.m0000644000000000000000000000170513460206417021563 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Loadable Function} {} flushoutput (@var{udp}) ## ## Flush the output buffer. ## ## @var{udp} - instance of @var{octave_udp} class. ## ## @seealso{flushinput} ## @end deftypefn function flushoutput (udp) __udp_properties__ (udp, 'flush', 0); end instrument-control-0.4.0/inst/@octave_udp/fopen.m0000644000000000000000000000173013460206417020266 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens UDP connection @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/@octave_udp/fprintf.m0000644000000000000000000000254313460206417020632 0ustar0000000000000000## Copyright (C) 2016-2019 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{numbytes} =} fprintf (@var{obj}, @var{template} ...) ## Writes formatted string @var{template} using optional parameters to ## UDP instrument ## ## @var{obj} is a UDP object ## @var{template} Format template string ## ## @end deftypefn function numbytes = fprintf (varargin) defaultformat = '%s\n'; if (nargin < 2) print_usage (); elseif (nargin < 3) formargs = varargin(2); format = defaultformat; else(nargin < 4) formargs = varargin(3:nargin); format = varargin{2}; end if (! ( ischar (format))) print_usage (); end numbytes = udp_write (varargin{1}, sprintf (format, formargs{:})); end instrument-control-0.4.0/inst/@octave_udp/fread.m0000644000000000000000000000563113460206417020244 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{data} =} fread (@var{obj}) ## @deftypefnx {Function File} {@var{data} =} fread (@var{obj}, @var{size}) ## @deftypefnx {Function File} {@var{data} =} fread (@var{obj}, @var{size}, @var{precision}) ## @deftypefnx {Function File} {[@var{data},@var{count}] =} fread (@var{obj}, ...) ## @deftypefnx {Function File} {[@var{data},@var{count},@var{errmsg}] =} fread (@var{obj}, ...) ## Reads @var{data} from UDP instrument ## ## @var{obj} is a UDP object ## ## @var{size} Number of values to read. (Default: 100) ## @var{precision} precision of data ## ## @var{count} values read ## @var{errmsg} read operation error message ## ## @end deftypefn function [data, count, errmsg] = fread (obj, size, precision) if (nargin < 2) ## TODO: InputBufferSize property not implemented yet warning("fread: InputBufferSize property not implemented yet, using 100 as default"); size = 100; end if (nargin < 3) precision = 'uchar'; end if ((rows(size) == 1) && (columns(size) == 2)) toread = size(1) * size(2); elseif (numel(size) == 1) toread = size; else print_usage(); endif switch (precision) case {"char" "schar" "int8"} toclass = "int8"; case {"uchar" "uint8"} toclass = "uint8"; case {"int16" "short"} toclass = "int16"; toread = toread * 2; case {"uint16" "ushort"} toclass = "uint16"; case {"int32" "int"} toclass = "int32"; toread = toread * 4; case {"uint32" "uint"} toclass = "uint32"; toread = toread * 4; case {"long" "int64"} toclass = "int64"; toread = toread * 8; case {"ulong" "uint64"} toclass = "uint64"; toread = toread * 8; case {"single" "float" "float32"} toclass = "single"; toread = toread * 4; case {"double" "float64"} toclass = "double"; toread = toread * 8; otherwise error ("precision not supported"); end eoi=0; tmp=[]; count=0; while ((!eoi) && (toread > 0)) tmp1 = udp_read (obj, toread, get(obj, 'timeout')); if !isempty(tmp1) wasread = numel(tmp1); count = count + wasread; toread = toread - wasread; else break; end tmp = [tmp tmp1]; end errmsg = ''; data = typecast(tmp,toclass); if (numel(size) > 1) data = reshape(data,size); end endfunction instrument-control-0.4.0/inst/@octave_udp/fwrite.m0000644000000000000000000000364213460206417020463 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{numbytes} = } fwrite (@var{obj}, @var{data}) ## @deftypefnx {Function File} {@var{numbytes} =} fwrite (@var{obj}, @var{data}, @var{precision}) ## Writes @var{data} to UDP instrument ## ## @var{obj} is a UDP object ## ## @var{data} data to write ## @var{precision} precision of data ## ## returns number of bytes written. ## @end deftypefn function numbytes = fwrite(obj, data, precision) if (nargin < 2) print_usage (); elseif (nargin < 3) precision = []; end switch (precision) case {"char" "schar" "int8"} data = int8 (data); case {"uchar" "uint8"} data = uint8 (data); case {"int16" "short"} data = int16 (data); case {"uint16" "ushort"} data = uint16 (data); case {"int32" "int"} data = int32 (data); case {"uint32" "uint"} data = uint32 (data); case {"long" "int64"} data = int64 (data); case {"ulong" "uint64"} data = uint64 (data); case {"single" "float" "float32"} data = single (data); case {"double" "float64"} data = double (data); case [] %% use data as it is otherwise error ("precision not supported"); end %% should we handle endianess ? numbytes = udp_write (obj, typecast(data,'uint8')); end instrument-control-0.4.0/inst/@octave_udp/get.m0000644000000000000000000000352713460206417017744 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{struct} = } get (@var{udp}) ## @deftypefnx {Function File} {@var{field} = } get (@var{udp}, @var{property}) ## Get the properties of udp object. ## ## @seealso{@@octave_udp/set} ## @end deftypefn function retval = get (udp, property) properties = {'name', 'remoteport', 'remotehost', ... 'localport', 'type', ... 'status', 'timeout', 'bytesavailable'}; if (nargin == 1) property = properties; elseif (nargin > 2) error ("Too many arguments.\n"); end if !iscell (property) property = {property}; end property = tolower(property); valid = ismember (property, properties); not_found = {property{!valid}}; if !isempty (not_found) msg = @(x) error("udp:get:InvalidArgument", ... "Unknown property '%s'.\n",x); cellfun (msg, not_found); end property = {property{valid}}; func = @(x) __udp_properties__ (udp, x); retval = cellfun (func, property, 'UniformOutput', false); if numel(property) == 1 retval = retval{1}; elseif (nargin == 1) retval = cell2struct (retval',properties); end end instrument-control-0.4.0/inst/@octave_udp/set.m0000644000000000000000000000521213460206417017751 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} set (@var{obj}, @var{property},@var{value}) ## @deftypefnx {Function File} set (@var{obj}, @var{property},@var{value},@dots{}) ## Set the properties of udp object. ## ## If @var{property} is a cell so must be @var{value}, it sets the values of ## all matching properties. ## ## The function also accepts property-value pairs. ## ## @table @var ## @item 'name' ## Set the name for the udp socket. ## ## @item 'remotehost' ## Set the remote host name for the udp socket. ## ## @item 'remoteport' ## Set the remote port for the udp socket. ## ## @item 'timeout' ## Set the timeout value in tenths of a second. Value of -1 means a ## blocking call. Maximum value of 255 (i.e. 25.5 seconds). ## ## @end table ## ## @seealso{@@octave_udp/get} ## @end deftypefn function set (udp, varargin) properties = {'remotehost','remoteport','timeout', 'name' }; if numel (varargin) == 1 && isstruct (varargin{1}) property = fieldnames (varargin{1}); func = @(x) getfield (varargin{1}, x); value = cellfun (func, property, 'UniformOutput', false); elseif numel (varargin) == 2 && iscell (varargin{1}) && iscell (varargin{2}) %% The arguments are two cells, expecting fields and values. property = varargin{1}; value = varargin{2}; else property = {varargin{1:2:end}}; value = {varargin{2:2:end}}; end if numel (property) != numel (value) error ('udp:set:InvalidArgument', ... 'PROPERIES and VALUES must have the same number of elements.'); end property = tolower(property); valid = ismember (property, properties); not_found = {property{!valid}}; if !isempty (not_found) msg = @(x) error ("udp:set:InvalidArgument", ... "Property '%s' not found in udp object.\n",x); cellfun (msg, not_found); end property = {property{valid}}; value = {value{valid}}; for i=1:length(property) __udp_properties__ (udp, property{i}, value{i}); end end instrument-control-0.4.0/inst/@octave_usbtmc/0000755000000000000000000000000013460206417017505 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_usbtmc/fclose.m0000644000000000000000000000157413460206417021145 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes USBTMC connection @var{obj} ## @end deftypefn ## TODO: function fclose(fd) usbtmc_close(fd); end instrument-control-0.4.0/inst/@octave_usbtmc/fopen.m0000644000000000000000000000172013460206417020772 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens USBTMC connection @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/@octave_vxi11/0000755000000000000000000000000013460206417017160 5ustar0000000000000000instrument-control-0.4.0/inst/@octave_vxi11/fclose.m0000644000000000000000000000157213460206417020616 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fclose (@var{obj}) ## Closes VXI11 connection @var{obj} ## @end deftypefn ## TODO: function fclose(fd) vxi11_close(fd); end instrument-control-0.4.0/inst/@octave_vxi11/fopen.m0000644000000000000000000000171713460206417020453 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{res} =} fopen (@var{obj}) (dummy) ## Opens VXI11 connection @var{obj} ## This currently is a dummy function to improve compatibility to MATLAB ## ## @end deftypefn function fopen(fd) % dummy for matlab compatibility end instrument-control-0.4.0/inst/clrdevice.m0000644000000000000000000000204513460206417016666 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} clrdevice (@var{obj}) ## Send clear command to Clear GPIB instrument. ## ## @var{obj} is a GPIB object ## ## @end deftypefn ## TODO: function clrdevice (obj) # if (nargin < 1) print_usage(); end if (!isa (obj,'octave_gpib')) error ('clrdevice: need octave_gpib object'); end __gpib_clrdevice__ (obj); instrument-control-0.4.0/inst/instrhwinfo.m0000644000000000000000000000615113460206417017302 0ustar0000000000000000## Copyright (C) 2018-2019 John Donoghue ## Copyright (C) 2016 Andreas Weber ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{list}] =} instrhwinfo () ## @deftypefnx {Function File} {@var{list} =} instrhwinfo (@var{interface}) ## Query available hardware for instrument-control ## ## When run without any input parameters, instrhwinfo will provide the toolbox ## information and a list of supported interfaces. ## ## If an output variable is provided, the function will store the information ## to the variable, otherwise it will be displayed to the screen. ## ## @example ## instrhwinfo ## scalar structure containing the fields: ## ## ToolboxVersion = 0.4.0 ## ToolboxName = octave instrument control package ## SupportedInterfaces = ## @{ ## [1,1] = i2c ## [1,2] = parallel ## [1,3] = serial ## [1,4] = tcp ## [1,5] = udp ## [1,6] = usbtmc ## [1,7] = vxi11 ## @} ## ## @end example ## ## @var{interface} is the instrument interface to query. When provided, instrhwinfo ## will provide information on the specified interface. ## ## Currently only interface "serial" is supported, which will provide a list of ## available serial ports. ## @end deftypefn function out = instrhwinfo (interface) if (nargin == 0) a = __instr_hwinfo__(); if (nargout == 0) disp(a); else out = a; endif elseif (nargin != 1) print_usage (); elseif (strcmpi (interface, "serial")) if (ispc ()) # windoze Skey = 'HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM'; ## Find connected serial devices and clean up the output [~, list] = dos(['REG QUERY ' Skey]); [~, ~, ~, out]=regexp (list, "COM[0-9]+"); elseif (ismac ()) tmp = glob ("/dev/tty.*"); out = strrep (tmp, "/dev/", ""); elseif (isunix ()) # GNU/Linux, BSD... ## only devices with device/driver tmp = glob ("/sys/class/tty/*/device/driver"); tmp = strrep (tmp, "/sys/class/tty/", ""); out = strrep (tmp, "/device/driver", ""); endif else error ("Interface '%s' not yet implemented...", interface); endif endfunction %!test %! a = instrhwinfo(); %! assert(! isempty (a)) %!xtest %! # could fail if no serial ports? %! assert(!isempty(instrhwinfo("serial"))) %!error instrhwinfo("serial", "2ndarg") %!test %! p = pkg('describe', 'instrument-control'); %! hw = instrhwinfo (); %! assert (hw.ToolboxVersion, p{1}.version) instrument-control-0.4.0/inst/seriallist.m0000644000000000000000000000221013460206417017073 0ustar0000000000000000## Copyright (C) 2018 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{list} = } seriallist () ## Returns a list of all serial ports detected in the system. ## ## @var{list} is a string cell array of serial ports names detected ## in the system. ## ## @seealso{instrhwinfo("serial")} ## @end deftypefn function out = seriallist () if nargin != 0 print_usage (); endif out = instrhwinfo("serial"); endfunction %!assert(seriallist, instrhwinfo("serial")) instrument-control-0.4.0/inst/spoll.m0000644000000000000000000000333713460206417016064 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{out} =} spoll (@var{obj}) ## @deftypefnx {Function File} {[@var{out},@var{statusByte}] =} spoll (@var{obj}) ## Serial polls GPIB instruments. ## ## @var{obj} is a GPIB object or a cell array of GPIB objects ## ## @var{out} GPIB objects ready for service ## @var{statusByte} status Byte ## ## @end deftypefn ## TODO: function [out,statusByte] = spoll (obj) # if (nargin < 1) print_usage (); end if iscell (obj) && numel (obj) > 0 if ~all (cellfun (@(x) isa (x,'octave_gpib'),obj)) error ("obj contains wrong elements"); end out = {}; statusByte = []; for i = 1:numel (obj) tmp_status = uint8 (__gpib_spoll__ (obj{i})); if (bitget (tmp_status,7) == 0) out{end+1} = obj{i}; statusByte(end+1) = tmp_status; end end return elseif (!isa (obj,'octave_gpib')) error ('spoll: need octave_gpib object'); end out = []; statusByte = []; tmp_status = uint8 (__gpib_spoll__ (obj)); if (bitget (tmp_status,7) == 0) out = obj; statusByte = tmp_status; end instrument-control-0.4.0/inst/tcpip.m0000644000000000000000000000377013460206417016053 0ustar0000000000000000## Copyright (C) 2018-2019 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{tcp} = } tcpip (@var{host}, [@var{port}], [@var{PropertyName}, @var{PropertyValue}...]) ## Matlab compatible wrapper to the tcp interface. ## ## @var{host} - the host name or ip. ## @var{port} - the port number to connect. If omitted defaults to 80. ## @var{PropertyName}, @var{PropertyValue} - Optional property name, value pairs to set on the tcp object. ## Currently the only known properties are "timeout" and "name". ## ## tcpip will return an instance of @var{octave_tcp} class as the result. ## @end deftypefn function out = tcpip (varargin) if nargin == 0 || (nargin > 1 && !isnumeric(varargin{2})) print_usage (); endif host = varargin{1}; if nargin > 1 port = varargin{2}; else port = 80; endif if nargin > 2 if mod(nargin, 2) != 0 error ("tcpip: expected property name, value pairs"); endif if !iscellstr (varargin(3:2:nargin)) error ("tcpip: expected property names to be strings"); endif endif out = tcp (resolvehost(host, "address"), port); for i = 3:2:nargin propname = tolower(varargin{i}); propvalue = varargin{i+1}; __tcp_properties__ (out, propname, propvalue); endfor endfunction %!test %! a = tcpip ("octave.org", 80); %! assert(isa(a, "octave_tcp")); %! fclose(a); instrument-control-0.4.0/inst/trigger.m0000644000000000000000000000201213460206417016363 0ustar0000000000000000## Copyright (C) 2013 Stefan Mahr ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} trigger (@var{obj}) ## Triggers GPIB instrument. ## ## @var{obj} is a GPIB object ## ## @end deftypefn ## TODO: function trigger (obj) # if (nargin < 1) print_usage(); end if (!isa (obj,'octave_gpib')) error ('trigger: need octave_gpib object'); end __gpib_trigger__ (obj); instrument-control-0.4.0/inst/udp_demo.m0000644000000000000000000000430313460206417016521 0ustar0000000000000000## Copyright (C) 2016 John Donoghue ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{result} =} udp_demo () ## Run test SNTP demonstration for udp class ## ## @seealso{udp} ## @end deftypefn ## Author: john donoghue ## Created: 2016-11-23 function result = udp_demo () result = false; server = 'pool.ntp.org'; fprintf ('getting time from %s\n', server); # query time using SNTP s = udp (server, 123); # send request packet data = [uint8(0x1b) uint8(zeros (1,47))]; res = udp_write (s, data); # recieve packet data = udp_read (s,48, 4000); # should have 48 bytes reply if length (data) == 48 # convert uint8s to integer32 dataL = typecast (data, 'uint32'); # convert to little endian if we are on a little endian machine if typecast (uint8([1 0]), 'uint16') == 1 dataL = swapbytes (dataL); endif # network time ntimeval = dataL(11) - 2208988800; # get system time ltimeval = uint32 (time()); fprintf ('network time=%lu local time=%lu\n', ... ntimeval, ltimeval); result = true; endif fclose (s); endfunction %!test % assert(udp_demo) %!test % s = udp('127.0.0.1', 80); % assert(!isempty(s)); % assert(get(s,'name'), 'UDP-127.0.0.1'); % assert(get(s,'remoteport'), 80); % assert(get(s,'remotehost','127.0.0.1'); % assert(get(s,'localport')) % set(s,'name', 'test'); % assert(get(s,'name'), 'test'); % udp_close(s); %!test % s = udp('127.0.0.1', 80); % assert(get(s,'status'), 'open'); % fclose(s); % assert(get(s,'status'), 'closed'); instrument-control-0.4.0/src/0000755000000000000000000000000013460206417014361 5ustar0000000000000000instrument-control-0.4.0/src/Makefile.in0000644000000000000000000000216013460206417016425 0ustar0000000000000000 SUBDIRS = serial parallel i2c usbtmc tcp udp gpib vxi11 resolvehost hwinfo MKOCTFILE ?= mkoctfile GREP ?= grep .PHONY: clean .PHONY: realclean .PHONY: distclean .PHONY: $(SUBDIRS) .PHONY: make-pkg-add_file all: $(SUBDIRS) make-pkg-add-file.cc $(SUBDIRS): $(MAKE) -C $@ # pkg install doesnt look in subdirs of src to make pkgadd/del so we # make a source file that it will see CC_SOURCES = $(wildcard */*.cc) make-pkg-add-file.cc: $(CC_SOURCES) @echo "Generating pkg add/del $@ ..." @( echo "// Generated file for PKG_ADD/DEL inclusion"; \ $(GREP) -h '// PKG_' $^) > "$@" CLEANDIRS = $(SUBDIRS:%=clean-%) DISTCLEANDIRS = $(SUBDIRS:%=distclean-%) .PHONY: $(CLEANDIRS) .PHONY: $(DISTCLEANDIRS) $(CLEANDIRS): $(MAKE) -C $(@:clean-%=%) clean $(DISTCLEANDIRS): $(MAKE) -C $(@:distclean-%=%) distclean clean: $(CLEANDIRS) realclean: -rm -f *.oct -rm -f make-pkg-add-file.cc: distclean: realclean $(DISTCLEANDIRS) -rm -rf autom4te.cache -rm -f Makefile config.status config.log config.h maintainer-clean: distclean -rm -f configure # and prebuild stuff we need do prebuild: $(MAKE) -C vxi11 prebuild instrument-control-0.4.0/src/aclocal.m40000644000000000000000000002527713460206417016236 0ustar0000000000000000# generated automatically by aclocal 1.15 -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- dnl serial 11 (pkg-config-0.29) dnl dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR m4_include([m4/octave-forge.m4]) instrument-control-0.4.0/src/bootstrap0000755000000000000000000000031713460206417016325 0ustar0000000000000000#!/bin/bash ## Octave-Forge: video package bootstrap script ## Run this to generate the configure script set -e # halt if unhandled error aclocal autoconf # generate configure script autoheader -f instrument-control-0.4.0/src/config.h.in0000644000000000000000000000660613460206417016414 0ustar0000000000000000/* config.h.in. Generated from configure.ac by autoheader. */ #include "undef-ah-octave.h" /* build GPIB interface functions */ #undef BUILD_GPIB /* build I2C interface functions */ #undef BUILD_I2C /* build PARALLEL interface functions */ #undef BUILD_PARALLEL /* build resolvehost function */ #undef BUILD_RESOLVEHOST /* build SERIAL interface functions */ #undef BUILD_SERIAL /* build TCP interface functions */ #undef BUILD_TCP /* build UDP interface functions */ #undef BUILD_UDP /* build USBTMC interface functions */ #undef BUILD_USBTMC /* build VISA interface functions */ #undef BUILD_VISA /* build VXI11 interface functions */ #undef BUILD_VXI11 /* clnt allows const inputs */ #undef CONST_CLNT_SUPPORT /* Define to 1 if you have the header file. */ #undef HAVE_DEV_IICBUS_IIC_H /* Define to 1 if you have the header file. */ #undef HAVE_DEV_PPBUS_PPBCONF_H /* Define to 1 if you have the header file. */ #undef HAVE_DEV_PPBUS_PPI_H /* Define to 1 if you have the header file. */ #undef HAVE_GPIB_IB_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_I2C_DEV_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_PARPORT_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_PPDEV_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_RPC_RPC_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_VISA_VISA_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Use new register_binary_op */ #undef OCTAVE__NEW_REGISTER_OP /* macro for alternative Octave symbols */ #undef OCTAVE__REGISTER_BINARY_OP /* macro for alternative Octave symbols */ #undef OCTAVE__UNWIND_PROTECT /* macro for alternative Octave symbols */ #undef OV_ISFLOAT /* macro for alternative Octave symbols */ #undef OV_ISINTEGER /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS #include "oct-alt-includes.h" instrument-control-0.4.0/src/configure0000755000000000000000000047257513460206417016314 0ustar0000000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for octave instrument control package 0.4.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='octave instrument control package' PACKAGE_TARNAME='octave-instrument-control-package' PACKAGE_VERSION='0.4.0' PACKAGE_STRING='octave instrument control package 0.4.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS BUILD_VXI11 VISALIBS RPCGENOPTS RPCGEN RPCLIBS RPCINCLUDE TIRPC_LIBS TIRPC_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG GPIBLIBS TCPLIBS EGREP CXXCPP BUILD_FOR_WINDOWS GREP MKOCTFILE OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_librpc ' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR TIRPC_CFLAGS TIRPC_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures octave instrument control package 0.4.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/octave-instrument-control-package] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of octave instrument control package 0.4.0:";; esac cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-librpc=tirpc|sunrpc|auto|none Choose use/selection of librpc used Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path TIRPC_CFLAGS C compiler flags for TIRPC, overriding pkg-config TIRPC_LIBS linker flags for TIRPC, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF octave instrument control package configure 0.4.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by octave instrument control package $as_me 0.4.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" # Avoid warnings for redefining AH-generated preprocessor symbols of # Octave. # Checks for programs. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # Define macros needed #AC_DEFINE(__STDC_CONSTANT_MACROS, [], [workaround for C++ programs to use C99 macros]) # Extract the first word of "mkoctfile", so it can be a program name with args. set dummy mkoctfile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MKOCTFILE+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MKOCTFILE"; then ac_cv_prog_MKOCTFILE="$MKOCTFILE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MKOCTFILE="mkoctfile" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_MKOCTFILE" && ac_cv_prog_MKOCTFILE="none" fi fi MKOCTFILE=$ac_cv_prog_MKOCTFILE if test -n "$MKOCTFILE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKOCTFILE" >&5 $as_echo "$MKOCTFILE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "$MKOCTFILE" = "none"; then as_fn_error $? "mkoctfile required to install $PACKAGE_NAME" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" ## Simple symbol alternatives of different Octave versions. save_altsyms_CXX="$CXX" save_altsyms_CXXFLAGS="$CXXFLAGS" save_altsyms_LDFLAGS="$LDFLAGS" save_altsyms_LIBS="$LIBS" OCTINCLUDEDIR=${OCTINCLUDEDIR:-`$MKOCTFILE -p INCFLAGS`} OCTLIBDIR=${OCTLIBDIR:-`$MKOCTFILE -p OCTLIBDIR`} CXX=`${MKOCTFILE} -p CXX` CXXFLAGS="$OCTINCLUDEDIR $CXXFLAGS" LDFLAGS="-L$OCTLIBDIR $LDFLAGS" LIBS="-loctinterp $LIBS" echo '/* generated by configure */' > oct-alt-includes.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_float_type or isfloat" >&5 $as_echo_n "checking is_float_type or isfloat... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().isfloat (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISFLOAT isfloat" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: isfloat" >&5 $as_echo "isfloat" >&6; } echo ' ' >> oct-alt-includes.h ac_cv_octsym_OV_ISFLOAT="isfloat" else $as_echo "#define OV_ISFLOAT is_float_type" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_float_type" >&5 $as_echo " is_float_type" >&6; } echo '' >> oct-alt-includes.h ac_cv_octsym_OV_ISFLOAT=" is_float_type" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_integer_type or isinteger" >&5 $as_echo_n "checking is_integer_type or isinteger... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().isinteger (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISINTEGER isinteger" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: isinteger" >&5 $as_echo "isinteger" >&6; } echo ' ' >> oct-alt-includes.h ac_cv_octsym_OV_ISINTEGER="isinteger" else $as_echo "#define OV_ISINTEGER is_integer_type" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_integer_type" >&5 $as_echo " is_integer_type" >&6; } echo '' >> oct-alt-includes.h ac_cv_octsym_OV_ISINTEGER=" is_integer_type" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking unwind_protect or octave::unwind_protect" >&5 $as_echo_n "checking unwind_protect or octave::unwind_protect... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { octave::unwind_protect frame; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OCTAVE__UNWIND_PROTECT octave::unwind_protect" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave::unwind_protect" >&5 $as_echo "octave::unwind_protect" >&6; } echo '#include #include ' >> oct-alt-includes.h ac_cv_octsym_OCTAVE__UNWIND_PROTECT="octave::unwind_protect" else $as_echo "#define OCTAVE__UNWIND_PROTECT unwind_protect" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: unwind_protect" >&5 $as_echo " unwind_protect" >&6; } echo '#include #include ' >> oct-alt-includes.h ac_cv_octsym_OCTAVE__UNWIND_PROTECT=" unwind_protect" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking octave_value_typeinfo::register_binary_op or octave::type_info::register_binary_op" >&5 $as_echo_n "checking octave_value_typeinfo::register_binary_op or octave::type_info::register_binary_op... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { octave::type_info& ti = octave::interpreter::the_interpreter ()->get_type_info (); ti.register_binary_op(octave_value::op_eq, 1,1,0); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OCTAVE__REGISTER_BINARY_OP octave::type_info::register_binary_op" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave::type_info::register_binary_op" >&5 $as_echo "octave::type_info::register_binary_op" >&6; } echo ' #include #include ' >> oct-alt-includes.h ac_cv_octsym_OCTAVE__REGISTER_BINARY_OP="octave::type_info::register_binary_op" else $as_echo "#define OCTAVE__REGISTER_BINARY_OP octave_value_typeinfo::register_binary_op" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave_value_typeinfo::register_binary_op" >&5 $as_echo " octave_value_typeinfo::register_binary_op" >&6; } echo '#include ' >> oct-alt-includes.h ac_cv_octsym_OCTAVE__REGISTER_BINARY_OP=" octave_value_typeinfo::register_binary_op" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_octsym_OCTAVE__REGISTER_BINARY_OP == "octave::type_info::register_binary_op"; then $as_echo "#define OCTAVE__NEW_REGISTER_OP /**/" >>confdefs.h fi CXX=$save_altsyms_CXX CXXFLAGS=$save_altsyms_CXXFLAGS LDFLAGS=$save_altsyms_LDFLAGS LIBS=$save_altsyms_LIBS build_parallel=no build_serial=no build_i2c=no build_usbtmc=no build_tcp=no build_udp=no build_gpib=no build_vxi11=no build_visa=no build_resolvehost=no # Check for Windows { $as_echo "$as_me:${as_lineno-$LINENO}: checking for windows" >&5 $as_echo_n "checking for windows... " >&6; } have_windows=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef __WIN32__ #error "Not windows!" #endif int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_windows=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # if windows, we can build some of the packages just by having # windows.h if test $have_windows = yes; then build_serial=yes BUILD_FOR_WINDOWS=1 fi # check for i2c # if linux/i2c-dev.h exists we are probably under linux, so build usbtmc as well ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in linux/i2c-dev.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "linux/i2c-dev.h" "ac_cv_header_linux_i2c_dev_h" "$ac_includes_default" if test "x$ac_cv_header_linux_i2c_dev_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_I2C_DEV_H 1 _ACEOF build_i2c=yes build_usbtmc=yes fi done for ac_header in dev/iicbus/iic.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "dev/iicbus/iic.h" "ac_cv_header_dev_iicbus_iic_h" "$ac_includes_default" if test "x$ac_cv_header_dev_iicbus_iic_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DEV_IICBUS_IIC_H 1 _ACEOF build_i2c=yes fi done # check for serial for ac_header in termios.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "termios.h" "ac_cv_header_termios_h" "$ac_includes_default" if test "x$ac_cv_header_termios_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TERMIOS_H 1 _ACEOF build_serial=yes fi done # check for parallel for ac_header in linux/parport.h linux/ppdev.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF build_parallel=yes fi done for ac_header in dev/ppbus/ppi.h dev/ppbus/ppbconf.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF build_parallel=yes fi done # build tcp, available for most platforms for ac_header in sys/socket.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" if test "x$ac_cv_header_sys_socket_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SOCKET_H 1 _ACEOF build_tcp=yes fi done # Check for winsock2 and ws2_32 have_winsock2=no for ac_header in winsock2.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _head_libws2_32_a" >&5 $as_echo_n "checking for library containing _head_libws2_32_a... " >&6; } if ${ac_cv_search__head_libws2_32_a+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char _head_libws2_32_a (); int main () { return _head_libws2_32_a (); ; return 0; } _ACEOF for ac_lib in '' ws2_32; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search__head_libws2_32_a=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search__head_libws2_32_a+:} false; then : break fi done if ${ac_cv_search__head_libws2_32_a+:} false; then : else ac_cv_search__head_libws2_32_a=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__head_libws2_32_a" >&5 $as_echo "$ac_cv_search__head_libws2_32_a" >&6; } ac_res=$ac_cv_search__head_libws2_32_a if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" have_winsock2=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _head_lib32_libws2_32_a" >&5 $as_echo_n "checking for library containing _head_lib32_libws2_32_a... " >&6; } if ${ac_cv_search__head_lib32_libws2_32_a+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char _head_lib32_libws2_32_a (); int main () { return _head_lib32_libws2_32_a (); ; return 0; } _ACEOF for ac_lib in '' ws2_32; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search__head_lib32_libws2_32_a=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search__head_lib32_libws2_32_a+:} false; then : break fi done if ${ac_cv_search__head_lib32_libws2_32_a+:} false; then : else ac_cv_search__head_lib32_libws2_32_a=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__head_lib32_libws2_32_a" >&5 $as_echo "$ac_cv_search__head_lib32_libws2_32_a" >&6; } ac_res=$ac_cv_search__head_lib32_libws2_32_a if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" have_winsock2=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _head_lib64_libws2_32_a" >&5 $as_echo_n "checking for library containing _head_lib64_libws2_32_a... " >&6; } if ${ac_cv_search__head_lib64_libws2_32_a+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char _head_lib64_libws2_32_a (); int main () { return _head_lib64_libws2_32_a (); ; return 0; } _ACEOF for ac_lib in '' ws2_32; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search__head_lib64_libws2_32_a=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search__head_lib64_libws2_32_a+:} false; then : break fi done if ${ac_cv_search__head_lib64_libws2_32_a+:} false; then : else ac_cv_search__head_lib64_libws2_32_a=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__head_lib64_libws2_32_a" >&5 $as_echo "$ac_cv_search__head_lib64_libws2_32_a" >&6; } ac_res=$ac_cv_search__head_lib64_libws2_32_a if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" have_winsock2=yes fi fi done if test $have_winsock2 = yes; then TCPLIBS="-lws2_32" build_tcp=yes build_resolvehost=yes fi # if can build tcp, can build udp if test $build_tcp = yes; then build_udp=yes fi # checks for resolve host if test $build_tcp = yes; then if test $build_resolvehost = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getnameinfo" >&5 $as_echo_n "checking for library containing getnameinfo... " >&6; } if ${ac_cv_search_getnameinfo+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char getnameinfo (); int main () { return getnameinfo (); ; return 0; } _ACEOF for ac_lib in '' inet6 socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_getnameinfo=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_getnameinfo+:} false; then : break fi done if ${ac_cv_search_getnameinfo+:} false; then : else ac_cv_search_getnameinfo=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getnameinfo" >&5 $as_echo "$ac_cv_search_getnameinfo" >&6; } ac_res=$ac_cv_search_getnameinfo if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" build_resolvehost=yes fi if test "x$ac_cv_search_getnameinfo" != "xno"; then test "x$ac_cv_search_getnameinfo" = "xnone required" || TCPLIBS=$ac_cv_search_getnameinfo fi fi fi # Checks for GPIB for ac_header in gpib/ib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "gpib/ib.h" "ac_cv_header_gpib_ib_h" "$ac_includes_default" if test "x$ac_cv_header_gpib_ib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GPIB_IB_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ibrd" >&5 $as_echo_n "checking for library containing ibrd... " >&6; } if ${ac_cv_search_ibrd+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ibrd (); int main () { return ibrd (); ; return 0; } _ACEOF for ac_lib in '' gpib; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_ibrd=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_ibrd+:} false; then : break fi done if ${ac_cv_search_ibrd+:} false; then : else ac_cv_search_ibrd=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ibrd" >&5 $as_echo "$ac_cv_search_ibrd" >&6; } ac_res=$ac_cv_search_ibrd if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" build_gpib=yes fi fi done if test "x$ac_cv_search_ibrd" != "xno"; then test "x$ac_cv_search_ibrd" = "xnone required" || GPIBLIBS=$ac_cv_search_ibrd fi # Checks for RPC/VXI11 # Check whether --with-librpc was given. if test "${with_librpc+set}" = set; then : withval=$with_librpc; with_libtirpc="$with_librpc" else with_librpc="auto" fi if test "x${with_librpc}" = "xyes"; then with_librpc="auto" fi if test "x${with_librpc}" = "xno"; then with_librpc="none" fi if test "x${with_librpc}" = "xauto" || test "x${with_librpc}" = "xtirpc"; then if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIRPC" >&5 $as_echo_n "checking for TIRPC... " >&6; } if test -n "$TIRPC_CFLAGS"; then pkg_cv_TIRPC_CFLAGS="$TIRPC_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TIRPC_CFLAGS=`$PKG_CONFIG --cflags "libtirpc" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$TIRPC_LIBS"; then pkg_cv_TIRPC_LIBS="$TIRPC_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TIRPC_LIBS=`$PKG_CONFIG --libs "libtirpc" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then TIRPC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtirpc" 2>&1` else TIRPC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtirpc" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$TIRPC_PKG_ERRORS" >&5 RPCINCLUDE="$RPCINCLUDE" elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } RPCINCLUDE="$RPCINCLUDE" else TIRPC_CFLAGS=$pkg_cv_TIRPC_CFLAGS TIRPC_LIBS=$pkg_cv_TIRPC_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } with_librpc="yes"; build_vxi11=yes; RPCINCLUDE="$RPCINCLUDE $TIRPC_CFLAGS"; RPCLIBS="$RPCLIBS $TIRPC_LIBS"; fi fi if test "x${with_librpc}" = "xauto" || test "x${with_librpc}" = "xsunrpc"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clnt_create" >&5 $as_echo_n "checking for library containing clnt_create... " >&6; } if ${ac_cv_search_clnt_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clnt_create (); int main () { return clnt_create (); ; return 0; } _ACEOF for ac_lib in '' tirpc; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_clnt_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_clnt_create+:} false; then : break fi done if ${ac_cv_search_clnt_create+:} false; then : else ac_cv_search_clnt_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clnt_create" >&5 $as_echo "$ac_cv_search_clnt_create" >&6; } ac_res=$ac_cv_search_clnt_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" with_librpc="yes" fi if test "x$ac_cv_search_clnt_create" != "xnone required"; then RPCLIBS="$RPCLIBS $ac_cv_search_clnt_create" fi for ac_header in rpc/rpc.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "rpc/rpc.h" "ac_cv_header_rpc_rpc_h" "$ac_includes_default" if test "x$ac_cv_header_rpc_rpc_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_RPC_RPC_H 1 _ACEOF RPCINCLUDE="$RPC_CFLAGS" else with_librpc="no"; build_vxi11=no fi done fi if test "x${with_librpc}" = "xauto"; then with_librpc="none" fi # with_librpc should now be yes, if found # none if was never wanted or not auto detected if test "x${with_librpc}" != "xyes" && test "x${with_librpc}" != "xnone"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Did not find valid rpc libraries" >&5 $as_echo "$as_me: WARNING: Did not find valid rpc libraries" >&2;} fi if test "x${with_librpc}" = "xyes"; then build_vxi11=yes # we support const input into clnt_create ? { $as_echo "$as_me:${as_lineno-$LINENO}: checking const input allowed into clnt_perror" >&5 $as_echo_n "checking const input allowed into clnt_perror... " >&6; } const_clnt_perror=no ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu save_LIBS=$LIBS save_CPPFLAGS=$CPPFLAGS LIBS=$RPCLIBS CPPFLAGS=$RPCINCLUDE cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { const char * msg = "const message"; CLIENT *clnt = 0; clnt_perror(clnt, msg); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } const_clnt_perror=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext LIBS=$save_LIBS= CPPFLAGS=$save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test $const_clnt_perror = yes; then $as_echo "#define CONST_CLNT_SUPPORT 1" >>confdefs.h fi # we have rpcgen for ac_prog in rpcgen rpcgen-mt do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RPCGEN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RPCGEN"; then ac_cv_prog_RPCGEN="$RPCGEN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RPCGEN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RPCGEN=$ac_cv_prog_RPCGEN if test -n "$RPCGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RPCGEN" >&5 $as_echo "$RPCGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$RPCGEN" && break done test -n "$RPCGEN" || RPCGEN="none" if test "xRPCGEN" = "xnone"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: No rpcgen found - if rpc sources are modified, the build will fail" >&5 $as_echo "$as_me: WARNING: No rpcgen found - if rpc sources are modified, the build will fail" >&2;} else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${RPCGEN} accepts -M option" >&5 $as_echo_n "checking whether ${RPCGEN} accepts -M option... " >&6; } rm -f rpcgen_test.* cat > rpcgen_test.x < /dev/null 2>&1 if test -f rpcgen_test.h; then _rpcgen_result=yes RPCGENOPTS="-M" else _rpcgen_result=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_rpcgen_result" >&5 $as_echo "$_rpcgen_result" >&6; } RPCGENOPTS=$RPCGENOPTS rm -f rpcgen_test.* rm -f rpcgen_test_* fi fi # Checks for openvisa for ac_header in visa/visa.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "visa/visa.h" "ac_cv_header_visa_visa_h" "$ac_includes_default" if test "x$ac_cv_header_visa_visa_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VISA_VISA_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing viOpenDefaultRM" >&5 $as_echo_n "checking for library containing viOpenDefaultRM... " >&6; } if ${ac_cv_search_viOpenDefaultRM+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char viOpenDefaultRM (); int main () { return viOpenDefaultRM (); ; return 0; } _ACEOF for ac_lib in '' openvisa; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_viOpenDefaultRM=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_viOpenDefaultRM+:} false; then : break fi done if ${ac_cv_search_viOpenDefaultRM+:} false; then : else ac_cv_search_viOpenDefaultRM=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_viOpenDefaultRM" >&5 $as_echo "$ac_cv_search_viOpenDefaultRM" >&6; } ac_res=$ac_cv_search_viOpenDefaultRM if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" build_visa=yes fi fi done if test "x$ac_cv_search_viOpenDefaultRM" != "xno"; then test "x$ac_cv_search_viOpenDefaultRM" = "xnone required" || VISALIBS=$ac_cv_search_viOpenDefaultRM fi # if test $build_parallel = yes; then $as_echo "#define BUILD_PARALLEL /**/" >>confdefs.h fi if test $build_serial = yes; then $as_echo "#define BUILD_SERIAL /**/" >>confdefs.h fi if test $build_i2c = yes; then $as_echo "#define BUILD_I2C /**/" >>confdefs.h fi if test $build_usbtmc = yes; then $as_echo "#define BUILD_USBTMC /**/" >>confdefs.h fi if test $build_tcp = yes; then $as_echo "#define BUILD_TCP /**/" >>confdefs.h fi if test $build_udp = yes; then $as_echo "#define BUILD_UDP /**/" >>confdefs.h fi if test $build_gpib = yes; then $as_echo "#define BUILD_GPIB /**/" >>confdefs.h fi if test $build_vxi11 = yes; then $as_echo "#define BUILD_VXI11 /**/" >>confdefs.h BUILD_VXI11=1 fi if test $build_visa = yes; then $as_echo "#define BUILD_VISA /**/" >>confdefs.h fi if test $build_resolvehost = yes; then $as_echo "#define BUILD_RESOLVEHOST /**/" >>confdefs.h fi # all done ac_config_files="$ac_config_files Makefile gpib/Makefile tcp/Makefile udp/Makefile vxi11/Makefile usbtmc/Makefile serial/Makefile parallel/Makefile i2c/Makefile resolvehost/Makefile hwinfo/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by octave instrument control package $as_me 0.4.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ octave instrument control package config.status 0.4.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "gpib/Makefile") CONFIG_FILES="$CONFIG_FILES gpib/Makefile" ;; "tcp/Makefile") CONFIG_FILES="$CONFIG_FILES tcp/Makefile" ;; "udp/Makefile") CONFIG_FILES="$CONFIG_FILES udp/Makefile" ;; "vxi11/Makefile") CONFIG_FILES="$CONFIG_FILES vxi11/Makefile" ;; "usbtmc/Makefile") CONFIG_FILES="$CONFIG_FILES usbtmc/Makefile" ;; "serial/Makefile") CONFIG_FILES="$CONFIG_FILES serial/Makefile" ;; "parallel/Makefile") CONFIG_FILES="$CONFIG_FILES parallel/Makefile" ;; "i2c/Makefile") CONFIG_FILES="$CONFIG_FILES i2c/Makefile" ;; "resolvehost/Makefile") CONFIG_FILES="$CONFIG_FILES resolvehost/Makefile" ;; "hwinfo/Makefile") CONFIG_FILES="$CONFIG_FILES hwinfo/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi { $as_echo "$as_me:${as_lineno-$LINENO}: $PACKAGE_NAME is now configured with BUILD SERIAL: $build_serial BUILD PARALLEL: $build_parallel BUILD I2C: $build_i2c BUILD TCP: $build_tcp BUILD UDP: $build_udp BUILD USBTMC: $build_usbtmc BUILD GPIB: $build_gpib BUILD VXI11: $build_vxi11 BUILD RESOLVEHOST: $build_resolvehost GPIB LIBS: $GPIBLIBS VXI11 LIBS: $RPCLIBS VXI11 INCLUDE: $RPCINCLUDE VISA LIBS: $VISALIBS TCP LIBS: $TCPLIBS " >&5 $as_echo "$as_me: $PACKAGE_NAME is now configured with BUILD SERIAL: $build_serial BUILD PARALLEL: $build_parallel BUILD I2C: $build_i2c BUILD TCP: $build_tcp BUILD UDP: $build_udp BUILD USBTMC: $build_usbtmc BUILD GPIB: $build_gpib BUILD VXI11: $build_vxi11 BUILD RESOLVEHOST: $build_resolvehost GPIB LIBS: $GPIBLIBS VXI11 LIBS: $RPCLIBS VXI11 INCLUDE: $RPCINCLUDE VISA LIBS: $VISALIBS TCP LIBS: $TCPLIBS " >&6;} instrument-control-0.4.0/src/configure.ac0000644000000000000000000002262513460206417016656 0ustar0000000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.67]) AC_INIT([octave instrument control package], [0.4.0]) AC_CONFIG_HEADERS([config.h]) # Avoid warnings for redefining AH-generated preprocessor symbols of # Octave. AH_TOP([#include "undef-ah-octave.h"]) AC_CONFIG_MACRO_DIRS([m4]) # Checks for programs. AC_PROG_CXX AC_LANG(C++) # Define macros needed #AC_DEFINE(__STDC_CONSTANT_MACROS, [], [workaround for C++ programs to use C99 macros]) AC_CHECK_PROG([MKOCTFILE], [mkoctfile], [mkoctfile], [none]) if [test "$MKOCTFILE" = "none"]; then AC_MSG_ERROR([mkoctfile required to install $PACKAGE_NAME]) fi AC_PROG_GREP ## Simple symbol alternatives of different Octave versions. save_altsyms_CXX="$CXX" save_altsyms_CXXFLAGS="$CXXFLAGS" save_altsyms_LDFLAGS="$LDFLAGS" save_altsyms_LIBS="$LIBS" OCTINCLUDEDIR=${OCTINCLUDEDIR:-`$MKOCTFILE -p INCFLAGS`} OCTLIBDIR=${OCTLIBDIR:-`$MKOCTFILE -p OCTLIBDIR`} CXX=`${MKOCTFILE} -p CXX` CXXFLAGS="$OCTINCLUDEDIR $CXXFLAGS" LDFLAGS="-L$OCTLIBDIR $LDFLAGS" LIBS="-loctinterp $LIBS" OF_OCTAVE_LIST_ALT_SYMS([ [dnl [is_float_type], [isfloat], [[octave_value ().isfloat ();]], [OV_ISFLOAT], [], [] ], [dnl [is_integer_type], [isinteger], [[octave_value ().isinteger ();]], [OV_ISINTEGER], [], [] ], [dnl [unwind_protect], [octave::unwind_protect], [[octave::unwind_protect frame;]], [OCTAVE__UNWIND_PROTECT], [[#include ] [#include ] ], [[#include ] [#include ] ] ], [dnl [octave_value_typeinfo::register_binary_op], [octave::type_info::register_binary_op], [ [octave::type_info& ti = octave::interpreter::the_interpreter ()->get_type_info ();] [ti.register_binary_op(octave_value::op_eq, 1,1,0);] ], [OCTAVE__REGISTER_BINARY_OP], [[#include ]], [ [#include ] [#include ] ] ] ],[oct-alt-includes.h]) if test $ac_cv_octsym_OCTAVE__REGISTER_BINARY_OP == "octave::type_info::register_binary_op"; then AC_DEFINE([OCTAVE__NEW_REGISTER_OP], [], [Use new register_binary_op]) fi CXX=$save_altsyms_CXX CXXFLAGS=$save_altsyms_CXXFLAGS LDFLAGS=$save_altsyms_LDFLAGS LIBS=$save_altsyms_LIBS build_parallel=no build_serial=no build_i2c=no build_usbtmc=no build_tcp=no build_udp=no build_gpib=no build_vxi11=no build_visa=no build_resolvehost=no # Check for Windows AC_MSG_CHECKING([for windows]) have_windows=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifndef __WIN32__ #error "Not windows!" #endif ]], [])], [AC_MSG_RESULT([yes]) have_windows=yes], [AC_MSG_RESULT([no])]) # if windows, we can build some of the packages just by having # windows.h if test $have_windows = yes; then build_serial=yes AC_SUBST([BUILD_FOR_WINDOWS], [1], [build using native windows functions]) fi # check for i2c # if linux/i2c-dev.h exists we are probably under linux, so build usbtmc as well AC_CHECK_HEADERS([linux/i2c-dev.h],[build_i2c=yes build_usbtmc=yes]) AC_CHECK_HEADERS([dev/iicbus/iic.h],[build_i2c=yes]) # check for serial AC_CHECK_HEADERS([termios.h],[build_serial=yes]) # check for parallel AC_CHECK_HEADERS([linux/parport.h linux/ppdev.h],[build_parallel=yes]) AC_CHECK_HEADERS([dev/ppbus/ppi.h dev/ppbus/ppbconf.h],[build_parallel=yes]) # build tcp, available for most platforms AC_CHECK_HEADERS([sys/socket.h],[build_tcp=yes]) # Check for winsock2 and ws2_32 have_winsock2=no AC_CHECK_HEADERS([winsock2.h], [AC_SEARCH_LIBS([_head_libws2_32_a], [ws2_32], [have_winsock2=yes] , [] ) AC_SEARCH_LIBS([_head_lib32_libws2_32_a], [ws2_32], [have_winsock2=yes] , [] ) AC_SEARCH_LIBS([_head_lib64_libws2_32_a], [ws2_32], [have_winsock2=yes] , [] ) ], []) if test $have_winsock2 = yes; then AC_SUBST(TCPLIBS, ["-lws2_32"]) build_tcp=yes build_resolvehost=yes fi # if can build tcp, can build udp if test $build_tcp = yes; then build_udp=yes fi # checks for resolve host if test $build_tcp = yes; then if test $build_resolvehost = no; then AC_SEARCH_LIBS(getnameinfo, [inet6 socket], [build_resolvehost=yes]) if test "x$ac_cv_search_getnameinfo" != "xno"; then test "x$ac_cv_search_getnameinfo" = "xnone required" || AC_SUBST(TCPLIBS, [$ac_cv_search_getnameinfo]) fi fi fi # Checks for GPIB AC_CHECK_HEADERS([gpib/ib.h], [AC_SEARCH_LIBS([ibrd], [gpib], [build_gpib=yes], [])] , [] ) if test "x$ac_cv_search_ibrd" != "xno"; then test "x$ac_cv_search_ibrd" = "xnone required" || AC_SUBST(GPIBLIBS, [$ac_cv_search_ibrd]) fi # Checks for RPC/VXI11 AC_ARG_WITH([librpc], [AC_HELP_STRING([--with-librpc=tirpc|sunrpc|auto|none], [Choose use/selection of librpc used])], [with_libtirpc="$with_librpc"], [with_librpc="auto"]) if test "x${with_librpc}" = "xyes"; then with_librpc="auto" fi if test "x${with_librpc}" = "xno"; then with_librpc="none" fi if test "x${with_librpc}" = "xauto" || test "x${with_librpc}" = "xtirpc"; then PKG_CHECK_MODULES([TIRPC], [libtirpc], [with_librpc="yes"; build_vxi11=yes; RPCINCLUDE="$RPCINCLUDE $TIRPC_CFLAGS"; RPCLIBS="$RPCLIBS $TIRPC_LIBS";], [RPCINCLUDE="$RPCINCLUDE"]) fi if test "x${with_librpc}" = "xauto" || test "x${with_librpc}" = "xsunrpc"; then AC_SEARCH_LIBS([clnt_create], [tirpc], [with_librpc="yes"], []) if test "x$ac_cv_search_clnt_create" != "xnone required"; then RPCLIBS="$RPCLIBS $ac_cv_search_clnt_create" fi AC_CHECK_HEADERS([rpc/rpc.h],[RPCINCLUDE="$RPC_CFLAGS"],[with_librpc="no"; build_vxi11=no]) fi if test "x${with_librpc}" = "xauto"; then with_librpc="none" fi AC_SUBST(RPCINCLUDE) AC_SUBST(RPCLIBS) # with_librpc should now be yes, if found # none if was never wanted or not auto detected if test "x${with_librpc}" != "xyes" && test "x${with_librpc}" != "xnone"; then AC_MSG_WARN([Did not find valid rpc libraries]) fi if test "x${with_librpc}" = "xyes"; then build_vxi11=yes # we support const input into clnt_create ? AC_MSG_CHECKING([const input allowed into clnt_perror]) const_clnt_perror=no AC_LANG_PUSH([C++]) save_LIBS=$LIBS save_CPPFLAGS=$CPPFLAGS LIBS=$RPCLIBS CPPFLAGS=$RPCINCLUDE AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ const char * msg = "const message"; CLIENT *clnt = 0; clnt_perror(clnt, msg); ]])], [AC_MSG_RESULT([yes]) const_clnt_perror=yes], [AC_MSG_RESULT([no])] ) LIBS=$save_LIBS= CPPFLAGS=$save_CPPFLAGS AC_LANG_POP([C++]) if test $const_clnt_perror = yes; then AC_DEFINE([CONST_CLNT_SUPPORT], [1], [clnt allows const inputs]) fi # we have rpcgen AC_CHECK_PROGS([RPCGEN], [rpcgen rpcgen-mt], [none]) if test "xRPCGEN" = "xnone"; then AC_MSG_WARN([No rpcgen found - if rpc sources are modified, the build will fail]) else AC_MSG_CHECKING([whether ${RPCGEN} accepts -M option]) rm -f rpcgen_test.* cat > rpcgen_test.x < /dev/null 2>&1 if test -f rpcgen_test.h; then _rpcgen_result=yes RPCGENOPTS="-M" else _rpcgen_result=no fi AC_MSG_RESULT([$_rpcgen_result]) AC_SUBST([RPCGENOPTS], [$RPCGENOPTS]) rm -f rpcgen_test.* rm -f rpcgen_test_* fi fi # Checks for openvisa AC_CHECK_HEADERS([visa/visa.h], [AC_SEARCH_LIBS([viOpenDefaultRM], [openvisa], [build_visa=yes], [])] , [] ) if test "x$ac_cv_search_viOpenDefaultRM" != "xno"; then test "x$ac_cv_search_viOpenDefaultRM" = "xnone required" || AC_SUBST(VISALIBS, [$ac_cv_search_viOpenDefaultRM]) fi # if test $build_parallel = yes; then AC_DEFINE([BUILD_PARALLEL], [], [build PARALLEL interface functions]) fi if test $build_serial = yes; then AC_DEFINE([BUILD_SERIAL], [], [build SERIAL interface functions]) fi if test $build_i2c = yes; then AC_DEFINE([BUILD_I2C], [], [build I2C interface functions]) fi if test $build_usbtmc = yes; then AC_DEFINE([BUILD_USBTMC], [], [build USBTMC interface functions]) fi if test $build_tcp = yes; then AC_DEFINE([BUILD_TCP], [], [build TCP interface functions]) fi if test $build_udp = yes; then AC_DEFINE([BUILD_UDP], [], [build UDP interface functions]) fi if test $build_gpib = yes; then AC_DEFINE([BUILD_GPIB], [], [build GPIB interface functions]) fi if test $build_vxi11 = yes; then AC_DEFINE([BUILD_VXI11], [], [build VXI11 interface functions]) AC_SUBST([BUILD_VXI11], [1], [build VXI11 interface functions]) fi if test $build_visa = yes; then AC_DEFINE([BUILD_VISA], [], [build VISA interface functions]) fi if test $build_resolvehost = yes; then AC_DEFINE([BUILD_RESOLVEHOST], [], [build resolvehost function]) fi # all done AC_CONFIG_FILES([Makefile gpib/Makefile tcp/Makefile udp/Makefile vxi11/Makefile usbtmc/Makefile serial/Makefile parallel/Makefile i2c/Makefile resolvehost/Makefile hwinfo/Makefile]) AC_OUTPUT AC_MSG_NOTICE([ $PACKAGE_NAME is now configured with BUILD SERIAL: $build_serial BUILD PARALLEL: $build_parallel BUILD I2C: $build_i2c BUILD TCP: $build_tcp BUILD UDP: $build_udp BUILD USBTMC: $build_usbtmc BUILD GPIB: $build_gpib BUILD VXI11: $build_vxi11 BUILD RESOLVEHOST: $build_resolvehost GPIB LIBS: $GPIBLIBS VXI11 LIBS: $RPCLIBS VXI11 INCLUDE: $RPCINCLUDE VISA LIBS: $VISALIBS TCP LIBS: $TCPLIBS ]) instrument-control-0.4.0/src/gpib/0000755000000000000000000000000013460206417015302 5ustar0000000000000000instrument-control-0.4.0/src/gpib/Makefile.in0000644000000000000000000000155513460206417017355 0ustar0000000000000000OCT := ../gpib.oct OBJ := gpib.o gpib_timeout.o gpib_write.o gpib_close.o gpib_read.o __gpib_spoll__.o __gpib_trigger__.o __gpib_clrdevice__.o gpib_class.o __gpib_pkg_lock__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ LFLAGS = @GPIBLIBS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ $(LFLAGS) -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/gpib/__gpib_clrdevice__.cc0000644000000000000000000000325613460206417021354 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include #include "gpib_class.h" #endif // PKG_ADD: autoload ("__gpib_clrdevice__", "gpib.oct"); DEFUN_DLD (__gpib_clrdevice__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} __gpib_clrdevice__ (@var{gpib})\n \ \n\ Sends clear command to gpib device.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.@*\ \n\ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_gpib::static_type_id ()) { print_usage (); return octave_value (-1); } octave_gpib* gpib = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); retval = gpib->cleardevice (); return octave_value (); #endif } instrument-control-0.4.0/src/gpib/__gpib_pkg_lock__.cc0000644000000000000000000000264713460206417021210 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__gpib_pkg_lock__", "gpib.oct"); // PKG_ADD: __gpib_pkg_lock__(1); // PKG_DEL: __gpib_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__gpib_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__gpib_pkg_lock__")) interp.munlock("__gpib_pkg_lock__"); } return retval; } #else DEFUN_DLD(__gpib_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/gpib/__gpib_spoll__.cc0000644000000000000000000000347213460206417020545 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include #include "gpib_class.h" #endif // PKG_ADD: autoload ("__gpib_spoll__", "gpib.oct"); DEFUN_DLD (__gpib_spoll__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{sb} = } __gpib_spoll__ (@var{gpib})\n \ \n\ serial poll gpib interface.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.@*\ \n\ Upon successful completion, gpib_spoll() shall return the status byte @var{sb}.\n \ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_gpib::static_type_id ()) { print_usage (); return octave_value (-1); } octave_gpib* gpib = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); char rqs; retval = gpib->spoll (&rqs); if (retval == -1) return octave_value (); return octave_value (rqs); #endif } instrument-control-0.4.0/src/gpib/__gpib_trigger__.cc0000644000000000000000000000322713460206417021055 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include #include "gpib_class.h" #endif // PKG_ADD: autoload ("__gpib_trigger__", "gpib.oct"); DEFUN_DLD (__gpib_trigger__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} __gpib_trigger__ (@var{gpib})\n \ \n\ triggers gpib device.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.@*\ \n\ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_gpib::static_type_id ()) { print_usage (); return octave_value (-1); } octave_gpib* gpib = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); retval = gpib->trigger (); return octave_value (); #endif } instrument-control-0.4.0/src/gpib/gpib.cc0000644000000000000000000000615113460206417016535 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include //#include #include "gpib_class.h" #endif // PKG_ADD: autoload ("gpib", "gpib.oct"); DEFUN_DLD (gpib, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{gpib} = } gpib ([@var{gpibid}], [@var{timeout}])\n \ \n\ Open gpib interface.\n \ \n\ @var{gpibid} - the interface number.@* \ @var{timeout} - the interface timeout value. If omitted defaults to blocking call.\n \ \n\ The gpib() shall return instance of @var{octave_gpib} class as the result @var{gpib}.\n \ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values int gpibid; const int minor = 0; int timeout = -1; const int secid = 0; const int send_eoi = 1; const int eos_mode = 0; // Parse the function arguments if (args.length() > 0) { if (args (0).OV_ISINTEGER () || args (0).OV_ISFLOAT ()) { gpibid = args (0).int_value (); } else { print_usage (); return octave_value (); } } else { print_usage (); return octave_value (); } // is_float_type() is or'ed to allow expression like ("", 123), without user // having to use ("", int32(123)), as we still only take "int_value" if (args.length() > 1) { if (args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) { timeout = args (1).int_value (); } else { print_usage (); return octave_value (); } } // Open the interface octave_gpib* retval = new octave_gpib (); retval->open (minor, gpibid, secid, timeout, send_eoi, eos_mode); //retval->set_timeout(timeout); //retval->set_sad(eot); //retval->set_send_eoi(eot); //retval->set_eos_mode(eot); return octave_value (retval); #endif } #if 0 %!test %! if any(strcmp(instrhwinfo().SupportedInterfaces, "gpib")) %! fail ("gpib ()", "Invalid call to gpib"); %! else %! fail ("gpib ()", "gpib: Your system doesn't support the GPIB interface"); %! endif #endif instrument-control-0.4.0/src/gpib/gpib_class.cc0000644000000000000000000002042413460206417017721 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include #include #include #include #include #include "gpib/ib.h" #define GPIB_USEBLOCKREAD #include "gpib_class.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_gpib, "octave_gpib", "octave_gpib"); static void close_fd (int fd) { ibonl(fd,0); } octave_gpib::octave_gpib () { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); } minor = -1; gpibid = -1; } octave_gpib::~octave_gpib () { octave_gpib::close (); } void octave_gpib::print (std::ostream& os, bool pr_as_read_syntax) { print_raw (os, pr_as_read_syntax); newline (os); } void octave_gpib::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw (os, pr_as_read_syntax); newline (os); } void octave_gpib::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << gpibid; } int octave_gpib::open (int minor, int gpibid, int sad, int timeout, int send_eoi, int eos_mode) { this->minor = minor; this->gpibid = gpibid; this->sad = sad; this->timeout = timeout; this->send_eoi = send_eoi; this->eos_mode = eos_mode; return 1; } int octave_gpib::read (uint8_t *buf, unsigned int len, bool *eoi) { int gperr,fd; int bytes_read = 0; if (this->minor < 0) { error ("gpib_read: Interface must be opened first..."); return -1; } fd = ibdev (this->minor, this->gpibid, this->sad, this->timeout, this->send_eoi, this->eos_mode); if (fd < 0) { error ("gpib_read: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); #if defined(GPIB_USEBLOCKREAD) // blocking read - not interruptable gperr = ibrd (fd,(void *)buf,len); if (gperr & ERR) { if (gperr & TIMO) { warning ("gpib_read: read timeout"); } else { int localiberr = ThreadIberr (); error ("gpib_read: Error while reading: %d - %d\n", gperr, localiberr); if (localiberr == 0) { localiberr = ThreadIbcnt (); warning ("gpib_read: failed system call: %d - %s\n", localiberr, strerror (localiberr)); } return -1; } } #else // async read - not interruptable as well gperr = ibrda (fd, (void *)buf, len); if (gperr & ERR) { error ("gpib_read: Error while reading: %d\n", ThreadIberr()); return -1; } while (1) { OCTAVE_QUIT; gperr = ibwait (fd,CMPL); warning ("gpib_read: read timeout %d - %d - %d",gperr, ThreadIberr (),ThreadIbcnt ()); if (gperr & ERR) { if (gperr & TIMO) { warning ("gpib_read: read timeout"); } else { int localiberr = ThreadIberr (); error ("gpib_read: Error while reading: %d - %d\n", gperr, localiberr); if (localiberr == 0) { localiberr = ThreadIbcnt(); warning ("gpib_read: failed system call: %d - %s\n", localiberr, strerror (localiberr)); } return -1; } } } #endif bytes_read = ThreadIbcnt (); *eoi = (ThreadIbsta () & 0x2000) ? true : false; return bytes_read; } int octave_gpib::write (const std::string &str) { int gperr,fd; if (minor < 0) { error ("gpib_write: Interface must be opened first..."); return -1; } fd = ibdev (minor, gpibid, sad, timeout, send_eoi, eos_mode); if (fd < 0) { error ("gpib_read: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); gperr = ibwrt (fd,str.c_str (), str.length ()); if (gperr & ERR) { // warning: can not write if (ThreadIberr () != ENOL) { // ENOL is handled by library error ("gpib: can not write gpib data to device"); } } return gperr; } int octave_gpib::write (uint8_t *buf, unsigned int len) { int gperr,fd; if (minor < 0) { error ("gpib_write: Interface must be opened first..."); return -1; } fd = ibdev(minor, gpibid, sad, timeout, send_eoi, eos_mode); if (fd < 0) { error ("gpib_write: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); gperr = ibwrt (fd, buf, len); if (gperr & ERR) { // warning: can not write if (ThreadIberr() != ENOL) { // ENOL is handled by library error ("gpib: can not write gpib data to device"); } } return gperr; } int octave_gpib::spoll (char *rqs) { int gperr,fd; if (minor < 0) { error("gpib_spoll: Interface must be opened first..."); return -1; } fd = ibdev (minor, gpibid, sad, timeout, send_eoi, eos_mode); if (fd < 0) { error ("gpib_spoll: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); gperr = ibrsp (fd,rqs); if (gperr & ERR) { error ("gpib_spoll: some error occured: %d", ThreadIberr ()); return -1; } //warning ("aaa: %X - %X",gperr, buf); return gperr; } int octave_gpib::trigger() { int gperr,fd; if (this->minor < 0) { error ("gpib_trigger: Interface must be opened first..."); return -1; } fd = ibdev(minor, gpibid, sad, timeout, send_eoi, eos_mode); if (fd < 0) { error("gpib_trigger: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); gperr = ibtrg (fd); if (gperr & ERR) { error ("gpib_trigger: some error occured: %d", ThreadIberr ()); return -1; } return gperr; } int octave_gpib::cleardevice() { int gperr,fd; if (minor < 0) { error ("gpib_clear: Interface must be opened first..."); return -1; } fd = ibdev(minor, gpibid, sad, timeout, send_eoi, eos_mode); if (fd < 0) { error("gpib_clear: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); gperr = ibclr(fd); if (gperr & ERR) { error ("gpib_clear: some error occured: %d", ThreadIberr ()); return -1; } return gperr; } int octave_gpib::set_timeout (int newtimeout) { if (minor < 0) { error ("gpib_timeout: Interface must be opened first..."); return -1; } if (timeout < 0 || timeout > 17) { error ("gpib_timeout: timeout must be between 0 and 17"); return -1; } timeout = newtimeout; return 1; } int octave_gpib::get_timeout() const { return timeout; } int octave_gpib::close() { int fd,gperr; if (minor > -1) { fd = ibdev(minor, gpibid, sad, timeout, send_eoi, eos_mode); if (fd < 0) { error("gpib_close: error opening gpib device..."); return -1; } // set up a frame to close fd OCTAVE__UNWIND_PROTECT frame; frame.add_fcn (close_fd, fd); gperr = ibloc (fd); if (gperr & ERR) { error ("gpib_close: can not set device to local"); } } minor = -1; return -1; } #endif instrument-control-0.4.0/src/gpib/gpib_class.h0000644000000000000000000000400313460206417017556 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef GPIB_CLASS_H #define GPIB_CLASS_H #include #include #include class octave_gpib : public octave_base_value { public: octave_gpib(); ~octave_gpib(); int write(const std::string&); int write(uint8_t*, unsigned int); int read(uint8_t*, unsigned int, bool*); int spoll(char*); int trigger(); int cleardevice(); int open(int, int, int, int, int, int); int close(); int set_timeout(int); int get_timeout() const; //int set_sad(int); //int set_send_eoi(int); //int set_eos_mode(int); // Overloaded base functions double gpib_value() const { return (double)this->gpibid; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)this->gpibid; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool print_as_scalar (void) const { return true;} private: int minor; int gpibid; int sad; int timeout; int send_eoi; int eos_mode; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/gpib/gpib_close.cc0000644000000000000000000000314613460206417017723 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include "gpib_class.h" #endif // PKG_ADD: autoload ("gpib_close", "gpib.oct"); DEFUN_DLD (gpib_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} gpib_close (@var{gpib})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.\n \ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else if (args.length() != 1 || args(0).type_id() != octave_gpib::static_type_id()) { print_usage (); return octave_value (-1); } octave_gpib* gpib = NULL; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); gpib->close (); return octave_value (); #endif } instrument-control-0.4.0/src/gpib/gpib_read.cc0000644000000000000000000000551513460206417017533 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include #include #include "gpib_class.h" #endif // PKG_ADD: autoload ("gpib_read", "gpib.oct"); DEFUN_DLD (gpib_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}, @var{eoi}] = } gpib_read (@var{gpib}, @var{n})\n \ \n\ Read from gpib interface.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.@* \ @var{n} - number of bytes to attempt to read of type Integer.\n \ \n\ The gpib_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @var{eoi} indicates read operation complete \n \ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else if (args.length () < 2 || args.length () > 3 || args (0).type_id () != octave_gpib::static_type_id ()) { print_usage (); return octave_value (-1); } unsigned int buffer_len = 0; if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ())) { print_usage (); return octave_value (-1); } buffer_len = args (1).int_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buffer, (buffer_len + 1)); if (buffer == NULL) { error ("gpib_read: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value (-1); } octave_gpib* gpib = NULL; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); // Read data bool eoi; int bytes_read = gpib->read (buffer, buffer_len, &eoi); // Convert data to octave type variables octave_value_list return_list; uint8NDArray data(dim_vector (1, bytes_read)); for (int i = 0; i < bytes_read; i++) data (i) = buffer[i]; return_list (0) = data; return_list (1) = bytes_read; return_list (2) = eoi; return return_list; #endif } instrument-control-0.4.0/src/gpib/gpib_timeout.cc0000644000000000000000000000472113460206417020304 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include "gpib_class.h" #endif // PKG_ADD: autoload ("gpib_timeout", "gpib.oct"); DEFUN_DLD (gpib_timeout, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} gpib_timeout (@var{gpib}, @var{timeout})\n \ @deftypefnx {Loadable Function} {@var{t} = } gpib_timeout (@var{gpib})\n \ \n\ Set new or get existing gpib interface timeout parameter. The timeout value is valid from 0 to 17.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.@* \ @var{timeout} - Value of 0 means never timeout, 11 means one second and 17 means 1000 seconds (see GPIB documentation (ibtmo) for further details)\n \ \n\ If @var{timeout} parameter is omitted, the gpib_timeout() shall return current timeout value as the result @var{t}.\n \ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value(); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_gpib::static_type_id ()) { print_usage (); return octave_value (-1); } octave_gpib* gpib = NULL; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); // Setting new timeout if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } gpib->set_timeout (args (1).int_value ()); return octave_value (); // Should it return by default? } // Returning current timeout return octave_value (gpib->get_timeout ()); #endif } instrument-control-0.4.0/src/gpib/gpib_write.cc0000644000000000000000000000506113460206417017746 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_GPIB #include #include "gpib_class.h" #endif // PKG_ADD: autoload ("gpib_write", "gpib.oct"); DEFUN_DLD (gpib_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } gpib_write (@var{gpib}, @var{data})\n \ \n\ Write data to a gpib interface.\n \ \n\ @var{gpib} - instance of @var{octave_gpib} class.@* \ @var{data} - data to be written to the gpib interface. Can be either of String or uint8 type.\n \ \n\ Upon successful completion, gpib_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_GPIB error ("gpib: Your system doesn't support the GPIB interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_gpib::static_type_id ()) { print_usage(); return octave_value(-1); } octave_gpib* gpib = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); gpib = &((octave_gpib &)rep); if (args (1).is_string ()) // String { retval = gpib->write (args (1).string_value ()); } else if (args (1).is_uint8_type ()) // uint8_t { NDArray data = args (1).array_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buf, (data.numel ())); if (buf == NULL) { error ("gpib_write: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value(-1); } for (int i = 0; i < data.numel (); i++) buf[i] = static_cast(data (i)); retval = gpib->write (buf, data.numel ()); } else { print_usage (); return octave_value (-1); } return octave_value (retval); #endif } instrument-control-0.4.0/src/hwinfo/0000755000000000000000000000000013460206417015653 5ustar0000000000000000instrument-control-0.4.0/src/hwinfo/Makefile.in0000644000000000000000000000136213460206417017722 0ustar0000000000000000OCT := ../__instr_hwinfo__.oct OBJ := __instr_hwinfo__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ LFLAGS = @TCPLIBS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ $(LFLAGS) -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/hwinfo/__instr_hwinfo__.cc0000644000000000000000000000366413460206417021500 0ustar0000000000000000// Copyright (C) 2017-2018 John Donoghue // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif DEFUN_DLD (__instr_hwinfo__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{res} = } __instr_hwinfo__()\n \ \n\ Internal private function\n \ \n\ @end deftypefn") { octave_value_list return_value; octave_value_list interfaces; octave_map inf; inf.assign("ToolboxVersion", octave_value(PACKAGE_VERSION)); inf.assign("ToolboxName", octave_value(PACKAGE_NAME)); int int_count = 0; #ifdef BUILD_GPIB interfaces (int_count++) = "gpib"; #endif #ifdef BUILD_I2C interfaces (int_count++) = "i2c"; #endif #ifdef BUILD_PARALLEL interfaces (int_count++) = "parallel"; #endif #ifdef BUILD_SERIAL interfaces (int_count++) = "serial"; #endif #ifdef BUILD_TCP interfaces (int_count++) = "tcp"; #endif #ifdef BUILD_UDP interfaces (int_count++) = "udp"; #endif #ifdef BUILD_USBTMC interfaces (int_count++) = "usbtmc"; #endif #ifdef BUILD_VXI11 interfaces (int_count++) = "vxi11"; #endif inf.assign("SupportedInterfaces", octave_value(interfaces.cell_value())); return_value (0) = inf; return return_value; } #if 0 %!test %! a = __instr_hwinfo__(); %! assert (! isempty (a)); #endif instrument-control-0.4.0/src/i2c/0000755000000000000000000000000013460206417015036 5ustar0000000000000000instrument-control-0.4.0/src/i2c/Makefile.in0000644000000000000000000000140413460206417017102 0ustar0000000000000000OCT := ../i2c.oct OBJ := i2c.o i2c_close.o i2c_addr.o i2c_write.o i2c_read.o i2c_class.o __i2c_pkg_lock__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/i2c/__i2c_pkg_lock__.cc0000644000000000000000000000263713460206417020477 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__i2c_pkg_lock__", "i2c.oct"); // PKG_ADD: __i2c_pkg_lock__(1); // PKG_DEL: __i2c_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__i2c_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__i2c_pkg_lock__")) interp.munlock("__i2c_pkg_lock__"); } return retval; } #else DEFUN_DLD(__i2c_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/i2c/i2c.cc0000644000000000000000000000552413460206417016030 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_I2C #include #include "i2c_class.h" #endif // PKG_ADD: autoload ("i2c", "i2c.oct"); DEFUN_DLD (i2c, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{i2c} = } i2c ([@var{path}], [@var{address}])\n \ \n\ Open i2c interface.\n \ \n\ @var{path} - the interface path of type String. If omitted defaults to '/dev/i2c-0'. @*\ @var{address} - the slave device address. If omitted must be set using i2c_addr() call.\n \ \n\ The i2c() shall return instance of @var{octave_i2c} class as the result @var{i2c}.\n \ @end deftypefn") { #ifndef BUILD_I2C error ("i2c: Your system doesn't support the I2C interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values int oflags = O_RDWR; std::string path ("/dev/i2c-0"); int addr = -1; // Parse the function arguments if (args.length () > 0) { if (args (0).is_string ()) { path = args (0).string_value (); } else { print_usage (); return octave_value (); } } // is_float_type() is or'ed to allow expression like ("", 123), without user // having to use ("", int32(123)), as we still only take "int_value" if (args.length () > 1) { if (args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) { addr = args (1).int_value (); } else { print_usage (); return octave_value (); } } octave_i2c* retval = new octave_i2c (); // Open the interface if (retval->open (path, oflags) < 0) return octave_value (); if (addr > 0) retval->set_addr (addr); return octave_value (retval); #endif } #if 0 %!test %! if any(strcmp(instrhwinfo().SupportedInterfaces, "i2c")) %! fail ("i2c ()", "Invalid call to i2c"); %! else %! fail ("i2c ()", "i2c: Your system doesn't support the I2C interface"); %! endif #endif instrument-control-0.4.0/src/i2c/i2c_addr.cc0000644000000000000000000000444113460206417017017 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_I2C #include "i2c_class.h" #endif // PKG_ADD: autoload ("i2c_addr", "i2c.oct"); DEFUN_DLD (i2c_addr, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} i2c_addr (@var{i2c}, @var{address})\n \ @deftypefnx {Loadable Function} {@var{addr} = } i2c_addr (@var{i2c})\n \ \n\ Set new or get existing i2c slave device address.\n \ \n\ @var{i2c} - instance of @var{octave_i2c} class.@*\ @var{address} - i2c slave device address of type Integer. \ The address is passed in the 7 or 10 lower bits of the argument.\n \ \n\ If @var{address} parameter is omitted, the i2c_addr() shall return \ current i2c slave device address as the result @var{addr}.\n \ @end deftypefn") { #ifndef BUILD_I2C error ("i2c: Your system doesn't support the I2C interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_i2c::static_type_id ()) { print_usage (); return octave_value (-1); } octave_i2c* i2c = NULL; const octave_base_value& rep = args (0).get_rep(); i2c = &((octave_i2c &)rep); // Setting new slave address if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } i2c->set_addr(args (1).int_value ()); return octave_value (); } // Returning current slave address return octave_value (i2c->get_addr ()); #endif } instrument-control-0.4.0/src/i2c/i2c_class.cc0000644000000000000000000001037713460206417017217 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_I2C #include #include #include #include #include #include #include #if defined (__linux__) #include #endif // Platform specific header files #if defined (__FreeBSD__) #include #endif #include "i2c_class.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_i2c, "octave_i2c", "octave_i2c"); octave_i2c::octave_i2c (void) { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); } fd = -1; } octave_i2c::~octave_i2c (void) { octave_i2c::close (); } int octave_i2c::get_fd (void) const { return fd; } void octave_i2c::print (std::ostream& os, bool pr_as_read_syntax) { print_raw (os, pr_as_read_syntax); newline (os); } void octave_i2c::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw (os, pr_as_read_syntax); newline (os); } void octave_i2c::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << fd; } int octave_i2c::open (const std::string &path, int flags) { fd = ::open (path.c_str (), flags, 0); if (get_fd () < 0) { error ("i2c: Error opening the interface: %s\n", strerror (errno)); return -1; } return get_fd (); } int octave_i2c::set_addr (int addr) { if (get_fd () < 0) { error ("i2c: Interface must be open first..."); return -1; } #if defined (__linux__) if (::ioctl (get_fd (), I2C_SLAVE, addr) < 0) { error ("i2c: Error setting slave address: %s\n", strerror (errno)); return -1; } #endif return 1; } int octave_i2c::get_addr (void) const { if (get_fd() < 0) { error ("i2c: Interface must be open first..."); return -1; } return addr; } int octave_i2c::read (uint8_t *buf, unsigned int len) { if (get_fd () < 0) { error ("i2c: Interface must be open first..."); return -1; } int retval = -1; #if defined (__linux__) retval = ::read (get_fd (), buf, len); #endif #if defined (__FreeBSD__) // Populate FreeBSD-specific structure struct iiccmd i2c_slave; i2c_slave.slave = static_cast(get_addr ()); i2c_slave.count = len; i2c_slave.last = 0; // No additional reads will follow for this transaction i2c_slave.buf = buf; ::ioctl (get_fd (), I2CSTART, &i2c_slave); retval = ::ioctl (get_fd(), I2CREAD, &i2c_slave); ::ioctl (get_fd(), I2CSTOP); #endif if (retval < 0) error ("i2c: Failed to read from the i2c bus: %s\n", strerror (errno)); return retval; } int octave_i2c::write (uint8_t *buf, unsigned int len) { if (get_fd () < 0) { error ("i2c: Interface must be open first..."); return -1; } int retval = -1; #if defined (__linux__) retval = ::write (get_fd (), buf, len); #endif #if defined (__FreeBSD__) // Populate FreeBSD-specific structure struct iiccmd i2c_slave; i2c_slave.slave = static_cast(get_addri ()); i2c_slave.count = len; i2c_slave.last = 0; // No additional writes will follow for this transaction i2c_slave.buf = buf; ::ioctl (get_fd (), I2CSTART, &i2c_slave); retval = ::ioctl (get_fd (), I2CWRITE, &i2c_slave); ::ioctl(get_fd (), I2CSTOP); #endif if (retval < 0) error ("i2c: Failed to write to the i2c bus: %s\n", strerror (errno)); return retval; } int octave_i2c::close (void) { int retval = -1; if (get_fd () > 0) { retval = ::close(get_fd ()); fd = -1; } return retval; } #endif instrument-control-0.4.0/src/i2c/i2c_class.h0000644000000000000000000000353513460206417017057 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef I2C_CLASS_H #define I2C_CLASS_H #include #include class octave_i2c : public octave_base_value { public: octave_i2c (void); ~octave_i2c (void); int open (const std::string& /* path */, int /* open flags */); int close (void); int get_fd (void) const; int set_addr (int /* slave ddress */); int get_addr (void) const; // Simple i2c commands int write (uint8_t* /* buffer */, unsigned int /* buffer size */); int read (uint8_t* /* buffer */, unsigned int /* buffer size */); // Overloaded base functions double i2c_value () const { return (double)fd; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)fd; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool print_as_scalar (void) const { return true;} private: int fd; int addr; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/i2c/i2c_close.cc0000644000000000000000000000304413460206417017210 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_I2C #include "i2c_class.h" #endif // PKG_ADD: autoload ("i2c_close", "i2c.oct"); DEFUN_DLD (i2c_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} i2c_close (@var{i2c})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{i2c} - instance of @var{octave_i2c} class.@*\ @end deftypefn") { #ifndef BUILD_I2C error ("i2c: Your system doesn't support the I2C interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_i2c::static_type_id ()) { print_usage (); return octave_value (-1); } octave_i2c* i2c = NULL; const octave_base_value& rep = args (0).get_rep (); i2c = &((octave_i2c &)rep); i2c->close (); return octave_value (); #endif } instrument-control-0.4.0/src/i2c/i2c_read.cc0000644000000000000000000000525513460206417017024 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_I2C #include #include "i2c_class.h" #endif // PKG_ADD: autoload ("i2c_read", "i2c.oct"); DEFUN_DLD (i2c_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}] = } i2c_read (@var{i2c}, @var{n})\n \ \n\ Read from i2c slave device.\n \ \n\ @var{i2c} - instance of @var{octave_i2c} class.@*\ @var{n} - number of bytes to attempt to read of type Integer.\n \ \n\ The i2c_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @end deftypefn") { #ifndef BUILD_I2C error ("i2c: Your system doesn't support the I2C interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_i2c::static_type_id ()) { print_usage (); return octave_value (-1); } unsigned int buffer_len = 1; if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } buffer_len = args (1).int_value (); } OCTAVE_LOCAL_BUFFER (uint8_t, buffer, (buffer_len +1)); if (buffer == NULL) { error ("i2c_read: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value (-1); } octave_i2c* i2c = NULL; const octave_base_value& rep = args (0).get_rep(); i2c = &((octave_i2c &)rep); int retval; retval = i2c->read (buffer, buffer_len); octave_value_list return_list; uint8NDArray data (dim_vector (1, retval)); for (int i = 0; i < retval; i++) data (i) = buffer[i]; return_list (0) = data; return_list (1) = retval; return return_list; #endif } instrument-control-0.4.0/src/i2c/i2c_write.cc0000644000000000000000000000454413460206417017243 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_I2C #include #include "i2c_class.h" #endif // PKG_ADD: autoload ("i2c_write", "i2c.oct"); DEFUN_DLD (i2c_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } i2c_write (@var{i2c}, @var{data})\n \ \n\ Write data to a i2c slave device.\n \ \n\ @var{i2c} - instance of @var{octave_i2c} class.@*\ @var{data} - data, of type uint8, to be written to the slave device.\n \ \n\ Upon successful completion, i2c_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_I2C error ("i2c: Your system doesn't support the I2C interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_i2c::static_type_id ()) { print_usage (); return octave_value (-1); } octave_i2c* i2c = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); i2c = &((octave_i2c &)rep); if (args (1).is_uint8_type ()) // uint8_t { NDArray data = args (1).array_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buf, (data.numel ())); if (buf == NULL) { error ("i2c_write: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value (-1); } for (int i = 0; i < data.numel (); i++) buf[i] = static_cast(data (i)); retval = i2c->write (buf, data.numel()); } else { print_usage (); return octave_value (-1); } return octave_value (retval); #endif } instrument-control-0.4.0/src/m4/0000755000000000000000000000000013460206417014701 5ustar0000000000000000instrument-control-0.4.0/src/m4/octave-forge.m40000644000000000000000000000605013460206417017525 0ustar0000000000000000# Copyright (C) 2017 Olaf Till # Modifications to print what is searching for by JohnD # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # arguments of OF_OCTAVE_ALT_SYMS (see also description of # OF_OCTAVE_LIST_ALT_SYMS below): # # $1: symbol version 1 # $2: symbol version 2 # $3: test for symbol version 2 # $4: macro name to access alternative symbols # $5: include directives for symbol version 1 # $6: include directives for symbol version 2 # (a list of lists of args 1--6 is $1 of OF_OCTAVE_LIST_ALT_SYMS) # $7: name of generated include file with alternatives of Octave headers # (arg7 is $2 of OF_OCTAVE_LIST_ALT_SYMS) AC_DEFUN([OF_OCTAVE_ALT_SYMS], [ AC_MSG_CHECKING([$1 or $2]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ] $6], [$3])], [AC_DEFINE($4, [[$2]], [macro for alternative Octave symbols]) AC_MSG_RESULT([$2]) echo '$6' >> $7 ac_cv_octsym_[$4]=["$2"]], [AC_DEFINE($4, [[$1]], [macro for alternative Octave symbols]) AC_MSG_RESULT([$1]) echo '$5' >> $7 ac_cv_octsym_[$4]=["$1"]], ) ]) # OF_OCTAVE_LIST_ALT_SYMS is called in the following way: # # OF_OCTAVE_LIST_ALT_SYMS([ # [dnl # [old_octave_symbol], # [new_octave_symbol], # [[compilation test] # [for new_octave_symbol]], # [NAME_OF_GENERATED_MACRO____WILL_EXPAND_TO_OLD_OR_NEW_SYMBOL], # [[include directives] # [except #include ] # [necessary to compile with old_octave_symbol]], # [[include directives] # [except #include ] # [nessary to compile with new_octave_symbol] # [and to compile the test]] # ], # # ... further such lists as the above # # ], # # [name-of-header-file-for-alternative-octave-iclude-directives.h]) # # # This file should be put into src/m4/, and the line # # AC_CONFIG_MACRO_DIRS([m4]) # # should be put into src/configure.ac. The package should use # autoheader to generate config.h.in (src/bootstrap should contain the # lines 'aclocal', 'autoconf', and 'autoheader -f'). Package code # should include config.h and use the generated macros to access the # alternative symbols of Octave. An example of a call to # OF_OCTAVE_LIST_ALT_SYMS in src/configure.ac is available together # with this file. AC_DEFUN([OF_OCTAVE_LIST_ALT_SYMS], [ echo '/* generated by configure */' > $2 m4_foreach([it], [$1], [m4_apply([OF_OCTAVE_ALT_SYMS], [it, $2])]) AH_BOTTOM([#include "$2"]) ]) instrument-control-0.4.0/src/oct-alt-includes.h0000644000000000000000000000024713460206417017704 0ustar0000000000000000/* generated by configure */ #include #include #include #include instrument-control-0.4.0/src/parallel/0000755000000000000000000000000013460206417016155 5ustar0000000000000000instrument-control-0.4.0/src/parallel/Makefile.in0000644000000000000000000000144013460206417020221 0ustar0000000000000000OCT := ../parallel.oct OBJ := parallel.o parallel_class.o pp_close.o pp_datadir.o pp_data.o pp_stat.o pp_ctrl.o __parallel_pkg_lock__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/parallel/__parallel_pkg_lock__.cc0000644000000000000000000000270713460206417022733 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__parallel_pkg_lock__", "parallel.oct"); // PKG_ADD: __parallel_pkg_lock__(1); // PKG_DEL: __parallel_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__parallel_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__parallel_pkg_lock__")) interp.munlock("__parallel_pkg_lock__"); } return retval; } #else DEFUN_DLD(__parallel_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/parallel/parallel.cc0000644000000000000000000000646313460206417020271 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include #include #include #include #ifndef __WIN32__ #include #include #include #include #include #include #include #include #include #include #endif using std::string; #include "parallel_class.h" #endif // PKG_ADD: autoload ("parallel", "parallel.oct"); DEFUN_DLD (parallel, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{parallel} = } parallel ([@var{path}], [@var{direction}])\n \ \n\ Open Parallel interface.\n \ \n\ @var{path} - the interface path of type String. If omitted defaults to '/dev/parport0'.@*\ @var{direction} - the direction of interface drivers of type Integer, see: PP_DATADIR for more info. \ If omitted defaults to 1 (Input).\n \ \n\ The parallel() shall return instance of @var{octave_parallel} class as the result @var{parallel}.\n \ @end deftypefn") { #ifndef BUILD_PARALLEL error ("parallel: Your system doesn't support the parallel interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values int oflags = O_RDWR; int dir = 1; // Input string path ("/dev/parport0"); // Parse the function arguments if (args.length () > 0) { if (args (0).is_string ()) { path = args (0).string_value (); } else { print_usage (); return octave_value (); } } // is_float_type () is or'ed to allow expression like ("", 123), without user // having to use ("", int32(123)), as we still only take "int_value" if (args.length () > 1) { if (args (1).OV_ISINTEGER() || args (1).OV_ISFLOAT()) { dir = args (1).int_value (); } else { print_usage (); return octave_value (); } } octave_parallel* retval = new octave_parallel (); // Open the interface if (retval->open (path, oflags) < 0) return octave_value (); // Set direction retval->set_datadir(dir); return octave_value (retval); #endif } #if 0 %!test %! if any(strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("parallel ()", "Invalid call to parallel"); %! else %! fail ("parallel ()", "parallel: Your system doesn't support the parallel interface"); %! endif #endif instrument-control-0.4.0/src/parallel/parallel_class.cc0000644000000000000000000001422113460206417021445 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined (__linux__) #include #include #endif // Platform specific header files #if defined (__FreeBSD__) #include #include // And constants #define PPWCONTROL PPISCTRL #define PPRCONTROL PPIGCTRL #define PPWSTATUS PPISSTATUS #define PPRSTATUS PPIGSTATUS #define PPWDATA PPISDATA #define PPRDATA PPIGDATA #endif using std::string; #include "parallel_class.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_parallel, "octave_parallel", "octave_parallel"); octave_parallel::octave_parallel (void) { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); } this->fd = -1; } octave_parallel::~octave_parallel (void) { this->close (); } int octave_parallel::open (string path, int flags) { this->fd = ::open (path.c_str (), flags, 0); if (this->get_fd () < 0) { error("parallel: Error opening the interface: %s\n", strerror (errno)); return -1; } // Claim control of parallel port // Not used with FreeBSD #if !defined(__FreeBSD__) if (ioctl (this->get_fd (), PPCLAIM) < 0) { error("parallel: Error when claiming the interface: %s\n", strerror(errno)); ::close (this->get_fd ()); this->fd = -1; return -1; } #endif return this->get_fd (); } int octave_parallel::get_fd (void) { return this->fd; } void octave_parallel::print (std::ostream& os, bool pr_as_read_syntax) { print_raw (os, pr_as_read_syntax); newline (os); } void octave_parallel::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw (os, pr_as_read_syntax); newline (os); } void octave_parallel::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << this->fd; } int octave_parallel::set_datadir (int dir) { if (this->get_fd () < 0) { error ("parallel: Open the interface first..."); return -1; } if (dir < 0 || 1 < dir) { error ("parallel: Unsupported data direction..."); return -1; } // The ioctl parameter is a pointer to an int. // If the int is zero, the drivers are turned on (forward/output direction); // if non-zero, the drivers are turned off (reverse/input direction). // Not used with FreeBSD #if !defined(__FreeBSD__) if (ioctl (this->get_fd (), PPDATADIR, &dir) < 0) { error ("pp_datadir: error setting data direction: %s\n", strerror (errno)); return false; } #endif this->dir = dir; return 1; } int octave_parallel::get_datadir (void) { if (this->get_fd () < 0) { error ("parallel: Open the interface first..."); return false; } return this->dir; } int octave_parallel::get_stat (void) { if (this->get_fd () < 0) { error ("parallel: Open the interface first..."); return -1; } uint8_t status; if (ioctl (this->get_fd (), PPRSTATUS, &status) < 0) { error ("parallel: Error while reading from Status register: %s\n", strerror (errno)); return -1; } return status; } int octave_parallel::set_data (uint8_t data) { if (this->get_fd () < 0) { error("parallel: Open the interface first..."); return -1; } /* if (this->get_dir () == 1) { error ("parallel: Trying to output data while in Input mode, this can result in hardware damage! \ Use override if you know what you are doing..."); return false; } */ if (ioctl (this->get_fd (), PPWDATA, &data) < 0) { error ("parallel: Error while writing to Data register: %s\n", strerror (errno)); return -1; } return 1; } int octave_parallel::get_data (void) { if (this->get_fd () < 0) { error ("parallel: Open the interface first..."); return -1; } uint8_t data; if (ioctl(this->get_fd (), PPRDATA, &data) < 0) { error ("parallel: Error while reading from Data register: %s\n", strerror (errno)); return -1; } return data; } int octave_parallel::set_ctrl (uint8_t ctrl) { if (this->get_fd () < 0) { error ("parallel: Open the interface first..."); return -1; } if (ioctl(this->get_fd (), PPWCONTROL, &ctrl) < 0) { error ("parallel: Error while writing to Control register: %s\n", strerror (errno)); return -1; } return 1; } int octave_parallel::get_ctrl (void) { if (this->get_fd () < 0) { error ("parallel: Open the interface first..."); return -1; } uint8_t ctrl; if (ioctl(this->get_fd (), PPRCONTROL, &ctrl) < 0) { error ("parallel: Error while reading from Control register: %s\n", strerror (errno)); return -1; } return ctrl; } int octave_parallel::close (void) { if (this->get_fd () > 0) { // Release parallel port // Not used with FreeBSD #if !defined(__FreeBSD__) if (ioctl (this->get_fd (), PPRELEASE) < 0) error ("parallel: error releasing parallel port: %s\n", strerror (errno)); #endif int retval = ::close (this->get_fd ()); this->fd = -1; return retval; } return -1; } #endif instrument-control-0.4.0/src/parallel/parallel_class.h0000644000000000000000000000371513460206417021315 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef PARALLEL_CLASS_H #define PARALLEL_CLASS_H #include #include #include using std::string; class octave_parallel : public octave_base_value { public: octave_parallel (void); ~octave_parallel (void); int open (string /* path */, int /* open flags */); int close (void); int get_fd (); int get_datadir (void); int set_datadir (int /* direction */); int get_data (void); int set_data (uint8_t /* value */); int get_stat (void); //int set_stat (uint8_t); int get_ctrl (void); int set_ctrl (uint8_t /* value */); // Overloaded base functions double parallel_value(void) const { return (double)this->fd; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)this->fd; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool print_as_scalar (void) const { return true;} private: int fd; // 1 - Input // 0 - Output int dir; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/parallel/pp_close.cc0000644000000000000000000000400313460206417020265 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include "parallel_class.h" #endif // PKG_ADD: autoload ("pp_close", "parallel.oct"); DEFUN_DLD (pp_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} pp_close (@var{parallel})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{parallel} - instance of @var{octave_serial} class.@*\ @end deftypefn") { #ifndef BUILD_PARALLEL error ("parallel: Your system doesn't support the parallel interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id() != octave_parallel::static_type_id ()) { print_usage (); return octave_value (-1); } octave_parallel* parallel = NULL; const octave_base_value& rep = args (0).get_rep (); parallel = &((octave_parallel &)rep); parallel->close (); return octave_value (); #endif } #if 0 %!xtest %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! a = parallel (); %! pp_close (a); %! endif %!test %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("pp_close(1);", "Invalid call to pp_close"); %! endif %!test %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("pp_close();", "Invalid call to pp_close"); %! endif #endif instrument-control-0.4.0/src/parallel/pp_ctrl.cc0000644000000000000000000000507413460206417020135 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include "parallel_class.h" #endif // PKG_ADD: autoload ("pp_ctrl", "parallel.oct"); DEFUN_DLD (pp_ctrl, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} pp_ctrl (@var{parallel}, @var{ctrl})\n \ @deftypefnx {Loadable Function} {@var{c} = } pp_ctrl (@var{parallel})\n \ \n\ Sets or Read the Control lines.\ \n\ @var{parallel} - instance of @var{octave_parallel} class.@*\ @var{ctrl} - control parameter to be set of type Byte.\n \ \n\ If @var{ctrl} parameter is omitted, the pp_ctrl() shall return current Control lines state as the result @var{c}.\n \ @end deftypefn") { #ifndef BUILD_PARALLEL error ("parallel: Your system doesn't support the parallel interface"); return octave_value(); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_parallel::static_type_id ()) { print_usage (); return octave_value (-1); } octave_parallel* parallel = NULL; const octave_base_value& rep = args (0).get_rep (); parallel = &((octave_parallel &)rep); // Set new Control register value if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args(1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } parallel->set_ctrl (args (1).int_value ()); return octave_value (); } // Return current Control register value on port return octave_value (parallel->get_ctrl ()); #endif } #if 0 %!xtest %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! a = parallel (); %! v = pp_ctrl(a); %! pp_close (a); %! endif %!test %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("pp_ctrl(1);", "Invalid call to pp_ctrl"); %! endif #endif instrument-control-0.4.0/src/parallel/pp_data.cc0000644000000000000000000000506113460206417020076 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include "parallel_class.h" #endif // PKG_ADD: autoload ("pp_data", "parallel.oct"); DEFUN_DLD (pp_data, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} pp_data (@var{parallel}, @var{data})\n \ @deftypefnx {Loadable Function} {@var{d} = } pp_data (@var{parallel})\n \ \n\ Sets or Read the Data lines.\ \n\ @var{parallel} - instance of @var{octave_parallel} class.@*\ @var{data} - data parameter to be set of type Byte.\n \ \n\ If @var{data} parameter is omitted, the pp_data() shall return current Data lines state as the result @var{d}.\n \ @end deftypefn") { #ifndef BUILD_PARALLEL error ("parallel: Your system doesn't support the parallel interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_parallel::static_type_id ()) { print_usage (); return octave_value (-1); } octave_parallel* parallel = NULL; const octave_base_value& rep = args (0).get_rep (); parallel = &((octave_parallel &)rep); // Set new Data register value if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args(1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } parallel->set_data (args (1).int_value ()); return octave_value (); } // Return current Data register value on port return octave_value (parallel->get_data ()); #endif } #if 0 %!xtest %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! a = parallel (); %! d = pp_data (a); %! pp_close (a); %! endif %!test %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("pp_data(1);", "Invalid call to pp_data"); %! endif #endif instrument-control-0.4.0/src/parallel/pp_datadir.cc0000644000000000000000000000601613460206417020576 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include "parallel_class.h" #endif // PKG_ADD: autoload ("pp_datadir", "parallel.oct"); DEFUN_DLD (pp_datadir, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} pp_datadir (@var{parallel}, @var{direction})\n \ @deftypefnx {Loadable Function} {@var{dir} = } pp_datadir (@var{parallel})\n \ \n\ Controls the Data line drivers. Normally the computer's parallel port will drive the data lines, \ but for byte-wide transfers from the peripheral to the host it is useful to turn off those drivers \ and let the peripheral drive the signals. (If the drivers on the computer's parallel port are left \ on when this happens, the port might be damaged.)\n \ \n\ @var{parallel} - instance of @var{octave_parallel} class.@*\ @var{direction} - direction parameter of type Integer. Supported values: 0 - the drivers are turned on \ (Output/Forward direction); 1 - the drivers are turned off (Input/Reverse direction).\n \ \n\ If @var{direction} parameter is omitted, the pp_datadir() shall return current Data direction as the result @var{dir}.\n \ @end deftypefn") { #ifndef BUILD_PARALLEL error ("parallel: Your system doesn't support the parallel interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_parallel::static_type_id ()) { print_usage (); return octave_value (-1); } octave_parallel* parallel = NULL; const octave_base_value& rep = args (0).get_rep (); parallel = &((octave_parallel &)rep); // Set new direction if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } parallel->set_datadir (args (1).int_value ()); return octave_value (); } // Return current direction return octave_value (parallel->get_datadir ()); #endif } #if 0 %!xtest %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! a = parallel (); %! d = pp_datadir (a); %! pp_close (a); %! endif %!test %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("pp_datadir(1);", "Invalid call to pp_datadir"); %! endif #endif instrument-control-0.4.0/src/parallel/pp_stat.cc0000644000000000000000000000401013460206417020131 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_PARALLEL #include "parallel_class.h" #endif // PKG_ADD: autoload ("pp_stat", "parallel.oct"); DEFUN_DLD (pp_stat, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{stat} = } pp_stat (@var{parallel})\n \ \n\ Reads the Status lines.\n \ \n\ @var{parallel} - instance of @var{octave_parallel} class.@*\ \n\ The pp_stat() shall return current Status lines state as the result @var{stat}.\n \ @end deftypefn") { #ifndef BUILD_PARALLEL error ("parallel: Your system doesn't support the parallel interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_parallel::static_type_id ()) { print_usage (); return octave_value (-1); } octave_parallel* parallel = NULL; const octave_base_value& rep = args (0).get_rep (); parallel = &((octave_parallel &)rep); // Return current Status register value on port return octave_value (parallel->get_stat ()); #endif } #if 0 %!xtest %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! a = parallel (); %! d = pp_stat (a); %! pp_close (a); %! endif %!test %! if any (strcmp(instrhwinfo().SupportedInterfaces, "parallel")) %! fail ("pp_stat(1);", "Invalid call to pp_stat"); %! endif #endif instrument-control-0.4.0/src/resolvehost/0000755000000000000000000000000013460206417016736 5ustar0000000000000000instrument-control-0.4.0/src/resolvehost/Makefile.in0000644000000000000000000000136313460206417021006 0ustar0000000000000000OCT := ../resolvehost.oct OBJ := resolvehost.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ LFLAGS = @TCPLIBS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ $(LFLAGS) $(TCPLIBS) -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/resolvehost/resolvehost.cc0000644000000000000000000001353313460206417021627 0ustar0000000000000000// Copyright (C) 2016-2018 John Donoghue // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_TCP #include #include #ifndef __WIN32__ # include # include # include # include # include # include #else // tell old versions of mingw32 to be win2k # ifdef __MINGW32__ # if _MINGW32_MAJOR_VERSION < 5 # undef _WIN32_WINNT # define _WIN32_WINNT 0x0501 # endif # endif # include # include #endif #ifndef __WIN32__ # define SOCKETERR errno # define STRSOCKETERR strerror(errno) #else # define SOCKETERR WSAGetLastError() # define STRSOCKETERR "" #endif static bool type_loaded = false; #endif DEFUN_DLD (resolvehost, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{name} = } resolvehost (@var{host})\n \ @deftypefnx {Loadable Function} {[@var{name}, @var{address}] = } resolvehost (@var{host})\n \ @deftypefnx {Loadable Function} {@var{out} = } resolvehost (@var{host}, @var{returntype})\n \ \n\ Resolve a network host name or address to network name and address\n \ \n\ @var{host} - Host name or IP address string to resolve.@* \ @var{name} - Resolved IP host name.@* \ @var{address} - Resolved IP host address.@* \ @var{returntype} - 'name' to get host name, 'address' to get IP address.\n \ \n \ Examples:\n \ \n \ @example\n \ %% get resolved ip name and address pf www.gnu.org\n \ [name, address] = resolvehost ('www.gnu.org');\n \ \n \ %% get ip address of www.gnu.org\n \ ipaddress = resolvehost ('www.gnu.org', 'address');\n \ \n \ @end example\n \ \n \ @seealso{tcp, udp}\n \ \n\ @end deftypefn") { #ifndef BUILD_RESOLVEHOST error("resolvehost: Your system doesn't support the resolvehost interface"); return octave_value(); #else octave_value_list return_value; if (!type_loaded) { #ifdef __WIN32__ WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD ( 2, 2 ); err = WSAStartup (wVersionRequested, &wsaData); if (err != 0) { error ("resolvehost: could not initialize winsock library"); return return_value; } #endif type_loaded = true; } // Nothing to do if (args.length () != 1 && args.length () != 2) { print_usage (); return return_value; } // expects host string if (! args (0).is_string ()) { print_usage (); return return_value; } std::string host = args (0).string_value (); // optional return type std::string return_type = "both"; if (args.length () == 2) { if(! args (1).is_string ()) { print_usage (); return return_value; } return_type = args (1).string_value (); std::transform (return_type.begin (), return_type.end (), return_type.begin (), ::tolower); if (return_type != "name" && return_type != "address") { print_usage (); return return_value; } } // create addr from ip/looked up ip of value sockaddr_in in; memset (&in, 0, sizeof (in)); in.sin_family = AF_INET; in.sin_addr.s_addr = inet_addr (host.c_str ()); if (in.sin_addr.s_addr == INADDR_NONE) { struct hostent * hostinfo = gethostbyname (host.c_str ()); if (hostinfo) memcpy (&in.sin_addr, hostinfo->h_addr_list[0], hostinfo->h_length); } if (in.sin_addr.s_addr == INADDR_NONE) { error ("resolvehost: could not lookup IP address"); return return_value; } // we want to look up the name (ie: not only address) if (return_type != "address") { char name[1025]; if( getnameinfo ((struct sockaddr *)&in, sizeof (in), name, sizeof(name), NULL, 0, 0) != 0) { error ("resolvehost: error looking up host name : %d - %s\n", SOCKETERR, STRSOCKETERR); return return_value; } return_value (0) = name; } // we want the ip address (both or address) if (return_type != "name") { std::stringstream n; u_long addr = ntohl (in.sin_addr.s_addr); int b[4]; b[0] = (addr>>24)&0xff; b[1] = (addr>>16)&0xff; b[2] = (addr>>8)&0xff; b[3] = (addr>>0)&0xff; n << b[0] << "." << b[1] << "." << b[2] << "." << b[3]; if (return_type == "both") return_value (1) = n.str (); else return_value (0) = n.str (); } return return_value; #endif } #if 0 %!xtest %! name = resolvehost ("wiki.octave.org"); %! assert(! isempty (name)); %!xtest %! [name, addr] = resolvehost ("wiki.octave.org"); %! assert (! isempty (name)); %! assert (! isempty (addr)); %! assert (name, resolvehost ("wiki.octave.org", "name")); %! assert (addr, resolvehost ("wiki.octave.org", "address")); %!error resolvehost (); %!error resolvehost (1); %!error resolvehost ("wiki.octave.org", 1); %!error resolvehost ("wiki.octave.org", "addr"); %!error resolvehost ("wiki.octave.org", "name", 1); #endif instrument-control-0.4.0/src/serial/0000755000000000000000000000000013460206417015640 5ustar0000000000000000instrument-control-0.4.0/src/serial/Makefile.in0000644000000000000000000000154713460206417017714 0ustar0000000000000000OCT := ../serial.oct OBJ := serial.o srl_write.o srl_read.o __srl_properties__.o __serial_pkg_lock__.o ifeq ("@BUILD_FOR_WINDOWS@","1") OBJ += serial_class_win32.o else OBJ += serial_class_lin.o endif MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/serial/__serial_pkg_lock__.cc0000644000000000000000000000266713460206417022106 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__serial_pkg_lock__", "serial.oct"); // PKG_ADD: __serial_pkg_lock__(1); // PKG_DEL: __serial_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__serial_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__serial_pkg_lock__")) interp.munlock("__serial_pkg_lock__"); } return retval; } #else DEFUN_DLD(__serial_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/serial/__srl_properties__.cc0000644000000000000000000002512213460206417022021 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // Copyright (C) 2014 Stefan Mahr // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_SERIAL #include "serial_class.h" #endif #ifdef BUILD_SERIAL octave_value_list srl_close (octave_serial* serial, const octave_value_list& args, int nargout) { serial->close (); return octave_value (); } octave_value_list srl_flush (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length() > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Default arguments int queue_selector = 2; // Input and Output if (args.length () > 0) { if (!(args (0).OV_ISINTEGER () || args (0).OV_ISFLOAT ())) (*current_liboctave_error_handler) ("argument must be integer or float"); queue_selector = args (0).int_value (); } serial->flush (queue_selector); return octave_value (); } octave_value_list srl_timeout (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Setting new timeout if (args.length () > 0) { if ( !(args (0).OV_ISINTEGER () || args (0).OV_ISFLOAT ()) ) (*current_liboctave_error_handler) ("argument must be integer or float"); serial->set_timeout (args (0).int_value ()); return octave_value (); // Should it return by default? } // Returning current timeout return octave_value (serial->get_timeout ()); } octave_value_list srl_bytesavailable (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 0) (*current_liboctave_error_handler) ("wrong number of arguments"); // Returning bytes available return octave_value (serial->get_bytesavailable ()); } octave_value_list srl_status (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 0) (*current_liboctave_error_handler) ("wrong number of arguments"); // Returning bytes available return octave_value (serial->get_status ()); } octave_value_list srl_type (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 0) (*current_liboctave_error_handler) ("wrong number of arguments"); // Returning bytes available return octave_value (serial->get_type ()); } octave_value_list srl_name (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length() > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Setting new name if (args.length () > 0) { if (! (args (0).is_string ())) (*current_liboctave_error_handler) ("argument must be string"); serial->set_name (args (0).string_value ()); return octave_value (); } // Returning current baud rate return octave_value (serial->get_name ()); } octave_value_list srl_baudrate (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length() > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Setting new baudrate if (args.length () > 0) { if (! (args (0).OV_ISINTEGER () || args (0).OV_ISFLOAT ())) (*current_liboctave_error_handler) ("argument must be integer or float"); serial->set_baudrate (args (0).int_value ()); return octave_value (); } // Returning current baud rate return octave_value (serial->get_baudrate ()); } octave_value_list srl_bytesize (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Setting new byte size if (args.length () > 0) { if (! (args (0).OV_ISINTEGER () || args (0).OV_ISFLOAT ()) ) (*current_liboctave_error_handler) ("argument must be integer or float"); serial->set_bytesize (args (0).int_value ()); return octave_value (); } // Returning current byte size return octave_value (serial->get_bytesize ()); } octave_value_list srl_stopbits (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length() > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Setting new stop bits if (args.length () > 0) { if (! (args (0).OV_ISINTEGER () || args (0).OV_ISFLOAT ()) ) (*current_liboctave_error_handler) ("argument must be integer or float"); serial->set_stopbits(args (0).int_value ()); return octave_value (); } // Returning current stop bits return octave_value (serial->get_stopbits ()); } octave_value_list srl_parity (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); // Setting new parity if (args.length () > 0) { if ( !(args (0).is_string ()) ) (*current_liboctave_error_handler) ("argument must be string"); serial->set_parity (args (0).string_value()); return octave_value (); } // Returning current parity return octave_value (serial->get_parity ()); } octave_value_list srl_requesttosend (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); std::string onoff = ""; // Setting RTS if (args.length () > 0) { if ( !(args (0).is_string ()) ) (*current_liboctave_error_handler) ("argument must be string"); onoff = args (0).string_value (); std::transform (onoff.begin (), onoff.end (), onoff.begin (), ::tolower); if (onoff == "on") serial->set_control_line ("RTS", true); else if (onoff == "off") serial->set_control_line ("RTS", false); else (*current_liboctave_error_handler) ("wrong argument"); } // Returning RTS if (serial->get_control_line ("RTS")) return octave_value ("on"); return octave_value ("off"); } octave_value_list srl_dataterminalready (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 1) (*current_liboctave_error_handler) ("wrong number of arguments"); std::string onoff = ""; // Setting DTR if (args.length () > 0) { if ( !(args (0).is_string ()) ) (*current_liboctave_error_handler) ("argument must be string"); onoff = args (0).string_value (); std::transform (onoff.begin (), onoff.end (), onoff.begin (), ::tolower); if (onoff == "on") serial->set_control_line ("DTR", true); else if (onoff == "off") serial->set_control_line ("DTR", false); else (*current_liboctave_error_handler) ("wrong argument"); } // Returning DTR if (serial->get_control_line ("DTR")) return octave_value ("on"); return octave_value ("off"); } octave_value_list srl_pinstatus (octave_serial* serial, const octave_value_list& args, int nargout) { if (args.length () > 0) (*current_liboctave_error_handler) ("wrong number of arguments"); octave_scalar_map res; res.assign ("CarrierDetect", serial->get_control_line ("CD") ? octave_value ("on") : octave_value ("off")); res.assign ("ClearToSend", serial->get_control_line ("CTS") ? octave_value ("on") : octave_value ("off")); res.assign ("DataSetReady", serial->get_control_line ("DSR") ? octave_value ("on") : octave_value ("off")); res.assign ("RingIndicator", serial->get_control_line ("RI") ? octave_value ("on") : octave_value ("off")); return octave_value (res); } #endif // PKG_ADD: autoload ("__srl_properties__", "serial.oct"); DEFUN_DLD (__srl_properties__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {varargout =} __srl_properties__ (@var{octave_serial}, @var{property}, @var{varargin})\n\ Undocumented internal function.\n\ @end deftypefn") { #ifdef BUILD_SERIAL if (args.length () < 2 || args (0).type_id () != octave_serial::static_type_id () || !args (1).is_string ()) (*current_liboctave_error_handler) ("wrong number of arguments"); const octave_base_value& rep = args (0).get_rep (); octave_serial* serial = &((octave_serial &)rep); std::string property = args (1).string_value (); octave_value_list args2 = args.slice (2, args.length ()-2); if (property == "baudrate") return srl_baudrate (serial, args2, nargout); else if (property == "bytesize") return srl_bytesize (serial, args2, nargout); else if (property == "dataterminalready") return srl_dataterminalready (serial, args2, nargout); else if (property == "close") return srl_close (serial, args2, nargout); else if (property == "flush") return srl_flush (serial, args2, nargout); else if (property == "parity") return srl_parity (serial, args2, nargout); else if (property == "pinstatus") return srl_pinstatus (serial, args2, nargout); else if (property == "requesttosend") return srl_requesttosend (serial, args2, nargout); else if (property == "stopbits") return srl_stopbits (serial, args2, nargout); else if (property == "timeout") return srl_timeout (serial, args2, nargout); else if (property == "bytesavailable") return srl_bytesavailable (serial, args2, nargout); else if (property == "status") return srl_status (serial, args2, nargout); else if (property == "name") return srl_name (serial, args2, nargout); else if (property == "type") return srl_type (serial, args2, nargout); else (*current_liboctave_error_handler) ("wrong keyword"); #endif /* never reached in normal operation */ (*current_liboctave_error_handler) ("Your system doesn't support the SERIAL interface"); } instrument-control-0.4.0/src/serial/serial.cc0000644000000000000000000000664013460206417017434 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . // TODO: Implement Flow Control // TODO: Implement H/W handshaking #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_SERIAL #include #include #include "serial_class.h" #endif // PKG_ADD: autoload ("serial", "serial.oct"); DEFUN_DLD (serial, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{serial} = } serial ([@var{path}], [@var{baudrate}], [@var{timeout}])\n \ \n\ Open serial interface.\n \ \n\ @var{path} - the interface path of type String. @*\ @var{baudrate} - the baudrate of interface. If omitted defaults to 115200. @*\ @var{timeout} - the interface timeout value. If omitted defaults to blocking call.\n \ \n\ The serial() shall return instance of @var{octave_serial} class as the result @var{serial}.\n \ @end deftypefn") { #ifndef BUILD_SERIAL error ("serial: Your system doesn't support the SERIAL interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values std::string path; unsigned int baud_rate = 115200; short timeout = -1; unsigned short bytesize = 8; std::string parity("N"); unsigned short stopbits = 1; // Parse the function arguments if ((args.length () == 0) || !args(0 ).is_string ()) { print_usage (); return octave_value (); } path = args (0).string_value (); // isfloat() is or'ed to allow expression like ("", 123), without user // having to use ("", int32(123)), as we still only take "int_value" if (args.length() > 1) { if (args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) { baud_rate = args (1).int_value (); } else { print_usage (); return octave_value (); } } if (args.length () > 2) { if (args (2).OV_ISINTEGER () || args (2).OV_ISFLOAT ()) { timeout = args (2).int_value (); } else { print_usage (); return octave_value (); } } octave_serial* retval = new octave_serial (); // Open the interface retval->open (path); retval->set_baudrate (baud_rate); retval->set_timeout (timeout); retval->set_parity (parity); retval->set_bytesize (bytesize); retval->set_stopbits (stopbits); //retval->flush (2); return octave_value (retval); #endif } #if 0 %!test %! if any(strcmp(instrhwinfo().SupportedInterfaces, "serial")) %! fail ("serial ()", "Invalid call to serial"); %! else %! fail ("serial ()", "serial: Your system doesn't support the serial interface"); %! endif #endif instrument-control-0.4.0/src/serial/serial_class.h0000644000000000000000000001052413460206417020457 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // 2018 John Donoghue // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef SERIAL_CLASS_H #define SERIAL_CLASS_H #include //#include #include #define BITMASK_SET(x,y) ((x) |= (y)) #define BITMASK_CLEAR(x,y) ((x) &= (~(y))) #define BITMASK_TOGGLE(x,y) ((x) ^= (y)) #define BITMASK_CHECK(x,y) ((x) & (y)) #define BITMASK_CHECK_VALUE(x,y,z) (((x) & (y)) == (z)) #define CONCAT2X(x,y) x ## y #define CONCAT2(x,y) CONCAT2X(x,y) #define BINOPDECL(name, a1, a2) \ static octave_value \ CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) #define CAST_BINOP_ARGS(t1, t2) \ t1 v1 = dynamic_cast (a1); \ t2 v2 = dynamic_cast (a2) #define DEFBINOP_CLASS_OP(name, t1, t2, op) \ BINOPDECL (name, a1, a2) \ { \ CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ return octave_value \ (&v1 op &v2); \ } #ifdef OCTAVE__NEW_REGISTER_OP #define INSTALL_BINOP(op, t1, t2, f) \ {octave::type_info& ti = octave::interpreter::the_interpreter ()->get_type_info (); \ ti.register_binary_op \ (octave_value::op, t1::static_type_id (), t2::static_type_id (), \ CONCAT2(oct_binop_, f));} #else #define INSTALL_BINOP(op, t1, t2, f) \ octave_value_typeinfo::register_binary_op \ (octave_value::op, t1::static_type_id (), t2::static_type_id (), \ CONCAT2(oct_binop_, f)); #endif class octave_serial_common : public octave_base_value { public: // os dependent functions virtual bool fd_is_valid() const = 0; virtual int get_timeout() const = 0; virtual int get_baudrate() const = 0; virtual int get_bytesize() const = 0; virtual std::string get_parity() const = 0; virtual int get_stopbits() const = 0; virtual int get_bytesavailable() const = 0; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool is_object (void) const { return true;} void print (std::ostream& os, bool pr_as_read_syntax = false) { print_raw(os, pr_as_read_syntax); newline(os); } void print (std::ostream& os, bool pr_as_read_syntax = false) const { print_raw(os, pr_as_read_syntax); newline(os); } void print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << " Serial Port Object " << this->get_name(); newline(os); os << " status: " << this->get_status(); newline(os); if (this->fd_is_valid()) { os << " port: " << this->portPath; newline(os); os << " baudrate: " << this->get_baudrate(); newline(os); os << " parity: " << this->get_parity(); newline(os); os << " bytesize: " << this->get_bytesize(); newline(os); os << " stopbits: " << this->get_stopbits(); newline(os); os << " timeout: " << this->get_timeout(); newline(os); //os << "Mode: " << blockmode; newline(os); } } bool operator==(octave_serial_common& other) const { return (this == &other); } bool operator!=(octave_serial_common& other) const { return ! (this == &other); } std::string get_status () const { if (fd_is_valid ()) return "open"; else return "closed"; } std::string get_type () const { return "serial"; } std::string get_name () const { return name; } void set_name (const std::string &newname) { name = newname; } protected: std::string name; std::string portPath; }; #ifdef __WIN32__ #include "serial_class_win32.h" #else #include "serial_class_lin.h" #endif DEFBINOP_CLASS_OP (eq_serial_serial, serial, serial, ==) DEFBINOP_CLASS_OP (ne_serial_serial, serial, serial, !=) #endif instrument-control-0.4.0/src/serial/serial_class_lin.cc0000644000000000000000000003553713460206417021472 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_SERIAL #include #include #include #include #include #include #include #include #include #include #include "serial_class.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_serial, "octave_serial", "octave_serial"); octave_serial::octave_serial (void) : fd (-1) { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); INSTALL_BINOP (op_eq, octave_serial, octave_serial, eq_serial_serial); INSTALL_BINOP (op_ne, octave_serial, octave_serial, ne_serial_serial); } } void octave_serial::open (const std::string &path) { int flags = O_RDWR | O_NOCTTY | O_SYNC | O_NDELAY; // O_SYNC - All writes immediately effective, no buffering // O_NOCTTY - Do not make serial terminal the controlling terminal for the process // O_NDELAY - Do not care what state the DCD signal line is in. Used for open only, later disabled. fd = ::open (path.c_str (), flags); portPath = path; name = "Serial-" + portPath; if (fd_is_valid ()) { // Check whether fd is an open file descriptor referring to a terminal if(! isatty (fd)) { error("serial: Interface does not refer to a terminal: %s\n", strerror (errno)); octave_serial::close (); return; } if (tcgetattr (fd, &config) < 0) { error ("serial: Failed to get terminal attributes: %s\n", strerror (errno)); octave_serial::close (); return; } // Clear all settings config.c_iflag = 0; // Input modes config.c_oflag = 0; // Output modes config.c_cflag = CS8 | CREAD | CLOCAL; // Control modes, 8n1 config.c_lflag = 0; // Local modes config.c_cc[VMIN] = 1; if (tcsetattr (fd, TCSANOW, &config) < 0) { error ("serial: Failed to set default terminal attributes: %s\n", strerror (errno)); octave_serial::close (); return; } // Disable NDELAY if (fcntl (fd, F_SETFL, 0) < 0) { error ("serial: Failed to disable NDELAY flag: %s\n", strerror (errno)); octave_serial::close (); return; } timeout = -1; blocking_read = true; } else { error ("serial: Error opening the interface: %s\n", strerror (errno)); return; } } octave_serial::~octave_serial (void) { octave_serial::close(); } int octave_serial::read (uint8_t *buf, unsigned int len) { if (! fd_is_valid ()) { error ("srl_read: Interface must be opened first..."); return 0; } size_t bytes_read = 0; ssize_t read_retval = -1; int maxwait = timeout; // While not interrupted in blocking mode while (bytes_read < len) { OCTAVE_QUIT; read_retval = ::read (fd, (void *)(buf + bytes_read), len - bytes_read); //printf("read_retval: %d\n\r", read_retval); if (read_retval < 0) { error ("srl_read: Error while reading: %s\n", strerror (errno)); break; } bytes_read += read_retval; // Timeout while in non-blocking mode if (read_retval == 0 && !blocking_read) { maxwait -= config.c_cc[VTIME]; // actual timeout if (maxwait <= 0) break; } } return bytes_read; } int octave_serial::write (const std::string &str) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } return ::write (fd, str.c_str (), str.length ()); } int octave_serial::write(uint8_t *buf, unsigned int len) { if (!fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } return ::write (fd, buf, len); } int octave_serial::set_timeout (short newtimeout) { if (! fd_is_valid ()) { error("serial: Interface must be opened first..."); return -1; } if (timeout < -1 || timeout > 255) { error("srl_timeout: timeout value must be between [-1..255]..."); return -1; } timeout = newtimeout; // Disable custom timeout, enable blocking read if (newtimeout < 0) { blocking_read = true; newtimeout = 5; } // Enable custom timeout, disable blocking read else { blocking_read = false; if(newtimeout > 10) newtimeout = 5; } BITMASK_CLEAR (config.c_lflag, ICANON); // Set non-canonical mode config.c_cc[VMIN] = 0; config.c_cc[VTIME] = (unsigned) newtimeout; // Set timeout of 'timeout * 10' seconds if (tcsetattr (fd, TCSANOW, &config) < 0) { error ("srl_timeout: error setting timeout..."); return -1; } return 1; } int octave_serial::get_timeout (void) const { if (blocking_read) return -1; else return timeout; } int octave_serial::set_stopbits (unsigned short stopbits) { if (!fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } /* * CSTOPB Send two stop bits, else one. */ if (stopbits == 1) { // Set to one stop bit BITMASK_CLEAR (config.c_cflag, CSTOPB); } else if (stopbits == 2) { // Set to two stop bits BITMASK_SET (config.c_cflag, CSTOPB); } else { error ("srl_stopbits: Only 1 or 2 stop bits are supported..."); return false; } if (tcsetattr (fd, TCSANOW, &config) < 0) { error ("srl_stopbits: error setting stop bits: %s\n", strerror (errno)); return false; } return true; } int octave_serial::get_stopbits (void) const { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } if (BITMASK_CHECK (config.c_cflag, CSTOPB)) return 2; else return 1; } int octave_serial::set_bytesize (unsigned short bytesize) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } tcflag_t c_bytesize = 0; switch (bytesize) { case 5: c_bytesize = CS5; break; case 6: c_bytesize = CS6; break; case 7: c_bytesize = CS7; break; case 8: c_bytesize = CS8; break; default: error ("srl_bytesize: expecting value between [5..8]..."); return false; } // Clear bitmask CSIZE BITMASK_CLEAR (config.c_cflag, CSIZE); // Apply new BITMASK_SET (config.c_cflag, c_bytesize); if (tcsetattr (fd, TCSANOW, &config) < 0) { error ("srl_bytesize: error setting byte size: %s\n", strerror (errno)); return false; } return true; } int octave_serial::get_bytesize (void) const { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } int retval = -1; if (BITMASK_CHECK_VALUE (config.c_cflag, CSIZE, CS5)) retval = 5; else if (BITMASK_CHECK_VALUE (config.c_cflag, CSIZE, CS6)) retval = 6; else if (BITMASK_CHECK_VALUE (config.c_cflag, CSIZE, CS7)) retval = 7; else if (BITMASK_CHECK_VALUE (config.c_cflag, CSIZE, CS8)) retval = 8; return retval; } int octave_serial::set_baudrate (unsigned int baud) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } speed_t baud_rate = 0; switch (baud) { case 0: baud_rate = B0; break; case 50: baud_rate = B50; break; case 75: baud_rate = B75; break; case 110: baud_rate = B110; break; case 134: baud_rate = B134; break; case 150: baud_rate = B150; break; case 200: baud_rate = B200; break; case 300: baud_rate = B300; break; case 600: baud_rate = B600; break; case 1200: baud_rate = B1200; break; case 1800: baud_rate = B1800; break; case 2400: baud_rate = B2400; break; case 4800: baud_rate = B4800; break; case 9600: baud_rate = B9600; break; case 19200: baud_rate = B19200; break; case 38400: baud_rate = B38400; break; #ifdef B57600 case 57600: baud_rate = B57600; break; #endif #ifdef B115200 case 115200: baud_rate = B115200; break; #endif #ifdef B230400 case 230400: baud_rate = B230400; break; #endif #ifdef B460800 case 460800: baud_rate = B460800; break; #endif #ifdef B500000 case 500000: baud_rate = B500000; break; #endif #ifdef B576000 case 576000: baud_rate = B576000; break; #endif #ifdef B921600 case 921600: baud_rate = B921600; break; #endif #ifdef B1000000 case 1000000: baud_rate = B1000000; break; #endif #ifdef B1152000 case 1152000: baud_rate = B1152000; break; #endif #ifdef B2000000 case 2000000: baud_rate = B2000000; break; #endif #ifdef B3000000 case 3000000: baud_rate = B3000000; break; #endif #ifdef B3500000 case 3500000: baud_rate = B3500000; break; #endif #ifdef B4000000 case 4000000: baud_rate = B4000000; break; #endif default: error ("serial: baud rate not supported..."); return false; } cfsetispeed (&config, baud_rate); cfsetospeed (&config, baud_rate); if (tcsetattr (fd, TCSANOW, &config) < 0) { error ("srl_baudrate: error setting baud rate: %s\n", strerror (errno)); return false; } return true; } int octave_serial::get_baudrate (void) const { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } int retval = -1; speed_t baudrate = cfgetispeed (&config); if (baudrate == B0) retval = 0; else if (baudrate == B50) retval = 50; else if (baudrate == B75) retval = 75; else if (baudrate == B110) retval = 110; else if (baudrate == B134) retval = 134; else if (baudrate == B150) retval = 150; else if (baudrate == B200) retval = 200; else if (baudrate == B300) retval = 300; else if (baudrate == B600) retval = 600; else if (baudrate == B1200) retval = 1200; else if (baudrate == B1800) retval = 1800; else if (baudrate == B2400) retval = 2400; else if (baudrate == B4800) retval = 4800; else if (baudrate == B9600) retval = 9600; else if (baudrate == B19200) retval = 19200; else if (baudrate == B38400) retval = 38400; else if (baudrate == B57600) retval = 57600; else if (baudrate == B115200) retval = 115200; else if (baudrate == B230400) retval = 230400; return retval; } int octave_serial::flush (unsigned short queue_selector) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } /* * TCIOFLUSH Flush both pending input and untransmitted output. * TCOFLUSH Flush untransmitted output. * TCIFLUSH Flush pending input. */ int flag; switch (queue_selector) { case 0: flag = TCOFLUSH; break; case 1: flag = TCIFLUSH; break; case 2: flag = TCIOFLUSH; break; default: error("srl_flush: only [0..2] values are accepted..."); return false; } return ::tcflush (fd, flag); } int octave_serial::set_parity (const std::string &newparity) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } // Convert string to lowercase std::string parity = newparity; std::transform (parity.begin (), parity.end (), parity.begin (), ::tolower); /* * PARENB Enable parity generation on output and parity checking for input. * PARODD If set, then parity for input and output is odd; otherwise even parity is used. */ if (parity == "n" || parity == "none") { // Disable parity generation/checking BITMASK_CLEAR (config.c_cflag, PARENB); } else if (parity == "e" || parity == "even") { // Enable parity generation/checking BITMASK_SET (config.c_cflag, PARENB); // Set to Even BITMASK_CLEAR (config.c_cflag, PARODD); } else if (parity == "o" || parity == "odd") { // Enable parity generation/checking BITMASK_SET (config.c_cflag, PARENB); // Set to Odd BITMASK_SET (config.c_cflag, PARODD); } else { error ("srl_parity: Only [N]one, [E]ven or [O]dd parities are supported..."); return false; } if (tcsetattr (fd, TCSANOW, &config) < 0) { error ("srl_parity: error setting parity: %s\n", strerror (errno)); return false; } return true; } std::string octave_serial::get_parity (void) const { if (!BITMASK_CHECK (config.c_cflag, PARENB)) return "None"; else if (BITMASK_CHECK (config.c_cflag, PARODD)) return "Odd"; else return "Even"; } void octave_serial::get_control_line_status (void) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return; } ioctl (fd, TIOCMGET, &status); } bool octave_serial::get_control_line (const std::string &control_signal) { get_control_line_status (); if (control_signal == "DTR") return (status & TIOCM_DTR); else if (control_signal == "RTS") return (status & TIOCM_RTS); else if (control_signal == "CTS") return (status & TIOCM_CTS); else if (control_signal == "DSR") return (status & TIOCM_DSR); else if (control_signal == "CD") return (status & TIOCM_CD); else if (control_signal == "RI") return (status & TIOCM_RI); error ("serial: Unknown control signal..."); return false; } void octave_serial::set_control_line (const std::string &control_signal, bool set) { get_control_line_status (); int signal; if (control_signal == "DTR") signal = TIOCM_DTR; else if (control_signal == "RTS") signal = TIOCM_RTS; else { error ("serial: Unknown control signal..."); return; } if (set) status |= signal; else status &= ~signal; ioctl (fd, TIOCMSET, &status); } bool octave_serial::fd_is_valid (void) const { return (fd >= 0); } void octave_serial::close (void) { if (fd_is_valid ()) { ::close (fd); fd = -1; } } int octave_serial::get_bytesavailable (void) const { int available = 0; if (fd_is_valid ()) { ioctl (fd, FIONREAD, &available); } return available; } #endif instrument-control-0.4.0/src/serial/serial_class_lin.h0000644000000000000000000000401013460206417021312 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef SERIAL_CLASS_LIN_H #define SERIAL_CLASS_LIN_H #include #include class octave_serial : public octave_serial_common { public: octave_serial(void); ~octave_serial(void); int write(const std::string& /* buffer */); int write(uint8_t* /* buffer */, unsigned int /* buffer size */); int read(uint8_t* /* buffer */, unsigned int /* buffer size */); void open(const std::string& /* path */); void close(void); int flush(unsigned short /* stream select */); int set_timeout(short /* timeout */); int get_timeout(void) const; int set_baudrate(unsigned int /* baudrate */); int get_baudrate(void) const; int set_bytesize(unsigned short /* bytesize */); int get_bytesize(void) const; int set_parity(const std::string& /* parity */); std::string get_parity() const; int set_stopbits(unsigned short /* stop bits */); int get_stopbits(void) const; bool get_control_line(const std::string &); void set_control_line(const std::string &, bool); int get_bytesavailable(void) const; private: int fd; int status; struct termios config; short timeout; volatile bool blocking_read; void get_control_line_status(void); bool fd_is_valid(void) const; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/serial/serial_class_win32.cc0000644000000000000000000002702213460206417021640 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2014 John Donoghue // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_SERIAL #include #include #include using std::string; #include "serial_class.h" char * winerror (int err) { static char errstring[100]; if (err != 0) return strerror (err); else { DWORD e; e = GetLastError (); if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errstring, sizeof(errstring)-1, 0) < 0) { errstring[0] = '\0'; } } return errstring; } DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_serial, "octave_serial", "octave_serial"); octave_serial::octave_serial(void) { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); INSTALL_BINOP (op_eq, octave_serial, octave_serial, eq_serial_serial); INSTALL_BINOP (op_ne, octave_serial, octave_serial, ne_serial_serial); } fd = INVALID_HANDLE_VALUE; } void octave_serial::open (const std::string &path) { fd = CreateFile(path.c_str (), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); portPath = path; name = "Serial-" + path; if (! fd_is_valid()) { error("serial: Error opening the interface: %s\n", winerror (errno)); return; } // clear any errors that may be on the port COMSTAT stats; DWORD err; ClearCommError (fd, &err, &stats); // Clean the configuration struct (DCB) memset (&config, 0, sizeof (config)); // set up device settings config.DCBlength = sizeof (config); if(GetCommState (fd, &config) == FALSE) { error ("serial: Failed to get terminal attributes: %s\n", winerror (errno)); octave_serial::close (); return; } timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.ReadTotalTimeoutMultiplier = 0; timeouts.ReadTotalTimeoutConstant = 0; timeouts.WriteTotalTimeoutMultiplier = 0; timeouts.WriteTotalTimeoutConstant = 0; timeout = -1; if (SetCommTimeouts(fd, &timeouts) == FALSE) { error ("serial: Failed to disable timeouts: %s\n", winerror (errno)); octave_serial::close (); return; } return; } octave_serial::~octave_serial(void) { octave_serial::close(); } int octave_serial::read(uint8_t *buf, unsigned int len) { if (! fd_is_valid ()) { error ("srl_read: Interface must be opened first..."); return 0; } size_t bytes_read = 0; ssize_t read_retval = -1; int maxwait = timeout; // While not interrupted in blocking mode while (bytes_read < len) { OCTAVE_QUIT; DWORD readsz; read_retval = -1; if (ReadFile (fd, (buf + bytes_read), len - bytes_read, &readsz, NULL) == TRUE) { read_retval = readsz; } if(read_retval < 0) { error ("srl_read: Error while reading: %s\n", winerror (errno)); break; } bytes_read += read_retval; if (read_retval == 0 && !blocking_read) { maxwait -= timeouts.ReadTotalTimeoutConstant/100; // actual timeout if (maxwait <= 0) break; } } return bytes_read; } int octave_serial::write (const std::string & str) { if (! fd_is_valid ()) { error("serial: Interface must be opened first..."); return -1; } int wrote_ret = -1; DWORD wrote; if (WriteFile (fd, str.c_str (), str.length (), &wrote, NULL) == TRUE) { wrote_ret = wrote; } return wrote_ret; } int octave_serial::write (uint8_t *buf, unsigned int len) { if (! fd_is_valid ()) { error("serial: Interface must be opened first..."); return -1; } int wrote_ret = -1; DWORD wrote; if (WriteFile (fd, buf, len, &wrote, NULL) == TRUE) { wrote_ret = wrote; } return wrote_ret; } int octave_serial::set_timeout (short newtimeout) { if (! fd_is_valid()) { error ("serial: Interface must be opened first..."); return -1; } if (newtimeout < -1 || newtimeout > 255) { error ("srl_timeout: timeout value must be between [-1..255]..."); return -1; } timeout = newtimeout; // Disable custom timeout, enable blocking read if (newtimeout < 0) { blocking_read = true; newtimeout = 5; } // Enable custom timeout, disable blocking read else { blocking_read = false; if (newtimeout > 10) newtimeout = 5; } timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.ReadTotalTimeoutMultiplier = 0; timeouts.ReadTotalTimeoutConstant = newtimeout*100; timeouts.WriteTotalTimeoutMultiplier = 0; timeouts.WriteTotalTimeoutConstant = 0; if (SetCommTimeouts (fd, &timeouts) == FALSE) { error ("srl_timeout: error setting timeout..."); return -1; } return 1; } int octave_serial::get_timeout (void) const { if (blocking_read) return -1; else return timeout; } int octave_serial::set_stopbits (unsigned short stopbits) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } if (stopbits == 1) { // Set to one stop bit config.StopBits = ONESTOPBIT; } else if (stopbits == 2) { // Set to two stop bits config.StopBits = TWOSTOPBITS; } else { error ("srl_stopbits: Only 1 or 2 stop bits are supported..."); return false; } if (SetCommState (fd,&config) == FALSE) { error ("srl_stopbits: error setting stop bits: %s\n", winerror (errno)); return false; } return true; } int octave_serial::get_stopbits (void) const { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } if (config.StopBits == TWOSTOPBITS) return 2; else return 1; } int octave_serial::set_bytesize (unsigned short bytesize) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } if(bytesize < 5 || bytesize > 8) { error ("srl_bytesize: expecting value between [5..8]..."); return false; } config.ByteSize = bytesize; if (SetCommState (fd, &config) == FALSE) { error ("serial: error setting byte size: %s\n", winerror (errno)); return false; } return true; } int octave_serial::get_bytesize (void) const { if (! fd_is_valid ()) { error("serial: Interface must be opened first..."); return -1; } return config.ByteSize; } int octave_serial::set_baudrate (unsigned int baud) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } DWORD old_baud = config.BaudRate; config.BaudRate = baud; if (SetCommState (fd, &config) == FALSE) { error ("serial: error setting baud rate: %s\n", winerror (errno)); config.BaudRate = old_baud; return false; } return true; } int octave_serial::get_baudrate (void) const { if (! fd_is_valid ()) { error("serial: Interface must be opened first..."); return -1; } return config.BaudRate; } int octave_serial::flush (unsigned short queue_selector) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } int flag; switch (queue_selector) { case 0: flag = PURGE_TXCLEAR; break; case 1: flag = PURGE_RXCLEAR; break; case 2: flag = PURGE_RXCLEAR|PURGE_TXCLEAR; break; default: error ("srl_flush: only [0..2] values are accepted..."); return false; } if (PurgeComm (fd,flag) == FALSE) return -1; else return true; } int octave_serial::set_parity (const std::string &newparity) { if (! fd_is_valid ()) { error ("serial: Interface must be opened first..."); return -1; } // Convert string to lowercase std::string parity = newparity; std::transform (parity.begin (), parity.end (), parity.begin (), ::tolower); /* * PARENB Enable parity generation on output and parity checking for input. * PARODD If set, then parity for input and output is odd; otherwise even parity is used. */ if (parity == "n" || parity == "none") { // Disable parity generation/checking config.Parity = NOPARITY; } else if (parity == "e" || parity == "even") { // Enable parity generation/checking config.Parity = EVENPARITY; } else if (parity == "o" || parity == "odd") { config.Parity = ODDPARITY; } else { error ("srl_parity: Only [N]one, [E]ven or [O]dd parities are supported..."); return false; } if (SetCommState (fd, &config) == FALSE) { error ("srl_parity: error setting parity: %s\n", winerror (errno)); return false; } return true; } std::string octave_serial::get_parity (void) const { if(config.Parity == NOPARITY) return "None"; else if(config.Parity == ODDPARITY) return "Odd"; else return "Even"; } void octave_serial::get_control_line_status (void) { if (! fd_is_valid()) { error ("serial: Interface must be opened first..."); return; } GetCommState (fd, &config); GetCommModemStatus (fd, &status); } bool octave_serial::get_control_line (const std::string &control_signal) { get_control_line_status (); if (control_signal == "DTR") return (config.fDtrControl == DTR_CONTROL_ENABLE); else if (control_signal == "RTS") return (config.fRtsControl == RTS_CONTROL_ENABLE); else if (control_signal == "CTS") return (status & MS_CTS_ON); else if (control_signal == "DSR") return (status & MS_DSR_ON); else if (control_signal == "CD") return (status & MS_RLSD_ON); else if (control_signal == "RI") return (status & MS_RING_ON); else error("serial: Unknown control signal..."); return false; } void octave_serial::set_control_line (const std::string &control_signal, bool set) { get_control_line_status (); int signal; if (control_signal == "DTR") { if(set) config.fDtrControl = DTR_CONTROL_ENABLE; else config.fDtrControl = DTR_CONTROL_DISABLE; } else if (control_signal == "RTS") { if(set) config.fRtsControl = RTS_CONTROL_ENABLE; else config.fRtsControl = RTS_CONTROL_DISABLE; } else { error("serial: Unknown control signal..."); return; } SetCommState (fd, &config); } bool octave_serial::fd_is_valid (void) const { return (fd != INVALID_HANDLE_VALUE); } void octave_serial::close (void) { if (fd_is_valid ()) { CloseHandle(fd); fd = INVALID_HANDLE_VALUE; } } int octave_serial::get_bytesavailable (void) const { int available = 0; if (fd_is_valid ()) { COMSTAT stats; DWORD err; if (ClearCommError (fd, &err, &stats)) available = stats.cbInQue; } return available; } #endif instrument-control-0.4.0/src/serial/serial_class_win32.h0000644000000000000000000000403713460206417021503 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef SERIAL_CLASS_WIN32_H #define SERIAL_CLASS_WIN32_H #include #include class octave_serial : public octave_serial_common { public: octave_serial(void); ~octave_serial(void); int write(const std::string& /* buffer */); int write(uint8_t* /* buffer */, unsigned int /* buffer size */); int read(uint8_t* /* buffer */, unsigned int /* buffer size */); void open(const std::string& /* path */); void close(void); int flush(unsigned short /* stream select */); int set_timeout(short /* timeout */); int get_timeout(void) const; int set_baudrate(unsigned int /* baudrate */); int get_baudrate() const; int set_bytesize(unsigned short /* bytesize */); int get_bytesize(void) const; int set_parity(const std::string& /* parity */); std::string get_parity(void) const; int set_stopbits(unsigned short /* stop bits */); int get_stopbits(void) const; bool get_control_line(const std::string &); void set_control_line(const std::string&, bool); int get_bytesavailable(void) const; private: HANDLE fd; DWORD status; DCB config; COMMTIMEOUTS timeouts; volatile bool blocking_read; short timeout; void get_control_line_status(void); bool fd_is_valid(void) const; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/serial/srl_read.cc0000644000000000000000000000516613460206417017752 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_SERIAL #include #include #include "serial_class.h" #endif // PKG_ADD: autoload ("srl_read", "serial.oct"); DEFUN_DLD (srl_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}] = } srl_read (@var{serial}, @var{n})\n \ \n\ Read from serial interface.\n \ \n\ @var{serial} - instance of @var{octave_serial} class.@*\ @var{n} - number of bytes to attempt to read of type Integer.\n \ \n\ The srl_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @end deftypefn") { #ifndef BUILD_SERIAL error("serial: Your system doesn't support the SERIAL interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_serial::static_type_id ()) { print_usage (); return octave_value (-1); } unsigned int buffer_len = 0; if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } buffer_len = args (1).int_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buffer, (buffer_len + 1)); if (buffer == NULL) { error ("srl_read: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value (-1); } octave_serial* serial = NULL; const octave_base_value& rep = args (0).get_rep (); serial = &((octave_serial &)rep); // Read data int bytes_read = serial->read (buffer, buffer_len); // Convert data to octave type variables octave_value_list return_list; uint8NDArray data (dim_vector (1, bytes_read)); for (int i = 0; i < bytes_read; i++) data (i) = buffer[i]; return_list (0) = data; return_list (1) = bytes_read; return return_list; #endif } instrument-control-0.4.0/src/serial/srl_write.cc0000644000000000000000000000476013460206417020170 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_SERIAL #include "serial_class.h" #endif // PKG_ADD: autoload ("srl_write", "serial.oct"); DEFUN_DLD (srl_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } srl_write (@var{serial}, @var{data})\n \ \n\ Write data to a serial interface.\n \ \n\ @var{serial} - instance of @var{octave_serial} class.@*\ @var{data} - data to be written to the serial interface. Can be either of String or uint8 type.\n \ \n\ Upon successful completion, srl_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_SERIAL error ("serial: Your system doesn't support the SERIAL interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_serial::static_type_id ()) { print_usage (); return octave_value (-1); } octave_serial *serial = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); serial = &((octave_serial &)rep); if (args (1).is_string ()) // String { retval = serial->write (args (1).string_value ()); } else if (args (1).is_uint8_type ()) // uint8_t { NDArray data = args (1).array_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buf, (data.numel ())); if (buf == NULL) { error ("srl_write: cannot allocate requested memory"); return octave_value (-1); } for (int i = 0; i < data.numel (); i++) buf[i] = static_cast(data(i)); retval = serial->write (buf, data.numel ()); } else { print_usage (); return octave_value (-1); } return octave_value (retval); #endif } instrument-control-0.4.0/src/tcp/0000755000000000000000000000000013460206417015147 5ustar0000000000000000instrument-control-0.4.0/src/tcp/Makefile.in0000644000000000000000000000150713460206417017217 0ustar0000000000000000OCT := ../tcp.oct OBJ := tcp.o tcp_timeout.o tcp_write.o tcp_close.o tcp_read.o tcp_class.o __tcp_properties__.o __tcp_pkg_lock__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ LFLAGS = @TCPLIBS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ $(LFLAGS) $(TCPLIBS) -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/tcp/__tcp_pkg_lock__.cc0000644000000000000000000000263713460206417020721 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__tcp_pkg_lock__", "tcp.oct"); // PKG_ADD: __tcp_pkg_lock__(1); // PKG_DEL: __tcp_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__tcp_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__tcp_pkg_lock__")) interp.munlock("__tcp_pkg_lock__"); } return retval; } #else DEFUN_DLD(__tcp_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/tcp/__tcp_properties__.cc0000644000000000000000000001163713460206417021324 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // Copyright (C) 2014 Stefan Mahr // Copyright (C) 2016 John Donoghue // Copyright (C) 2018 John Donoghue // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_UDP # include "tcp_class.h" #endif // PKG_ADD: autoload ("__tcp_properties__", "tcp.oct"); DEFUN_DLD (__tcp_properties__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {varargout =} __tcp_properties__ (@var{octave_tcp}, @var{property}, @var{varargin})\n\ Undocumented internal function.\n\ @end deftypefn") { #ifdef BUILD_UDP if (args.length () < 2 || args.length () > 3 || args(0).type_id () != octave_tcp::static_type_id () || !args(1).is_string ()) (*current_liboctave_error_handler) ("wrong number of arguments"); const octave_base_value& rep = args(0).get_rep (); octave_tcp* tcp = &((octave_tcp &)rep); std::string property = args(1).string_value (); if (args.length () == 2) // get { if (property == "name") return octave_value (tcp->get_name ()); else if (property == "type") return octave_value (tcp->get_type ()); else if (property == "remoteport") return octave_value (tcp->get_remote_port ()); else if (property == "remotehost") return octave_value (tcp->get_remote_addr ()); else if (property == "localport") return octave_value (tcp->get_local_port ()); else if (property == "status") return octave_value (tcp->get_status ()); else if (property == "timeout") return octave_value (tcp->get_timeout ()); else if (property == "bytesavailable") return octave_value (tcp->get_bytesavailable ()); else (*current_liboctave_error_handler) ("invalid property name"); } else // set { if (property == "name") return octave_value (tcp->set_name (args(2).string_value ())); else if (property == "type") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "remoteport") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "remotehost") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "localport") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "status") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "timeout") return octave_value (tcp->set_timeout (args(2).int_value ())); else if (property == "flush") return octave_value (tcp->flush (args(2).int_value ())); else (*current_liboctave_error_handler) ("invalid property name"); } #endif /* never reached in normal operation */ (*current_liboctave_error_handler) ("Your system doesn't support the UDP interface"); } #if 0 %!shared ip %! ip = resolvehost("www.octave.org", "address"); %!test %! # test get %! a = tcp (ip, 80); %! assert (__tcp_properties__ (a,"type"), "tcp"); %! assert (__tcp_properties__ (a,"remoteport"), 80); %! assert (__tcp_properties__ (a,"remotehost"), ip); %! assert (__tcp_properties__ (a,"timeout"), -1); %! assert (__tcp_properties__ (a,"status"), "open"); %! assert (__tcp_properties__ (a,"name"), ["TCP-" ip]); %! fail ("__tcp_properties__ (a,'invalid')", "invalid property name"); %! tcp_close (a); %! assert (__tcp_properties__ (a,"status"), "closed"); %!test %! # test set %! a = tcp(ip, 80); %! __tcp_properties__ (a, 'name', "mytest"); %! assert (__tcp_properties__ (a,"name"), "mytest"); %! fail ("__tcp_properties__ (a,'invalid', 1)", "invalid property name"); %! tcp_close (a); %!test %! # test flush %! a = tcp(ip, 80); %! __tcp_properties__ (a, 'flush', 0); %! __tcp_properties__ (a, 'flush', 1); %! __tcp_properties__ (a, 'flush', 2); %! fail ("__tcp_properties__ (a,'flush')", "invalid property name"); %! tcp_close (a); %!error __tcp_properties__ () %!error __tcp_properties__ (1) %!test %! a = tcp (ip, 80); %! fail ("__tcp_properties__ (a, 'name', 'test', 0)", "wrong number of arguments"); %! tcp_close (a); #endif instrument-control-0.4.0/src/tcp/tcp.cc0000644000000000000000000000642413460206417016252 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_TCP # include "tcp_class.h" #endif // PKG_ADD: autoload ("tcp", "tcp.oct"); DEFUN_DLD (tcp, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{tcp} = } tcp ([@var{ipaddress}], [@var{port}], [@var{timeout}])\n \ \n\ Open tcp interface.\n \ \n\ @var{ipaddress} - the ip address of type String. If omitted defaults to '127.0.0.1'.@* \ @var{port} - the port number to connect. If omitted defaults to 23.@* \ @var{timeout} - the interface timeout value. If omitted defaults to blocking call.\n \ \n\ The tcp() shall return instance of @var{octave_tcp} class as the result @var{tcp}.\n \ @end deftypefn") { #ifndef BUILD_TCP error("tcp: Your system doesn't support the TCP interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values std::string address ("127.0.0.1"); int port = 23; int timeout = -1; // Parse the function arguments if (args.length () > 0) { if (args (0).is_string ()) { address = args (0).string_value (); } else { print_usage (); return octave_value (); } } // is_float_type() is or'ed to allow expression like ("", 123), without user // having to use ("", int32(123)), as we still only take "int_value" if (args.length () > 1) { if (args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) { port = args (1).int_value (); } else { print_usage (); return octave_value (); } } if (args.length () > 2) { if (args (2).OV_ISINTEGER () || args (2).OV_ISFLOAT ()) { timeout = args (2).int_value (); } else { print_usage (); return octave_value (); } } // Open the interface and connect octave_tcp* retval = new octave_tcp (); if (retval->open (address, port) < 0) { return octave_value (); } retval->set_timeout (timeout); //retval->flush (2); return octave_value (retval); #endif } #if 0 %!test %! addr = resolvehost ('gnu.org', 'address'); %! a = tcp (addr, 80); %! assert (! isnull (a)); %! assert (isa (a, 'octave_tcp')); %! tcp_close (a); %!error tcp (1) %!error tcp (1, 1) #endif instrument-control-0.4.0/src/tcp/tcp_class.cc0000644000000000000000000002011713460206417017432 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_TCP #include #include #include #ifndef __WIN32__ #include #include #include #include #include #include #include #include #else #include #endif #ifndef __WIN32__ #define SOCKETERR errno #define STRSOCKETERR strerror(errno) #define IOCTL_TYPE int #else #define SOCKETERR WSAGetLastError() #define STRSOCKETERR "" #define IOCTL_TYPE u_long #define ioctl ioctlsocket #define socklen_t int #endif #include "tcp_class.h" static std::string to_ip_str (const sockaddr_in *in) { u_long addr = ntohl (in->sin_addr.s_addr); int b[4]; b[0] = (addr>>24)&0xff; b[1] = (addr>>16)&0xff; b[2] = (addr>>8)&0xff; b[3] = (addr>>0)&0xff; std::stringstream n; n << b[0] << "." << b[1] << "." << b[2] << "." << b[3]; return n.str (); } DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_tcp, "octave_tcp", "octave_tcp"); octave_tcp::octave_tcp (void) : fd (-1), timeout(-1), name("") { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); } } int octave_tcp::open (const std::string &address, int port) { int sockerr; name = "TCP-" + address; #ifdef __WIN32__ WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD( 2, 2 ); err = WSAStartup (wVersionRequested, &wsaData); if ( err != 0 ) { error( "could not initialize winsock library" ); return -1; } #endif memset (&remote_addr, 0, sizeof (remote_addr)); remote_addr.sin_addr.s_addr = inet_addr (address.c_str ()); remote_addr.sin_family = AF_INET; remote_addr.sin_port = htons (port); fd = socket (AF_INET, SOCK_STREAM,0); if (fd < 0) { error ("tcp: error opening socket : %d - %s\n", SOCKETERR, STRSOCKETERR); octave_tcp::close (); return -1; } // get local socket info memset (&local_addr, 0, sizeof (local_addr)); socklen_t sz = sizeof (local_addr); getsockname (fd, (struct sockaddr*)&local_addr, &sz); sockerr = connect (fd, (struct sockaddr*)&remote_addr, sizeof(struct sockaddr)); if (sockerr < 0) { error ("tcp: error on connect : %d - %s\n", SOCKETERR, STRSOCKETERR); octave_tcp::close (); return -1; } return get_fd(); } octave_tcp::~octave_tcp (void) { octave_tcp::close (); } void octave_tcp::print (std::ostream& os, bool pr_as_read_syntax) { print_raw (os, pr_as_read_syntax); newline (os); } void octave_tcp::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw (os, pr_as_read_syntax); newline (os); } void octave_tcp::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << " TCP Object " << get_name (); newline(os); os << " type: " << get_type (); newline(os); os << " status: " << get_status (); newline(os); os << " remoteport: " << get_remote_port (); newline(os); os << " remotehost: " << get_remote_addr (); newline(os); os << " localport: " << get_local_port (); newline (os); } int octave_tcp::read (uint8_t *buf, unsigned int len, int readtimeout) { struct timeval tv; fd_set readfds; if (get_fd () < 0) { error ("tcp_read: Interface must be opened first..."); return 0; } size_t bytes_read = 0; ssize_t read_retval = -1; // While not interrupted in blocking mode while (bytes_read < len) { OCTAVE_QUIT; /* tv.tv_sec = timeout / 1000; * tv.tv_usec = (timeout % 1000) * 1000; */ if (readtimeout < 0) { tv.tv_sec = 1; tv.tv_usec = 0; } else { tv.tv_sec = 0; if (readtimeout > 1000) tv.tv_usec = 1000 * 1000; else tv.tv_usec = readtimeout * 1000; } FD_ZERO (&readfds); FD_SET (get_fd (), &readfds); if (::select (get_fd ()+1, &readfds, NULL, NULL, &tv) < 0) { error ("tcp_read: Error while reading/select: %d - %s\n", SOCKETERR, STRSOCKETERR); break; } if (FD_ISSET (get_fd (), &readfds)) { read_retval = ::recv(get_fd (), reinterpret_cast((buf + bytes_read)), len - bytes_read, 0); if (read_retval < 0) { error ("tcp_read: Error while reading: %d - %s\n", SOCKETERR, STRSOCKETERR); break; } else if (read_retval == 0) { error ("tcp_read: Connection lost: %d - %s\n", SOCKETERR, STRSOCKETERR); break; } else { bytes_read += read_retval; } } else { // time out if (readtimeout >= 0) { // real timeout if (readtimeout <= 1000) break; // timed out 1 sec of an actual timeout else readtimeout -= 1000; } } } return bytes_read; } int octave_tcp::write (const std::string &str) { if (get_fd () < 0) { error ("tcp: Interface must be opened first..."); return -1; } return ::send (get_fd (), str.c_str (), str.length (), 0); } int octave_tcp::write (uint8_t *buf, unsigned int len) { if (get_fd () < 0) { error ("tcp: Interface must be opened first..."); return -1; } return ::send (get_fd (), reinterpret_cast(buf), len, 0); } int octave_tcp::set_timeout (int newtimeout) { if (get_fd () < 0) { error ("tcp: Interface must be opened first..."); return -1; } if (newtimeout < -1 ) { error ("tcp_timeout: timeout value must be -1 or positive"); return -1; } timeout = newtimeout; return 1; } int octave_tcp::close (void) { int retval = -1; if (get_fd() > 0) { #ifndef __WIN32__ retval = ::close (get_fd ()); #else retval = ::closesocket (get_fd ()); #endif fd = -1; } return retval; } int octave_tcp::get_bytesavailable () const { IOCTL_TYPE available = 0; if (get_fd () <= 0) { return 0; } ioctl (get_fd (), FIONREAD, &available); return available; } int octave_tcp::get_remote_port (void) const { return ntohs (remote_addr.sin_port); } std::string octave_tcp::get_remote_addr (void) const { return to_ip_str (&remote_addr); } int octave_tcp::get_local_port (void) const { return ntohs (local_addr.sin_port); } std::string octave_tcp::set_name (const std::string &n) { if (n.length() == 0 ) { error ("tcp_name: value must be non empty"); } else { name = n; } return name; } bool octave_tcp::is_open (void) const { return fd > 0; } std::string octave_tcp::get_status (void) const { if (! is_open ()) { return "closed"; } else { return "open"; } } int octave_tcp::flush (int mode) { int retval = -1; if (get_fd() > 0) { uint8_t tmpbuffer[1024]; if (mode == 0 || mode == 2) { // we are sending data as we get it, so no outout // buffers to flush } if (mode == 1 || mode == 2) { while (read (tmpbuffer, 1024, 0) > 0) {} } } return retval; } #endif instrument-control-0.4.0/src/tcp/tcp_class.h0000644000000000000000000000476013460206417017302 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef TCP_CLASS_H #define TCP_CLASS_H #include #include #include #ifndef __WIN32__ # include #else # include #endif class octave_tcp : public octave_base_value { public: octave_tcp (void); ~octave_tcp (void); int write (const std::string &); int write (uint8_t *, unsigned int); int read (uint8_t *, unsigned int, int); int open (const std::string &, int); int close (void); int get_fd (void) const { return fd; } int flush (int mode); int set_timeout (int); int get_timeout (void) const { return timeout; } // Overloaded base functions double tcp_value (void) const { return (double)fd; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)fd; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool is_object (void) const { return true; } int get_bytesavailable (void) const; std::string get_name (void) const { return name; } std::string set_name (const std::string &); std::string get_remote_addr (void) const; int get_remote_port (void) const; bool is_open(void) const; std::string get_type (void) const { return "tcp"; } std::string get_status (void) const; int get_local_port (void) const; private: int fd; int timeout; std::string name; sockaddr_in remote_addr; sockaddr_in local_addr; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/tcp/tcp_close.cc0000644000000000000000000000345013460206417017433 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_TCP #include "tcp_class.h" #endif // PKG_ADD: autoload ("tcp_close", "tcp.oct"); DEFUN_DLD (tcp_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} tcp_close (@var{tcp})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{tcp} - instance of @var{octave_tcp} class.\n \ @end deftypefn") { #ifndef BUILD_TCP error ("tcp: Your system doesn't support the TCP interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_tcp::static_type_id ()) { print_usage (); return octave_value (-1); } octave_tcp* tcp = NULL; const octave_base_value& rep = args (0).get_rep (); tcp = &((octave_tcp &)rep); tcp->close (); return octave_value (); #endif } #if 0 %!test %! addr = resolvehost ('gnu.org', 'address'); %! a = tcp (addr, 80); %! tcp_close (a); %!error tcp_close (1) %!error tcp_close () #endif instrument-control-0.4.0/src/tcp/tcp_read.cc0000644000000000000000000000722413460206417017244 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_TCP #include #include #include "tcp_class.h" #endif // PKG_ADD: autoload ("tcp_read", "tcp.oct"); DEFUN_DLD (tcp_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}] = } tcp_read (@var{tcp}, @var{n}, @var{timeout})\n \ \n\ Read from tcp interface.\n \ \n\ @var{tcp} - instance of @var{octave_tcp} class.@* \ @var{n} - number of bytes to attempt to read of type Integer@* \ @var{timeout} - timeout in ms if different from default of type Integer\n \ \n\ The tcp_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @end deftypefn") { #ifndef BUILD_TCP error ("tcp: Your system doesn't support the TCP interface"); return octave_value (); #else if (args.length() < 2 || args.length () > 3 || args (0).type_id () != octave_tcp::static_type_id ()) { print_usage (); return octave_value (-1); } unsigned int buffer_len = 0; if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ())) { print_usage (); return octave_value (-1); } if ( args.length () > 2 ) { if ( !(args (2).OV_ISINTEGER () || args (2).OV_ISFLOAT ())) { print_usage (); return octave_value (-1); } } buffer_len = args (1).int_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buffer, (buffer_len + 1)); if (buffer == NULL) { error ("tcp_read: cannot allocate requested memory: %s\n", strerror(errno)); return octave_value (-1); } octave_tcp* tcp = NULL; const octave_base_value& rep = args (0).get_rep (); tcp = &((octave_tcp &)rep); int timeout = tcp->get_timeout (); if (args.length () == 3) { timeout = args (2).int_value (); } // Read data int bytes_read = tcp->read (buffer, buffer_len, timeout); // Convert data to octave type variables octave_value_list return_list; uint8NDArray data (dim_vector (1, bytes_read) ); for (int i = 0; i < bytes_read; i++) data(i) = buffer[i]; return_list(0) = data; return_list(1) = bytes_read; return return_list; #endif } #if 0 %!test %! addr = resolvehost ('gnu.org', 'address'); %! a = tcp (addr, 80); %! assert (! isnull (a)); %! # server should be waiting for us to send request %! fail ("tcp_read (a, 10, 0, 0)", "Invalid call to tcp_read"); %! %! [d,c] = tcp_read (a, 1, 0); %! assert (0, c); %! assert (isempty (d)); %! %! tic; %! [d,c] = tcp_read (a, 1, 1000); %! t = toc; %! assert (c, 0); %! assert (isempty (d)); %! assert (t, 1.0, 0.1) %! %! tcp_close (a); %!error tcp_read (1) %!error tcp_read (1, 10, 0) #endif instrument-control-0.4.0/src/tcp/tcp_timeout.cc0000644000000000000000000000464613460206417020024 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_TCP #include "tcp_class.h" #endif // PKG_ADD: autoload ("tcp_timeout", "tcp.oct"); DEFUN_DLD (tcp_timeout, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} tcp_timeout (@var{tcp}, @var{timeout})\n \ @deftypefnx {Loadable Function} {@var{t} = } tcp_timeout (@var{tcp})\n \ \n\ Set new or get existing tcp interface timeout parameter used for tcp_read() requests. The timeout value is specified in milliseconds.\n \ \n\ @var{tcp} - instance of @var{octave_tcp} class.@* \ @var{timeout} - tcp_read() timeout value in milliseconds. Value of -1 means a blocking call.\n \ \n\ If @var{timeout} parameter is omitted, the tcp_timeout() shall return current timeout value as the result @var{t}.\n \ @end deftypefn") { #ifndef BUILD_TCP error("tcp: Your system doesn't support the TCP interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_tcp::static_type_id ()) { print_usage (); return octave_value (-1); } octave_tcp* tcp = NULL; const octave_base_value& rep = args (0).get_rep (); tcp = &((octave_tcp &)rep); // Setting new timeout if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } tcp->set_timeout (args (1).int_value ()); return octave_value (); // Should it return by default? } // Returning current timeout return octave_value (tcp->get_timeout ()); #endif } instrument-control-0.4.0/src/tcp/tcp_write.cc0000644000000000000000000000564013460206417017463 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_TCP #include "tcp_class.h" #endif // PKG_ADD: autoload ("tcp_write", "tcp.oct"); DEFUN_DLD (tcp_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } tcp_write (@var{tcp}, @var{data})\n \ \n\ Write data to a tcp interface.\n \ \n\ @var{tcp} - instance of @var{octave_tcp} class.@* \ @var{data} - data to be written to the tcp interface. Can be either of String or uint8 type.\n \ \n\ Upon successful completion, tcp_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_TCP error("tcp: Your system doesn't support the TCP interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_tcp::static_type_id ()) { print_usage (); return octave_value (-1); } octave_tcp *tcp = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); tcp = &((octave_tcp &)rep); if (args (1).is_string ()) // String { retval = tcp->write (args (1).string_value ()); } else if (args (1).is_uint8_type ()) { NDArray data = args (1).array_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buf, (data.numel ())); // memcpy? if (buf == NULL) { error ("tcp_write: cannot allocate requested memory"); return octave_value (-1); } for (int i = 0; i < data.numel (); i++) buf[i] = static_cast(data(i)); retval = tcp->write (buf, data.numel ()); } else { print_usage (); return octave_value (-1); } return octave_value (retval); #endif } #if 0 %!error tcp_write(1, uint8([104 101 108 108 111])) %!error tcp_write() %!test %! addr = resolvehost ('gnu.org', 'address'); %! a = tcp (addr, 80);; %! # call HTTP HEAD %! req = "HEAD / HTTP/1.1\r\n\r\n"; %! assert (length (req), tcp_write (a, req)); %! [d, c] = tcp_read (a, 12, 5000); %! tcp_close (a); %! assert (12, c); %! assert (c, length (d)); #endif instrument-control-0.4.0/src/udp/0000755000000000000000000000000013460206417015151 5ustar0000000000000000instrument-control-0.4.0/src/udp/Makefile.in0000644000000000000000000000151013460206417017213 0ustar0000000000000000OCT := ../udp.oct OBJ := udp.o udp_timeout.o udp_write.o udp_close.o udp_read.o __udp_properties__.o udp_class.o __udp_pkg_lock__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ LFLAGS = @TCPLIBS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ $(LFLAGS) $(TCPLIBS) -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/udp/__udp_pkg_lock__.cc0000644000000000000000000000263713460206417020725 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__udp_pkg_lock__", "udp.oct"); // PKG_ADD: __udp_pkg_lock__(1); // PKG_DEL: __udp_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__udp_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__udp_pkg_lock__")) interp.munlock("__udp_pkg_lock__"); } return retval; } #else DEFUN_DLD(__udp_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/udp/__udp_properties__.cc0000644000000000000000000001143013460206417021317 0ustar0000000000000000// Copyright (C) 2012 Andrius Sutas // Copyright (C) 2014 Stefan Mahr // Copyright (C) 2016 John Donoghue // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_UDP # include "udp_class.h" #endif // PKG_ADD: autoload ("__udp_properties__", "udp.oct"); DEFUN_DLD (__udp_properties__, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {varargout =} __udp_properties__ (@var{octave_udp}, @var{property}, @var{varargin})\n\ Undocumented internal function.\n\ @end deftypefn") { #ifdef BUILD_UDP if (args.length () < 2 || args.length () > 3 || args(0).type_id () != octave_udp::static_type_id () || !args(1).is_string ()) (*current_liboctave_error_handler) ("wrong number of arguments"); const octave_base_value& rep = args(0).get_rep (); octave_udp* udp = &((octave_udp &)rep); std::string property = args(1).string_value (); if (args.length () == 2) // get { if (property == "name") return octave_value (udp->get_name ()); else if (property == "type") return octave_value (udp->get_type ()); else if (property == "remoteport") return octave_value (udp->get_remote_port ()); else if (property == "remotehost") return octave_value (udp->get_remote_addr ()); else if (property == "localport") return octave_value (udp->get_local_port ()); else if (property == "status") return octave_value (udp->get_status ()); else if (property == "timeout") return octave_value (udp->get_timeout ()); else if (property == "bytesavailable") return octave_value (udp->get_bytesavailable ()); else (*current_liboctave_error_handler) ("invalid property name"); } else // set { if (property == "name") return octave_value (udp->set_name (args(2).string_value ())); else if (property == "type") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "remoteport") return octave_value (udp->set_remote_port (args(2).int_value ())); else if (property == "remotehost") return octave_value (udp->set_remote_addr (args(2).string_value ())); else if (property == "localport") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "status") (*current_liboctave_error_handler) ("can not set this property"); else if (property == "timeout") return octave_value (udp->set_timeout (args(2).int_value ())); else if (property == "flush") return octave_value (udp->flush (args(2).int_value ())); else (*current_liboctave_error_handler) ("invalid property name"); } #endif /* never reached in normal operation */ (*current_liboctave_error_handler) ("Your system doesn't support the UDP interface"); } #if 0 %!test %! # test get %! a = udp (); %! assert (__udp_properties__ (a,"type"), "udp"); %! assert (__udp_properties__ (a,"remoteport"), 23); %! assert (__udp_properties__ (a,"remotehost"), "127.0.0.1"); %! assert (__udp_properties__ (a,"timeout"), -1); %! assert (__udp_properties__ (a,"status"), "open"); %! assert (__udp_properties__ (a,"name"), "UDP-127.0.0.1"); %! fail ("__udp_properties__ (a,'invalid')", "invalid property name"); %! udp_close (a); %! assert (__udp_properties__ (a,"status"), "closed"); %!test %! # test set %! a = udp(); %! __udp_properties__ (a, 'name', "mytest"); %! assert (__udp_properties__ (a,"name"), "mytest"); %! fail ("__udp_properties__ (a,'invalid', 1)", "invalid property name"); %! udp_close (a); %!test %! # test flush %! a = udp(); %! __udp_properties__ (a, 'flush', 0); %! __udp_properties__ (a, 'flush', 1); %! __udp_properties__ (a, 'flush', 2); %! fail ("__udp_properties__ (a,'flush')", "invalid property name"); %! udp_close (a); %!error __udp_properties__ () %!error __udp_properties__ (1) %!test %! a = udp (); %! fail ("__udp_properties__ (a, 'name', 'test', 0)", "wrong number of arguments"); %! udp_close (a); #endif instrument-control-0.4.0/src/udp/udp.cc0000644000000000000000000000732613460206417016260 0ustar0000000000000000// Copyright (C) 2016,2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_UDP # include "udp_class.h" #endif // PKG_ADD: autoload ("udp", "udp.oct"); DEFUN_DLD (udp, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{udp} = } udp ([@var{remoteipaddress}], [@var{remoteport}], [@var{localport}], [@var{timeout}])\n \ \n\ Open udp interface.\n \ \n\ @var{remoteipaddress} - the ip address of type String. If omitted defaults to '127.0.0.1'.@* \ @var{remoteport} - the port number to connect. If omitted defaults to 23.@* \ @var{localport} - the local port number to bind. If omitted defaults to 0@* \ @var{timeout} - the interface timeout value. If omitted defaults to blocking call.\n \ \n\ The udp() shall return instance of @var{octave_udp} class as the result @var{udp}.\n \ @end deftypefn") { #ifndef BUILD_UDP error("udp: Your system doesn't support the UDP interface"); return octave_value(); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage(); return octave_value(); } // Default values std::string address("127.0.0.1"); int port = 23; int timeout = -1; int localport = 0; // Parse the function arguments if (args.length() > 0) { if (args(0).is_string()) { address = args(0).string_value(); } else { print_usage(); return octave_value(); } } // is_float_type() is or'ed to allow expression like ("", 123), without user // having to use ("", int32(123)), as we still only take "int_value" if (args.length() > 1) { if (args(1).OV_ISINTEGER() || args(1).OV_ISFLOAT()) { port = args(1).int_value(); } else { print_usage(); return octave_value(); } } if (args.length() > 2) { if (args(2).OV_ISINTEGER() || args(2).OV_ISFLOAT()) { localport = args(2).int_value(); } else { print_usage(); return octave_value(); } } if (args.length() > 3) { if (args(3).OV_ISINTEGER() || args(3).OV_ISFLOAT()) { timeout = args(3).int_value(); } else { print_usage(); return octave_value(); } } // Open the interface and connect octave_udp* retval = new octave_udp(); if (retval->open(address, port, localport) < 0) { return octave_value(); } retval->set_timeout(timeout); //retval->flush(2); return octave_value(retval); #endif } #if 0 %!test %! # can create default udp object %! a = udp (); %! assert (! isnull (a)); %! assert (isa (a, 'octave_udp')); %! udp_close (a); %!error udp (1) %!test %! a = udp ('127.0.0.1', 23, 0, 0); %! assert (! isnull (a)); %! udp_close (a); %!error udp ('127.0.0.1', 23,0,0,0) #endif instrument-control-0.4.0/src/udp/udp_class.cc0000644000000000000000000002310313460206417017434 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2016 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_UDP #include #include #include #include #ifndef __WIN32__ # include # include # include # include # include # include # include # include # define IOCTL_TYPE int #else # include # define IOCTL_TYPE u_long # define ioctl ioctlsocket #endif #include "udp_class.h" #ifndef __WIN32__ # define SOCKETERR errno # define STRSOCKETERR strerror(errno) #else # define SOCKETERR WSAGetLastError() # define STRSOCKETERR "" # define socklen_t int #endif static std::string to_ip_str (const sockaddr_in *in) { u_long addr = ntohl (in->sin_addr.s_addr); int b[4]; b[0] = (addr>>24)&0xff; b[1] = (addr>>16)&0xff; b[2] = (addr>>8)&0xff; b[3] = (addr>>0)&0xff; std::stringstream n; n << b[0] << "." << b[1] << "." << b[2] << "." << b[3]; return n.str (); } static bool lookup_addr (const std::string &ip, sockaddr_in *in) { in->sin_addr.s_addr = inet_addr (ip.c_str()); if (in->sin_addr.s_addr == INADDR_NONE) { struct hostent * host = gethostbyname (ip.c_str()); if (!host) return false; memcpy(&in->sin_addr, host->h_addr_list[0], host->h_length); } return true; } DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_udp, "octave_udp", "octave_udp"); octave_udp::octave_udp (void) : fd(-1), timeout(-1), name("") { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); } } int octave_udp::open (const std::string &address, int port, int localport) { int sockerr; name = "UDP-" + address; #ifdef __WIN32__ WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD( 2, 2 ); err = WSAStartup (wVersionRequested, &wsaData ); if ( err != 0 ) { error( "could not initialize winsock library" ); return -1; } #endif memset (&remote_addr, 0, sizeof (remote_addr)); if( !lookup_addr (address, &remote_addr)) { error ("udp: error looking up remote host : %d - %s\n", SOCKETERR, STRSOCKETERR); octave_udp::close (); return -1; } remote_addr.sin_family = AF_INET; remote_addr.sin_port = htons(port); fd = socket (AF_INET, SOCK_DGRAM, 0); if (fd < 0) { error ("udp: error opening socket : %d - %s\n", SOCKETERR, STRSOCKETERR); octave_udp::close (); return -1; } memset (&local_addr, 0, sizeof (local_addr)); local_addr.sin_addr.s_addr = htonl (INADDR_ANY); local_addr.sin_family = AF_INET; local_addr.sin_port = htons (localport); sockerr = bind (fd, (struct sockaddr*)&local_addr, sizeof (local_addr)); if (sockerr < 0) { error ("udp: error on bind : %d - %s\n", SOCKETERR, STRSOCKETERR); octave_udp::close (); return -1; } else if (localport == 0) { // if said port, 0, lookup actual port it used socklen_t sz = sizeof (local_addr); getsockname (fd, (struct sockaddr*)&local_addr, &sz); } return get_fd(); } octave_udp::~octave_udp (void) { close(); } void octave_udp::print (std::ostream& os, bool pr_as_read_syntax) { print_raw (os, pr_as_read_syntax); newline (os); } void octave_udp::print (std::ostream& os, bool pr_as_read_syntax) const { print_raw (os, pr_as_read_syntax); newline (os); } void octave_udp::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << " UDP Object " << get_name (); newline(os); os << " type: " << get_type (); newline(os); os << " status: " << get_status (); newline(os); os << " remoteport: " << get_remote_port (); newline(os); os << " remotehost: " << get_remote_addr (); newline(os); os << " localport: " << get_local_port (); newline (os); } int octave_udp::get_bytesavailable () const { IOCTL_TYPE available = 0; if (get_fd () < 0) { return 0; } ioctl (get_fd (), FIONREAD, &available); return available; } int octave_udp::read (uint8_t *buf, unsigned int len, int readtimeout) { struct sockaddr_in addr; socklen_t addrlen = sizeof (addr); struct timeval tv; fd_set readfds; if (get_fd () < 0) { error ("udp_read: Interface must be opened first..."); return 0; } size_t bytes_read = 0; ssize_t read_retval = -1; // While not interrupted in blocking mode while (bytes_read < len) { OCTAVE_QUIT; if (readtimeout < 0) { tv.tv_sec = 1; tv.tv_usec = 0; } else { tv.tv_sec = 0; if (readtimeout > 1000) tv.tv_usec = 1000 * 1000; else tv.tv_usec = readtimeout * 1000; } FD_ZERO (&readfds); FD_SET (get_fd (), &readfds); if (::select(get_fd ()+1, &readfds, NULL, NULL, &tv) < 0) { error("udp_read: Error while reading/select: %d - %s\n", SOCKETERR, STRSOCKETERR); break; } if (FD_ISSET (get_fd (), &readfds)) { addrlen = sizeof (addr); read_retval = ::recvfrom (get_fd (), reinterpret_cast((buf + bytes_read)), len - bytes_read, 0, (struct sockaddr*)&addr, &addrlen); if (read_retval < 0) { error ("udp_read: Error while reading: %d - %s\n", SOCKETERR, STRSOCKETERR); break; } else if (read_retval == 0) { error ("udp_read: Connection lost: %d - %s\n", SOCKETERR, STRSOCKETERR); break; } else { bytes_read += read_retval; } } else { // Timeout if (readtimeout >= 0) { // real timeout if (readtimeout <= 1000) break; // timed out 1 sec of an actual timeout else readtimeout -= 1000; } } } return bytes_read; } int octave_udp::write (const std::string &str) { return ::sendto (get_fd (), str.c_str(), str.length(), 0, (struct sockaddr *)&remote_addr, sizeof(remote_addr)); } int octave_udp::write (uint8_t *buf, unsigned int len) { if (get_fd () < 0) { error("udp: Interface must be opened first..."); return -1; } return ::sendto (get_fd(), reinterpret_cast(buf), len, 0, (struct sockaddr *)&remote_addr, sizeof (remote_addr)); } int octave_udp::set_timeout (int newtimeout) { if (get_fd () < 0) { error ("udp: Interface must be opened first..."); return -1; } if (newtimeout < -1 ) { error ("udp_timeout: timeout value must be -1 or positive"); return -1; } timeout = newtimeout; return 1; } int octave_udp::get_remote_port (void) const { return ntohs (remote_addr.sin_port); } int octave_udp::set_remote_port (int port) { if (port < 0 ) { error ("udp_remote_port: value must be positive"); return -1; } remote_addr.sin_port = htons(port); return get_remote_port(); } std::string octave_udp::get_remote_addr (void) const { return to_ip_str (&remote_addr); } std::string octave_udp::set_remote_addr (const std::string &addr) { if (addr.length() == 0 ) { error ("udp_remote_addr: value must be non empty"); } else if ( !lookup_addr(addr, &remote_addr)) { error ("udp: error looking up remote host : %d - %s\n", SOCKETERR, STRSOCKETERR); } return to_ip_str (&remote_addr); } int octave_udp::get_local_port (void) const { return ntohs (local_addr.sin_port); } std::string octave_udp::set_name (const std::string &n) { if (n.length() == 0 ) { error ("udp_name: value must be non empty"); } else { name = n; } return name; } bool octave_udp::is_open (void) const { return fd >= 0; } std::string octave_udp::get_status (void) const { if (! is_open ()) { return "closed"; } else { return "open"; } } int octave_udp::close (void) { int retval = -1; if (get_fd() > 0) { #ifndef __WIN32__ retval = ::close (get_fd ()); #else retval = ::closesocket (get_fd ()); #endif fd = -1; } return retval; } int octave_udp::flush (int mode) { int retval = -1; if (get_fd() > 0) { uint8_t tmpbuffer[1024]; if (mode == 0 || mode == 2) { // we are sending data as we get it, so no outout // buffers to flush } if (mode == 1 || mode == 2) { while (read (tmpbuffer, 1024, 0) > 0) {} } } return retval; } #endif instrument-control-0.4.0/src/udp/udp_class.h0000644000000000000000000000517213460206417017304 0ustar0000000000000000// Copyright (C) 2016 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef UDP_CLASS_H #define UDP_CLASS_H #include #include #include #ifndef __WIN32__ # include #else # include #endif class octave_udp : public octave_base_value { public: octave_udp (void); ~octave_udp (void); int write (const std::string &str); int write (uint8_t *buf, unsigned int len); int read (uint8_t *buf, unsigned int len, int readtimeout); int open (const std::string &address, int port, int localport); int close (void); int get_fd (void) const { return fd; } int get_bytesavailable (void) const; // Overloaded base functions double udp_value (void) const { return (double)fd; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)fd; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true; } bool is_defined (void) const { return true; } bool is_object (void) const { return true; } std::string get_name (void) const { return name; } std::string set_name (const std::string &); std::string get_remote_addr (void) const; std::string set_remote_addr (const std::string &); int get_remote_port (void) const; int set_remote_port (int); int get_local_port (void) const; bool is_open(void) const; std::string get_type (void) const { return "udp"; } std::string get_status (void) const; int set_timeout (int); int get_timeout (void) const { return timeout; } int flush(int mode); private: int fd; int timeout; std::string name; sockaddr_in remote_addr; sockaddr_in local_addr; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/udp/udp_close.cc0000644000000000000000000000346013460206417017440 0ustar0000000000000000// Copyright (C) 2016 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_UDP #include "udp_class.h" #endif // PKG_ADD: autoload ("udp_close", "udp.oct"); DEFUN_DLD (udp_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} udp_close (@var{udp})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{udp} - instance of @var{octave_udp} class.\n \ @end deftypefn") { #ifndef BUILD_UDP error ("udp: Your system doesn't support the UDP interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_udp::static_type_id ()) { print_usage(); return octave_value (-1); } octave_udp* udp = NULL; const octave_base_value& rep = args(0).get_rep(); udp = &((octave_udp &)rep); udp->close (); return octave_value (); #endif } #if 0 %!test %! a = udp(); %! udp_close(a); %!error udp_close(1) %!error udp_close() #endif instrument-control-0.4.0/src/udp/udp_read.cc0000644000000000000000000000702313460206417017245 0ustar0000000000000000// Copyright (C) 2016-2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_UDP #include #include #include "udp_class.h" #endif // PKG_ADD: autoload ("udp_read", "udp.oct"); DEFUN_DLD (udp_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}] = } udp_read (@var{udp}, @var{n}, @var{timeout})\n \ \n\ Read from udp interface.\n \ \n\ @var{udp} - instance of @var{octave_udp} class.@* \ @var{n} - number of bytes to attempt to read of type Integer@* \ @var{timeout} - timeout in ms if different from default of type Integer\n \ \n\ The udp_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @end deftypefn") { #ifndef BUILD_UDP error("udp: Your system doesn't support the UDP interface"); return octave_value(); #else if (args.length() < 2 || args.length() > 3 || args(0).type_id() != octave_udp::static_type_id()) { print_usage(); return octave_value(-1); } unsigned int buffer_len = 0; if ( !(args(1).OV_ISINTEGER() || args(1).OV_ISFLOAT())) { print_usage(); return octave_value(-1); } if ( args.length() > 2 ) { if ( !(args(2).OV_ISINTEGER() || args(2).OV_ISFLOAT())) { print_usage(); return octave_value(-1); } } buffer_len = args(1).int_value(); OCTAVE_LOCAL_BUFFER (uint8_t, buffer, (buffer_len + 1)); if (buffer == NULL) { error("udp_read: cannot allocate requested memory: %s\n", strerror(errno)); return octave_value(-1); } octave_udp* udp = NULL; const octave_base_value& rep = args(0).get_rep(); udp = &((octave_udp &)rep); int timeout = udp->get_timeout(); if (args.length() == 3) { timeout = args(2).int_value(); } // Read data int bytes_read = udp->read(buffer, buffer_len, timeout); // Convert data to octave type variables octave_value_list return_list; uint8NDArray data( dim_vector(1, bytes_read) ); for (int i = 0; i < bytes_read; i++) data(i) = buffer[i]; return_list(0) = data; return_list(1) = bytes_read; return return_list; #endif } #if 0 %!test %! a = udp (); %! assert (! isnull (a)); %! [d,c] = udp_read (a, 1, 0); %! assert (c == 0); %! assert (isempty (d)); %! udp_close (a); %!error udp_read(1, 10, 0) %!test %! a = udp (); %! fail ("udp_read (a, 10, 0, 0)", "Invalid call to udp_read"); %! udp_close (a); %!test %! # does read wait %! a = udp (); %! assert (! isnull (a)); %! tic; %! [d,c] = udp_read (a, 1, 1000); %! t = toc; %! assert (c, 0); %! assert (isempty (d)); %! assert (t, 1.0, 0.1) %! udp_close (a); #endif instrument-control-0.4.0/src/udp/udp_timeout.cc0000644000000000000000000000520513460206417020020 0ustar0000000000000000// Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_UDP # include "udp_class.h" #endif // PKG_ADD: autoload ("udp_timeout", "udp.oct"); DEFUN_DLD (udp_timeout, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} udp_timeout (@var{udp}, @var{timeout})\n \ @deftypefnx {Loadable Function} {@var{t} = } udp_timeout (@var{udp})\n \ \n\ Set new or get existing udp interface timeout parameter used for udp_read() requests. The timeout value is specified in milliseconds.\n \ \n\ @var{udp} - instance of @var{octave_udp} class.@* \ @var{timeout} - udp_read() timeout value in milliseconds. Value of -1 means a blocking call.\n \ \n\ If @var{timeout} parameter is omitted, the udp_timeout() shall return current timeout value as the result @var{t}.\n \ @end deftypefn") { #ifndef BUILD_UDP error("udp: Your system doesn't support the UDP interface"); return octave_value(); #else if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_udp::static_type_id()) { print_usage(); return octave_value(-1); } octave_udp* udp = NULL; const octave_base_value& rep = args(0).get_rep(); udp = &((octave_udp &)rep); // Setting new timeout if (args.length() > 1) { if ( !(args(1).OV_ISINTEGER() || args(1).OV_ISFLOAT()) ) { print_usage(); return octave_value(-1); } udp->set_timeout(args(1).int_value()); return octave_value(); // Should it return by default? } // Returning current timeout return octave_value(udp->get_timeout()); #endif } #if 0 %!test %! a = udp(); %! assert(udp_timeout(a), -1); %! udp_timeout(a, 103); %! assert(udp_timeout(a), 103); %! close(a); %!error udp_timeout() %!error udp_timeout(1) #endif instrument-control-0.4.0/src/udp/udp_write.cc0000644000000000000000000000630013460206417017461 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif #ifdef BUILD_UDP # include "udp_class.h" #endif // PKG_ADD: autoload ("udp_write", "udp.oct"); DEFUN_DLD (udp_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } udp_write (@var{udp}, @var{data})\n \ \n\ Write data to a udp interface.\n \ \n\ @var{udp} - instance of @var{octave_udp} class.@* \ @var{data} - data to be written to the udp interface. Can be either of String or uint8 type.\n \ \n\ Upon successful completion, udp_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_UDP error("udp: Your system doesn't support the UDP interface"); return octave_value(); #else if (args.length() != 2 || args(0).type_id() != octave_udp::static_type_id()) { print_usage(); return octave_value(-1); } octave_udp *udp = NULL; int retval; const octave_base_value& rep = args(0).get_rep(); udp = &((octave_udp &)rep); if (args(1).is_string()) // String { retval = udp->write(args(1).string_value()); } else if (args(1).is_uint8_type ()) { NDArray data = args(1).array_value(); OCTAVE_LOCAL_BUFFER (uint8_t, buf, (data.numel ())); // memcpy? if (buf == NULL) { error("udp_write: cannot allocate requested memory"); return octave_value(-1); } for (int i = 0; i < data.numel(); i++) buf[i] = static_cast(data(i)); retval = udp->write(buf, data.numel()); } else { print_usage(); return octave_value(-1); } return octave_value(retval); #endif } #if 0 %!test %! a = udp (); %! b = udp (); %! p = get (a, 'localport'); %! set (b, 'remoteport', p); %! p = get (b, 'localport'); %! set (a, 'remoteport', p); %! assert (5, udp_write (a, uint8 ([104 101 108 108 111]))); %! [d, c] = udp_read (b, 5, 1000); %! assert (c, 5); %! assert (d, uint8 ([104 101 108 108 111])); %! udp_close (a); %! udp_close (b); %!error udp_write (1, uint8([104 101 108 108 111])) %!error udp_write () %!test %! a = udp (); %! fail ("udp_write (a, uint8([104 101 108 108 111]), 0)", "Invalid call to udp_write") %! udp_close (a); %!test %! a = udp (); %! fail ("udp_write (a)", "Invalid call to udp_write") %! udp_close (a); #endif instrument-control-0.4.0/src/undef-ah-octave.h0000644000000000000000000000070613460206417017503 0ustar0000000000000000/* To be included at the top of config.h (by autoheader). Avoid warnings for redefining AH-generated preprocessor symbols of Octave. */ #ifdef PACKAGE_BUGREPORT #undef PACKAGE_BUGREPORT #endif #ifdef PACKAGE_NAME #undef PACKAGE_NAME #endif #ifdef PACKAGE_STRING #undef PACKAGE_STRING #endif #ifdef PACKAGE_TARNAME #undef PACKAGE_TARNAME #endif #ifdef PACKAGE_URL #undef PACKAGE_URL #endif #ifdef PACKAGE_VERSION #undef PACKAGE_VERSION #endif instrument-control-0.4.0/src/usbtmc/0000755000000000000000000000000013460206417015656 5ustar0000000000000000instrument-control-0.4.0/src/usbtmc/Makefile.in0000644000000000000000000000141713460206417017726 0ustar0000000000000000OCT := ../usbtmc.oct OBJ := usbtmc.o usbtmc_close.o usbtmc_write.o usbtmc_read.o usbtmc_class.o __usbtmc_pkg_lock__.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ CFLAGS = @DEFS@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) all: $(OCT) $(TST_SOURCES) %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(MKOCTFILE) $^ -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile .PHONY: all clean instrument-control-0.4.0/src/usbtmc/__usbtmc_pkg_lock__.cc0000644000000000000000000000266713460206417022142 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__usbtmc_pkg_lock__", "usbtmc.oct"); // PKG_ADD: __usbtmc_pkg_lock__(1); // PKG_DEL: __usbtmc_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__usbtmc_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__usbtmc_pkg_lock__")) interp.munlock("__usbtmc_pkg_lock__"); } return retval; } #else DEFUN_DLD(__usbtmc_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/usbtmc/usbtmc.cc0000644000000000000000000000451413460206417017466 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_USBTMC #include #include "usbtmc_class.h" #endif // PKG_ADD: autoload ("usbtmc", "usbtmc.oct"); DEFUN_DLD (usbtmc, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{usbtmc} = } usbtmc (@var{path})\n \ \n\ Open usbtmc interface.\n \ \n\ @var{path} - the interface path of type String. If omitted defaults to '/dev/usbtmc0'.\n \ \n\ The usbtmc() shall return instance of @var{octave_usbtmc} class as the result @var{usbtmc}.\n \ @end deftypefn") { #ifndef BUILD_USBTMC error ("usbtmc: Your system doesn't support the USBTMC interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values int oflags = O_RDWR; std::string path ("/dev/usbtmc0"); // Parse the function arguments if (args.length () > 0) { if (args (0).is_string ()) { path = args (0).string_value (); } else { print_usage (); return octave_value (); } } octave_usbtmc* retval = new octave_usbtmc (); // Open the interface if (retval->open (path, oflags) < 0) return octave_value (); return octave_value (retval); #endif } #if 0 %!test %! if any(strcmp(instrhwinfo().SupportedInterfaces, "usbtmc")) %! fail ("usbtmc ()", "Invalid call to usbtmc"); %! else %! fail ("usbtmc ()", "usbtmc: Your system doesn't support the USBTMC interface"); %! endif #endif instrument-control-0.4.0/src/usbtmc/usbtmc_class.cc0000644000000000000000000000536313460206417020656 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_USBTMC #include #include #include #include #include "usbtmc_class.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_usbtmc, "octave_usbtmc", "octave_usbtmc"); octave_usbtmc::octave_usbtmc (void) : fd (-1) { static bool type_registered = false; if (! type_registered) { type_registered = true; register_type (); } } octave_usbtmc::~octave_usbtmc (void) { octave_usbtmc::close(); } int octave_usbtmc::get_fd() const { return fd; } void octave_usbtmc::print (std::ostream& os, bool pr_as_read_syntax) { print_raw(os, pr_as_read_syntax); newline(os); } void octave_usbtmc::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw(os, pr_as_read_syntax); newline(os); } void octave_usbtmc::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << fd; } int octave_usbtmc::open (const std::string &path, int flags) { fd = ::open (path.c_str (), flags, 0); if (get_fd () < 0) { error ("usbtmc: Error opening the interface: %s\n", strerror (errno)); return -1; } return get_fd (); } int octave_usbtmc::read (uint8_t *buf, unsigned int len) { if (get_fd () < 0) { error ("usbtmc: Interface must be open first..."); return -1; } int retval = ::read (get_fd (), buf, len); if (retval < 0) error ("usbtmc: Failed to read from the usbtmc bus: %s\n", strerror (errno)); return retval; } int octave_usbtmc::write (uint8_t *buf, unsigned int len) { if (get_fd () < 0) { error ("usbtmc: Interface must be open first..."); return -1; } int retval = ::write (get_fd (), buf, len); if (retval < 0) error("usbtmc: Failed to write to the usbtmc bus: %s\n", strerror(errno)); return retval; } int octave_usbtmc::close (void) { int retval = -1; if (get_fd () > 0) { retval = ::close(get_fd ()); fd = -1; } return retval; } #endif instrument-control-0.4.0/src/usbtmc/usbtmc_class.h0000644000000000000000000000337213460206417020516 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef USBTMC_CLASS_H #define USBTMC_CLASS_H #include #include class octave_usbtmc : public octave_base_value { public: octave_usbtmc (void); ~octave_usbtmc(void); int open(const std::string&, int); int close(void); int get_fd(void) const; // Simple usbtmc commands int write(uint8_t*, unsigned int); int read(uint8_t*, unsigned int); // Overloaded base functions double usbtmc_value(void) const { return (double)fd; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)fd; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool print_as_scalar (void) const { return true;} private: int fd; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/usbtmc/usbtmc_close.cc0000644000000000000000000000321613460206417020651 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_USBTMC #include "usbtmc_class.h" #endif // PKG_ADD: autoload ("usbtmc_close", "usbtmc.oct"); DEFUN_DLD (usbtmc_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} usbtmc_close (@var{usbtmc})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{usbtmc} - instance of @var{octave_usbtmc} class.\n \ @end deftypefn") { #ifndef BUILD_USBTMC error ("usbtmc: Your system doesn't support the USBTMC interface"); return octave_value (); #else if (args.length () != 1 || args (0).type_id () != octave_usbtmc::static_type_id ()) { print_usage (); return octave_value (-1); } octave_usbtmc* usbtmc = NULL; const octave_base_value& rep = args (0).get_rep (); usbtmc = &((octave_usbtmc &)rep); usbtmc->close (); return octave_value (); #endif } instrument-control-0.4.0/src/usbtmc/usbtmc_read.cc0000644000000000000000000000542213460206417020460 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2017 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_USBTMC #include #include #include "usbtmc_class.h" #endif // PKG_ADD: autoload ("usbtmc_read", "usbtmc.oct"); DEFUN_DLD (usbtmc_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}] = } usbtmc_read (@var{usbtmc}, @var{n})\n \ \n\ Read from usbtmc slave device.\n \ \n\ @var{usbtmc} - instance of @var{octave_usbtmc} class.@* \ @var{n} - number of bytes to attempt to read of type Integer.\n \ \n\ The usbtmc_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @end deftypefn") { #ifndef BUILD_USBTMC error ("usbtmc: Your system doesn't support the USBTMC interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_usbtmc::static_type_id ()) { print_usage (); return octave_value (-1); } unsigned int buffer_len = 1; if (args.length () > 1) { if (! (args (1).OV_ISINTEGER () || args (1).OV_ISFLOAT ()) ) { print_usage (); return octave_value (-1); } buffer_len = args(1).int_value(); } OCTAVE_LOCAL_BUFFER (uint8_t, buffer, (buffer_len + 1)); if (buffer == NULL) { error ("usbtmc_read: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value (-1); } octave_usbtmc* usbtmc = NULL; const octave_base_value& rep = args (0).get_rep (); usbtmc = &((octave_usbtmc &)rep); int retval; retval = usbtmc->read (buffer, buffer_len); octave_value_list return_list; uint8NDArray data (dim_vector (1, retval)); for (int i = 0; i < retval; i++) data (i) = buffer[i]; return_list (0) = data; return_list (1) = retval; return return_list; #endif } instrument-control-0.4.0/src/usbtmc/usbtmc_write.cc0000644000000000000000000000523313460206417020677 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_USBTMC #include #include "usbtmc_class.h" #endif // PKG_ADD: autoload ("usbtmc_write", "usbtmc.oct"); DEFUN_DLD (usbtmc_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } usbtmc_write (@var{usbtmc}, @var{data})\n \ \n\ Write data to a usbtmc slave device.\n \ \n\ @var{usbtmc} - instance of @var{octave_usbtmc} class.@* \ @var{data} - data, of type uint8, to be written to the slave device.\n \ \n\ Upon successful completion, usbtmc_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_USBTMC error ("usbtmc: Your system doesn't support the USBTMC interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_usbtmc::static_type_id ()) { print_usage (); return octave_value (-1); } octave_usbtmc* usbtmc = NULL; int retval; const octave_base_value& rep = args (0).get_rep (); usbtmc = &((octave_usbtmc &)rep); const octave_base_value& data = args (1).get_rep (); if (data.is_string()) { std::string buf = data.string_value (); retval = usbtmc->write ((uint8_t*)buf.c_str (), buf.length ()); } else if (data.is_uint8_type ()) { NDArray dtmp = data.array_value (); OCTAVE_LOCAL_BUFFER (uint8_t, buf, (data.numel ())); if (buf == NULL) { error ("usbtmc_write: cannot allocate requested memory: %s\n", strerror (errno)); return octave_value (-1); } for (int i = 0; i < dtmp.numel (); i++) buf[i] = static_cast(dtmp (i)); retval = usbtmc->write (buf, dtmp.numel ()); } else { print_usage (); return octave_value (-1); } return octave_value (retval); #endif } instrument-control-0.4.0/src/vxi11/0000755000000000000000000000000013460206417015331 5ustar0000000000000000instrument-control-0.4.0/src/vxi11/Makefile.in0000644000000000000000000000246113460206417017401 0ustar0000000000000000VXI := vxi11_clnt.o vxi11_xdr.o OBJ := vxi11.o vxi11_write.o vxi11_close.o vxi11_read.o __vxi11_pkg_lock__.o OCT := ../vxi11.oct VXCLASS := vxi11_class.o MKOCTFILE ?= mkoctfile GREP ?= @GREP@ RPCGEN ?= @RPCGEN@ RPCGENOPTS ?= @RPCGENOPTS@ CFLAGS = @DEFS@ LFLAGS = BUILD_VXI11 = @BUILD_VXI11@ CC_SOURCES := $(wildcard *.cc) CC_TST_SOURCES := $(shell $(GREP) --files-with-matches '^%!' $(CC_SOURCES)) TST_SOURCES := $(patsubst %.cc,../../inst/test/%.cc-tst,$(CC_TST_SOURCES)) RPC_GENERATED_FILES := vxi11.h vxi11_clnt.c vxi11_xdr.c ifneq ($(BUILD_VXI11),1) VXI = VXCLASS = else CFLAGS += @RPCINCLUDE@ LFLAGS += @RPCLIBS@ endif all: $(OCT) $(TST_SOURCES) $(RPC_GENERATED_FILES): vxi11.x $(RPCGEN) $(RPCGENOPTS) vxi11.x %.o: %.c $(MKOCTFILE) $(CFLAGS) -c $^ %.o: %.cc $(MKOCTFILE) $(CFLAGS) -c $^ %.oct: $(OBJ) $(VXI) $(VXCLASS) $(MKOCTFILE) $^ $(LFLAGS) -o $@ ../../inst/test: @mkdir -p "$@" $(TST_SOURCES): ../../inst/test/%.cc-tst: %.cc | ../../inst/test @echo "Extracting tests from $< ..." @$(RM) -f "$@" "$@-t" @( echo "## Generated from $<"; \ $(GREP) '^%!' "$<") > "$@" clean: rm -f $(OCT) *.o distclean: clean rm Makefile extraclean: distclean rm -f $(RPC_GENERATED_FILES) prebuild: $(RPC_GENERATED_FILES) .PHONY: all clean prebuild extraclean instrument-control-0.4.0/src/vxi11/__vxi11_pkg_lock__.cc0000644000000000000000000000265713460206417021267 0ustar0000000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . #include #include #include #ifdef HAVE_CONFIG_H # include "../config.h" #endif // PKG_ADD: autoload ("__vxi11_pkg_lock__", "vxi11.oct"); // PKG_ADD: __vxi11_pkg_lock__(1); // PKG_DEL: __vxi11_pkg_lock__(0); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__vxi11_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__vxi11_pkg_lock__")) interp.munlock("__vxi11_pkg_lock__"); } return retval; } #else DEFUN_DLD(__vxi11_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif instrument-control-0.4.0/src/vxi11/vxi11.cc0000644000000000000000000000455313460206417016617 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_VXI11 #include using std::string; #include "vxi11_class.h" #endif // PKG_ADD: autoload ("vxi11", "vxi11.oct"); DEFUN_DLD (vxi11, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{vxi11} = } vxi11 (@var{ip})\n \ \n\ Open vxi11 interface.\n \ \n\ @var{path} - the ip address of type String. If omitted defaults to '127.0.0.1'.\n \ \n\ The vxi11() shall return instance of @var{octave_vxi11} class as the result @var{vxi11}.\n \ @end deftypefn") { #ifndef BUILD_VXI11 error ("vxi11: Your system doesn't support the VXI11 interface"); return octave_value (); #else // Do not open interface if return value is not assigned if (nargout != 1) { print_usage (); return octave_value (); } // Default values string path ("127.0.0.1"); // Parse the function arguments if (args.length () > 0) { if (args(0).is_string ()) { path = args (0).string_value (); } else { print_usage (); return octave_value (); } } // Open the interface octave_vxi11* retval = new octave_vxi11; if (retval->open (path) < 0) { error("vxi11: Error opening the interface: %s\n", strerror (errno)); return octave_value (); } return octave_value (retval); #endif } #if 0 %!test %! if any(strcmp(instrhwinfo().SupportedInterfaces, "vxi11")) %! fail ("vxi11 ()", "Invalid call to vxi11"); %! else %! fail ("vxi11 ()", "vxi11: Your system doesn't support the VXI11 interface"); %! endif #endif instrument-control-0.4.0/src/vxi11/vxi11.h0000644000000000000000000002711113460206417016454 0ustar0000000000000000/* * Please do not edit this file. * It was generated using rpcgen. */ #ifndef _VXI11_H_RPCGEN #define _VXI11_H_RPCGEN #include #include #ifdef __cplusplus extern "C" { #endif /* VXI-11 RPCL definitions. Taken from appendix C of the VXI-11 specfication. * See http://www.vxi.org */ #include #include /* VXI-11 flags */ #define VXI11_FLAG_WAITLOCK 0x01 #define VXI11_FLAG_ENDW 0x08 #define VXI11_FLAG_TERMCHRSET 0x80 /* VXI-11 device_docmd 'cmd' values */ #define VXI11_DOCMD_SEND_COMMAND 0x020000 #define VXI11_DOCMD_BUS_STATUS 0x020001 #define VXI11_DOCMD_ATN_CONTROL 0x020002 #define VXI11_DOCMD_REN_CONTROL 0x020003 #define VXI11_DOCMD_PASS_CONTROL 0x020004 #define VXI11_DOCMD_BUS_ADDRESS 0x02000A #define VXI11_DOCMD_IFC_CONTROL 0x020010 /* VXI-11 device_docmd Bus Status values */ #define VXI11_DOCMD_STAT_REMOTE 1 #define VXI11_DOCMD_STAT_SRQ 2 #define VXI11_DOCMD_STAT_NDAC 3 #define VXI11_DOCMD_STAT_SYS_CTRLR 4 #define VXI11_DOCMD_STAT_CTRLR_CHRG 5 #define VXI11_DOCMD_STAT_TALKER 6 #define VXI11_DOCMD_STAT_LISTENER 7 #define VXI11_DOCMD_STAT_BUSADDR 8 /* VXI-11 device_read 'reason' bits */ #define VXI11_REASON_REQCNT 1 /* requested number of bytes read */ #define VXI11_REASON_CHR 2 /* read terminated by eos character */ #define VXI11_REASON_END 4 /* read terminated by EOI */ /* VXI-11 errors */ #define VXI11_ERR_SUCCESS 0 #define VXI11_ERR_SYNTAX 1 #define VXI11_ERR_NODEVICE 3 #define VXI11_ERR_LINKINVAL 4 #define VXI11_ERR_PARAMETER 5 #define VXI11_ERR_NOCHAN 6 #define VXI11_ERR_NOTSUPP 8 #define VXI11_ERR_RESOURCES 9 #define VXI11_ERR_LOCKED 11 #define VXI11_ERR_NOLOCK 12 #define VXI11_ERR_IOTIMEOUT 15 #define VXI11_ERR_IOERROR 17 #define VXI11_ERR_ADDRINVAL 21 #define VXI11_ERR_ABORT 23 #define VXI11_ERR_CHANEST 29 typedef long Device_Link; enum Device_AddrFamily { DEVICE_TCP = 0, DEVICE_UDP = 1, }; typedef enum Device_AddrFamily Device_AddrFamily; typedef long Device_Flags; typedef long Device_ErrorCode; struct Device_Error { Device_ErrorCode error; }; typedef struct Device_Error Device_Error; struct Create_LinkParms { long clientId; bool_t lockDevice; u_long lock_timeout; char *device; }; typedef struct Create_LinkParms Create_LinkParms; struct Create_LinkResp { Device_ErrorCode error; Device_Link lid; u_short abortPort; u_long maxRecvSize; }; typedef struct Create_LinkResp Create_LinkResp; struct Device_WriteParms { Device_Link lid; u_long io_timeout; u_long lock_timeout; Device_Flags flags; struct { u_int data_len; char *data_val; } data; }; typedef struct Device_WriteParms Device_WriteParms; struct Device_WriteResp { Device_ErrorCode error; u_long size; }; typedef struct Device_WriteResp Device_WriteResp; struct Device_ReadParms { Device_Link lid; u_long requestSize; u_long io_timeout; u_long lock_timeout; Device_Flags flags; char termChar; }; typedef struct Device_ReadParms Device_ReadParms; struct Device_ReadResp { Device_ErrorCode error; long reason; struct { u_int data_len; char *data_val; } data; }; typedef struct Device_ReadResp Device_ReadResp; struct Device_ReadStbResp { Device_ErrorCode error; u_char stb; }; typedef struct Device_ReadStbResp Device_ReadStbResp; struct Device_GenericParms { Device_Link lid; Device_Flags flags; u_long lock_timeout; u_long io_timeout; }; typedef struct Device_GenericParms Device_GenericParms; struct Device_RemoteFunc { u_long hostAddr; u_short hostPort; u_long progNum; u_long progVers; Device_AddrFamily progFamily; }; typedef struct Device_RemoteFunc Device_RemoteFunc; struct Device_EnableSrqParms { Device_Link lid; bool_t enable; struct { u_int handle_len; char *handle_val; } handle; }; typedef struct Device_EnableSrqParms Device_EnableSrqParms; struct Device_LockParms { Device_Link lid; Device_Flags flags; u_long lock_timeout; }; typedef struct Device_LockParms Device_LockParms; struct Device_DocmdParms { Device_Link lid; Device_Flags flags; u_long io_timeout; u_long lock_timeout; long cmd; bool_t network_order; long datasize; struct { u_int data_in_len; char *data_in_val; } data_in; }; typedef struct Device_DocmdParms Device_DocmdParms; struct Device_DocmdResp { Device_ErrorCode error; struct { u_int data_out_len; char *data_out_val; } data_out; }; typedef struct Device_DocmdResp Device_DocmdResp; #define DEVICE_ASYNC 0x0607B0 #define DEVICE_ASYNC_VERSION 1 #if defined(__STDC__) || defined(__cplusplus) #define device_abort 1 extern enum clnt_stat device_abort_1(Device_Link *, Device_Error *, CLIENT *); extern bool_t device_abort_1_svc(Device_Link *, Device_Error *, struct svc_req *); extern int device_async_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); #else /* K&R C */ #define device_abort 1 extern enum clnt_stat device_abort_1(); extern bool_t device_abort_1_svc(); extern int device_async_1_freeresult (); #endif /* K&R C */ #define DEVICE_CORE 0x0607AF #define DEVICE_CORE_VERSION 1 #if defined(__STDC__) || defined(__cplusplus) #define create_link 10 extern enum clnt_stat create_link_1(Create_LinkParms *, Create_LinkResp *, CLIENT *); extern bool_t create_link_1_svc(Create_LinkParms *, Create_LinkResp *, struct svc_req *); #define device_write 11 extern enum clnt_stat device_write_1(Device_WriteParms *, Device_WriteResp *, CLIENT *); extern bool_t device_write_1_svc(Device_WriteParms *, Device_WriteResp *, struct svc_req *); #define device_read 12 extern enum clnt_stat device_read_1(Device_ReadParms *, Device_ReadResp *, CLIENT *); extern bool_t device_read_1_svc(Device_ReadParms *, Device_ReadResp *, struct svc_req *); #define device_readstb 13 extern enum clnt_stat device_readstb_1(Device_GenericParms *, Device_ReadStbResp *, CLIENT *); extern bool_t device_readstb_1_svc(Device_GenericParms *, Device_ReadStbResp *, struct svc_req *); #define device_trigger 14 extern enum clnt_stat device_trigger_1(Device_GenericParms *, Device_Error *, CLIENT *); extern bool_t device_trigger_1_svc(Device_GenericParms *, Device_Error *, struct svc_req *); #define device_clear 15 extern enum clnt_stat device_clear_1(Device_GenericParms *, Device_Error *, CLIENT *); extern bool_t device_clear_1_svc(Device_GenericParms *, Device_Error *, struct svc_req *); #define device_remote 16 extern enum clnt_stat device_remote_1(Device_GenericParms *, Device_Error *, CLIENT *); extern bool_t device_remote_1_svc(Device_GenericParms *, Device_Error *, struct svc_req *); #define device_local 17 extern enum clnt_stat device_local_1(Device_GenericParms *, Device_Error *, CLIENT *); extern bool_t device_local_1_svc(Device_GenericParms *, Device_Error *, struct svc_req *); #define device_lock 18 extern enum clnt_stat device_lock_1(Device_LockParms *, Device_Error *, CLIENT *); extern bool_t device_lock_1_svc(Device_LockParms *, Device_Error *, struct svc_req *); #define device_unlock 19 extern enum clnt_stat device_unlock_1(Device_Link *, Device_Error *, CLIENT *); extern bool_t device_unlock_1_svc(Device_Link *, Device_Error *, struct svc_req *); #define device_enable_srq 20 extern enum clnt_stat device_enable_srq_1(Device_EnableSrqParms *, Device_Error *, CLIENT *); extern bool_t device_enable_srq_1_svc(Device_EnableSrqParms *, Device_Error *, struct svc_req *); #define device_docmd 22 extern enum clnt_stat device_docmd_1(Device_DocmdParms *, Device_DocmdResp *, CLIENT *); extern bool_t device_docmd_1_svc(Device_DocmdParms *, Device_DocmdResp *, struct svc_req *); #define destroy_link 23 extern enum clnt_stat destroy_link_1(Device_Link *, Device_Error *, CLIENT *); extern bool_t destroy_link_1_svc(Device_Link *, Device_Error *, struct svc_req *); #define create_intr_chan 25 extern enum clnt_stat create_intr_chan_1(Device_RemoteFunc *, Device_Error *, CLIENT *); extern bool_t create_intr_chan_1_svc(Device_RemoteFunc *, Device_Error *, struct svc_req *); #define destroy_intr_chan 26 extern enum clnt_stat destroy_intr_chan_1(void *, Device_Error *, CLIENT *); extern bool_t destroy_intr_chan_1_svc(void *, Device_Error *, struct svc_req *); extern int device_core_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); #else /* K&R C */ #define create_link 10 extern enum clnt_stat create_link_1(); extern bool_t create_link_1_svc(); #define device_write 11 extern enum clnt_stat device_write_1(); extern bool_t device_write_1_svc(); #define device_read 12 extern enum clnt_stat device_read_1(); extern bool_t device_read_1_svc(); #define device_readstb 13 extern enum clnt_stat device_readstb_1(); extern bool_t device_readstb_1_svc(); #define device_trigger 14 extern enum clnt_stat device_trigger_1(); extern bool_t device_trigger_1_svc(); #define device_clear 15 extern enum clnt_stat device_clear_1(); extern bool_t device_clear_1_svc(); #define device_remote 16 extern enum clnt_stat device_remote_1(); extern bool_t device_remote_1_svc(); #define device_local 17 extern enum clnt_stat device_local_1(); extern bool_t device_local_1_svc(); #define device_lock 18 extern enum clnt_stat device_lock_1(); extern bool_t device_lock_1_svc(); #define device_unlock 19 extern enum clnt_stat device_unlock_1(); extern bool_t device_unlock_1_svc(); #define device_enable_srq 20 extern enum clnt_stat device_enable_srq_1(); extern bool_t device_enable_srq_1_svc(); #define device_docmd 22 extern enum clnt_stat device_docmd_1(); extern bool_t device_docmd_1_svc(); #define destroy_link 23 extern enum clnt_stat destroy_link_1(); extern bool_t destroy_link_1_svc(); #define create_intr_chan 25 extern enum clnt_stat create_intr_chan_1(); extern bool_t create_intr_chan_1_svc(); #define destroy_intr_chan 26 extern enum clnt_stat destroy_intr_chan_1(); extern bool_t destroy_intr_chan_1_svc(); extern int device_core_1_freeresult (); #endif /* K&R C */ /* the xdr functions */ #if defined(__STDC__) || defined(__cplusplus) extern bool_t xdr_Device_Link (XDR *, Device_Link*); extern bool_t xdr_Device_AddrFamily (XDR *, Device_AddrFamily*); extern bool_t xdr_Device_Flags (XDR *, Device_Flags*); extern bool_t xdr_Device_ErrorCode (XDR *, Device_ErrorCode*); extern bool_t xdr_Device_Error (XDR *, Device_Error*); extern bool_t xdr_Create_LinkParms (XDR *, Create_LinkParms*); extern bool_t xdr_Create_LinkResp (XDR *, Create_LinkResp*); extern bool_t xdr_Device_WriteParms (XDR *, Device_WriteParms*); extern bool_t xdr_Device_WriteResp (XDR *, Device_WriteResp*); extern bool_t xdr_Device_ReadParms (XDR *, Device_ReadParms*); extern bool_t xdr_Device_ReadResp (XDR *, Device_ReadResp*); extern bool_t xdr_Device_ReadStbResp (XDR *, Device_ReadStbResp*); extern bool_t xdr_Device_GenericParms (XDR *, Device_GenericParms*); extern bool_t xdr_Device_RemoteFunc (XDR *, Device_RemoteFunc*); extern bool_t xdr_Device_EnableSrqParms (XDR *, Device_EnableSrqParms*); extern bool_t xdr_Device_LockParms (XDR *, Device_LockParms*); extern bool_t xdr_Device_DocmdParms (XDR *, Device_DocmdParms*); extern bool_t xdr_Device_DocmdResp (XDR *, Device_DocmdResp*); #else /* K&R C */ extern bool_t xdr_Device_Link (); extern bool_t xdr_Device_AddrFamily (); extern bool_t xdr_Device_Flags (); extern bool_t xdr_Device_ErrorCode (); extern bool_t xdr_Device_Error (); extern bool_t xdr_Create_LinkParms (); extern bool_t xdr_Create_LinkResp (); extern bool_t xdr_Device_WriteParms (); extern bool_t xdr_Device_WriteResp (); extern bool_t xdr_Device_ReadParms (); extern bool_t xdr_Device_ReadResp (); extern bool_t xdr_Device_ReadStbResp (); extern bool_t xdr_Device_GenericParms (); extern bool_t xdr_Device_RemoteFunc (); extern bool_t xdr_Device_EnableSrqParms (); extern bool_t xdr_Device_LockParms (); extern bool_t xdr_Device_DocmdParms (); extern bool_t xdr_Device_DocmdResp (); #endif /* K&R C */ #ifdef __cplusplus } #endif #endif /* !_VXI11_H_RPCGEN */ instrument-control-0.4.0/src/vxi11/vxi11.x0000644000000000000000000001373013460206417016476 0ustar0000000000000000% %/* VXI-11 RPCL definitions. Taken from appendix C of the VXI-11 specfication. % * See http://www.vxi.org % */ %#include %#include % %/* VXI-11 flags */ %#define VXI11_FLAG_WAITLOCK 0x01 %#define VXI11_FLAG_ENDW 0x08 %#define VXI11_FLAG_TERMCHRSET 0x80 % %/* VXI-11 device_docmd 'cmd' values */ %#define VXI11_DOCMD_SEND_COMMAND 0x020000 %#define VXI11_DOCMD_BUS_STATUS 0x020001 %#define VXI11_DOCMD_ATN_CONTROL 0x020002 %#define VXI11_DOCMD_REN_CONTROL 0x020003 %#define VXI11_DOCMD_PASS_CONTROL 0x020004 %#define VXI11_DOCMD_BUS_ADDRESS 0x02000A %#define VXI11_DOCMD_IFC_CONTROL 0x020010 % %/* VXI-11 device_docmd Bus Status values */ %#define VXI11_DOCMD_STAT_REMOTE 1 %#define VXI11_DOCMD_STAT_SRQ 2 %#define VXI11_DOCMD_STAT_NDAC 3 %#define VXI11_DOCMD_STAT_SYS_CTRLR 4 %#define VXI11_DOCMD_STAT_CTRLR_CHRG 5 %#define VXI11_DOCMD_STAT_TALKER 6 %#define VXI11_DOCMD_STAT_LISTENER 7 %#define VXI11_DOCMD_STAT_BUSADDR 8 % %/* VXI-11 device_read 'reason' bits */ %#define VXI11_REASON_REQCNT 1 /* requested number of bytes read */ %#define VXI11_REASON_CHR 2 /* read terminated by eos character */ %#define VXI11_REASON_END 4 /* read terminated by EOI */ % %/* VXI-11 errors */ %#define VXI11_ERR_SUCCESS 0 %#define VXI11_ERR_SYNTAX 1 %#define VXI11_ERR_NODEVICE 3 %#define VXI11_ERR_LINKINVAL 4 %#define VXI11_ERR_PARAMETER 5 %#define VXI11_ERR_NOCHAN 6 %#define VXI11_ERR_NOTSUPP 8 %#define VXI11_ERR_RESOURCES 9 %#define VXI11_ERR_LOCKED 11 %#define VXI11_ERR_NOLOCK 12 %#define VXI11_ERR_IOTIMEOUT 15 %#define VXI11_ERR_IOERROR 17 %#define VXI11_ERR_ADDRINVAL 21 %#define VXI11_ERR_ABORT 23 %#define VXI11_ERR_CHANEST 29 /* Types */ typedef long Device_Link; enum Device_AddrFamily { /* used by interrupts */ DEVICE_TCP, DEVICE_UDP }; typedef long Device_Flags; /* Error types */ typedef long Device_ErrorCode; struct Device_Error { Device_ErrorCode error; }; struct Create_LinkParms { long clientId; /* implementation specific value */ bool lockDevice; /* attempt to lock the device */ unsigned long lock_timeout; /* time to wait on a lock */ string device<>; /* name of device */ }; struct Create_LinkResp { Device_ErrorCode error; Device_Link lid; unsigned short abortPort; /* for the abort RPC */ unsigned long maxRecvSize; /* specifies max data size in bytes device will accept on a write */ }; struct Device_WriteParms { Device_Link lid; /* link id from create_link */ unsigned long io_timeout; /* time to wait for I/O */ unsigned long lock_timeout; /* time to wait for lock */ Device_Flags flags; opaque data<>; /* the data length and the data itself */ }; struct Device_WriteResp { Device_ErrorCode error; unsigned long size; /* Number of bytes written */ }; struct Device_ReadParms { Device_Link lid; /* link id from create_link */ unsigned long requestSize; /* Bytes requested */ unsigned long io_timeout; /* time to wait for I/O */ unsigned long lock_timeout; /* time to wait for lock */ Device_Flags flags; char termChar; /* valid if flags & termchrset */ }; struct Device_ReadResp { Device_ErrorCode error; long reason; /* Reason(s) read completed */ opaque data<>; /* data.len and data.val */ }; struct Device_ReadStbResp { Device_ErrorCode error; /* error code */ unsigned char stb; /* the returned status byte */ }; struct Device_GenericParms { Device_Link lid; /* Device_Link id from connect call */ Device_Flags flags; /* flags with options */ unsigned long lock_timeout; /* time to wait for lock */ unsigned long io_timeout; /* time to wait for I/O */ }; struct Device_RemoteFunc { unsigned long hostAddr; /* Host servicing Interrupt */ unsigned short hostPort; /* valid port # on client */ unsigned long progNum; /* DEVICE_INTR */ unsigned long progVers; /* DEVICE_INTR_VERSION */ Device_AddrFamily progFamily; /* DEVICE_UDP | DEVICE_TCP */ }; struct Device_EnableSrqParms { Device_Link lid; bool enable; /* Enable or disable interrupts */ opaque handle<40>; /* Host specific data */ }; struct Device_LockParms { Device_Link lid; /* link id from create_link */ Device_Flags flags; /* Contains the waitlock flag */ unsigned long lock_timeout; /* time to wait to acquire lock */ }; struct Device_DocmdParms { Device_Link lid; /* link id from create_link */ Device_Flags flags; /* flags specifying various options */ unsigned long io_timeout; /* time to wait for I/O to complete */ unsigned long lock_timeout; /* time to wait on a lock */ long cmd; /* which command to execute */ bool network_order; /* client's byte order */ long datasize; /* size of individual data elements */ opaque data_in<>; /* docmd data parameters */ }; struct Device_DocmdResp { Device_ErrorCode error; /* returned status */ opaque data_out<>; /* returned data parameter */ }; program DEVICE_ASYNC{ version DEVICE_ASYNC_VERSION { Device_Error device_abort (Device_Link) = 1; } = 1; } = 0x0607B0; program DEVICE_CORE { version DEVICE_CORE_VERSION { Create_LinkResp create_link (Create_LinkParms) = 10; Device_WriteResp device_write (Device_WriteParms) = 11; Device_ReadResp device_read (Device_ReadParms) = 12; Device_ReadStbResp device_readstb (Device_GenericParms) = 13; Device_Error device_trigger (Device_GenericParms) = 14; Device_Error device_clear (Device_GenericParms) = 15; Device_Error device_remote (Device_GenericParms) = 16; Device_Error device_local (Device_GenericParms) = 17; Device_Error device_lock (Device_LockParms) = 18; Device_Error device_unlock (Device_Link) = 19; Device_Error device_enable_srq (Device_EnableSrqParms) = 20; Device_DocmdResp device_docmd (Device_DocmdParms) = 22; Device_Error destroy_link (Device_Link) = 23; Device_Error create_intr_chan (Device_RemoteFunc) = 25; Device_Error destroy_intr_chan (void) = 26; } = 1; } = 0x0607AF; instrument-control-0.4.0/src/vxi11/vxi11_class.cc0000644000000000000000000002424713460206417020006 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . // // VXI11 functions are copied from Steve D. Sharples VXI11 library // see http://optics.eee.nottingham.ac.uk/vxi11/ // #include #include #include // open or close vxi11 session only on call of vxi11 or vxi11_close #define OPENONCE using std::string; #include "vxi11_class.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_vxi11, "octave_vxi11", "octave_vxi11"); #define VXI11_DEFAULT_TIMEOUT 10000 /* in ms */ #define VXI11_READ_TIMEOUT 2000 /* in ms */ #define VXI11_MAX_CLIENTS 256 /* maximum no of unique IP addresses/clients */ #define VXI11_NULL_READ_RESP 50 /* vxi11_receive() return value if a query * times out ON THE INSTRUMENT (and so we have * to resend the query again) */ #define VXI11_NULL_WRITE_RESP 51 /* vxi11_send() return value if a sent command * times out ON THE INSTURMENT. */ octave_vxi11::octave_vxi11 (void) { static bool type_registered = false; this->ip = ""; if (! type_registered) { type_registered = true; register_type (); } } octave_vxi11::~octave_vxi11 (void) { this->close (); } void octave_vxi11::print (std::ostream& os, bool pr_as_read_syntax) { print_raw (os, pr_as_read_syntax); newline (os); } void octave_vxi11::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw (os, pr_as_read_syntax); newline (os); } void octave_vxi11::print_raw (std::ostream& os, bool pr_as_read_syntax) const { os << this->ip; } int octave_vxi11::open (string ip) { std::string inst="inst0"; this->ip=ip; #ifdef OPENONCE if (this->openvxi (this->ip.c_str(),&this->client,&this->link,inst.c_str ())) { error ("vxi11: Cannot open VXI11..."); return -1; } #endif return 0; } int octave_vxi11::read(char *buf, unsigned int len) { CLIENT *client; Create_LinkResp *link; unsigned long timeout = VXI11_READ_TIMEOUT; if (this->ip.empty()) { error("vxi11: setup ip first"); return -1; } #ifdef OPENONCE client = this->client; link = this->link; #else std::string inst="inst0"; if (this->openvxi(this->ip.c_str(),&client,&link,inst.c_str())) { error("vxi11: Cannot open VXI11..."); return -1; } #endif #define RCV_END_BIT 0x04 // An end indicator has been read #define RCV_CHR_BIT 0x02 // A termchr is set in flags and a character which matches termChar is transferred #define RCV_REQCNT_BIT 0x01 // requestSize bytes have been transferred. This includes a request size of zero. //long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout) { Device_ReadParms read_parms; Device_ReadResp read_resp; unsigned int curr_pos = 0; read_parms.lid = link->lid; read_parms.requestSize = len; read_parms.io_timeout = timeout; /* in ms */ read_parms.lock_timeout = timeout; /* in ms */ read_parms.flags = 0; read_parms.termChar = 0; do { memset(&read_resp, 0, sizeof(read_resp)); read_resp.data.data_val = buf + curr_pos; read_parms.requestSize = len - curr_pos; // Never request more total data than originally specified in len if(device_read_1(&read_parms, &read_resp, client) != RPC_SUCCESS) { error ("vxi11: cannot read"); return -1; /* there is nothing to read. Usually occurs after sending a query which times out on the instrument. If we don't check this first, then the following line causes a seg fault */ } if (read_resp.error != 0) { /* Read failed for reason specified in error code. * (From published VXI-11 protocol, section B.5.2) * 0 no error * 1 syntax error * 3 device not accessible * 4 invalid link identifier * 5 parameter error * 6 channel not established * 8 operation not supported * 9 out of resources * 11 device locked by another link * 12 no lock held by this link * 15 I/O timeout * 17 I/O error * 21 invalid address * 23 abort * 29 channel already established */ error ("vxi11: cannot read: %d",(int)read_resp.error); return -1; } if ((curr_pos + read_resp.data.data_len) <= len) { curr_pos += read_resp.data.data_len; } if( (read_resp.reason & RCV_END_BIT) || (read_resp.reason & RCV_CHR_BIT) ) { break; } else if( curr_pos == len ) { error ("xvi11: read error: buffer too small. Read %d bytes without hitting terminator.", (int)curr_pos ); return -1; } } while (1); #ifndef OPENONCE // close VXI11 session if (this->closevxi (this->ip.c_str (),client,link)) { error ("vxi11:Cannot close VXI11..."); return -1; } #endif return curr_pos; } int octave_vxi11::write (const char *buf, int len) { CLIENT *client; Create_LinkResp *link; if (this->ip.empty ()) { error ("vxi11: setup ip first"); return -1; } #ifdef OPENONCE client = this->client; link = this->link; #else std::string inst="inst0"; if (this->openvxi (this->ip.c_str (),&client,&link,inst.c_str ())) { error ("vxi11: Cannot open VXI11..."); return -1; } #endif //int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len) { Device_WriteParms write_parms; unsigned int bytes_left = len; char *send_cmd; send_cmd = new char[len]; memcpy (send_cmd, buf, len); write_parms.lid = link->lid; write_parms.io_timeout = VXI11_DEFAULT_TIMEOUT; write_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT; /* We can only write (link->maxRecvSize) bytes at a time, so we sit in a loop, * writing a chunk at a time, until we're done. */ do { Device_WriteResp write_resp; memset(&write_resp, 0, sizeof(write_resp)); if (bytes_left <= link->maxRecvSize) { write_parms.flags = 8; write_parms.data.data_len = bytes_left; } else { write_parms.flags = 0; /* We need to check that maxRecvSize is a sane value (ie >0). Believe it * or not, on some versions of Agilent Infiniium scope firmware the scope * returned "0", which breaks Rule B.6.3 of the VXI-11 protocol. Nevertheless * we need to catch this, otherwise the program just hangs. */ if (link->maxRecvSize > 0) { write_parms.data.data_len = link->maxRecvSize; } else { write_parms.data.data_len = 4096; /* pretty much anything should be able to cope with 4kB */ } } write_parms.data.data_val = send_cmd + (len - bytes_left); if(device_write_1 (&write_parms, &write_resp, client) != RPC_SUCCESS) { delete[] send_cmd; error ("vxi11: cannot write"); return -VXI11_NULL_WRITE_RESP; /* The instrument did not acknowledge the write, just completely dropped it. There was no vxi11 comms error as such, the instrument is just being rude. Usually occurs when the instrument is busy. If we don't check this first, then the following line causes a seg fault */ } if (write_resp.error != 0) { error("vxi11_user: write error: %d", (int)write_resp.error); delete[] send_cmd; return -(write_resp.error); } bytes_left -= write_resp.size; } while (bytes_left > 0); delete[] send_cmd; #ifndef OPENONCE // close VXI11 session if (this->closevxi (this->ip.c_str (),client,link)) { error ("vxi11:Cannot close VXI11..."); return -1; } #endif return 0; } int octave_vxi11::close (void) { int retval = 0; #ifdef OPENONCE // close VXI11 session if (!this->ip.empty()) { if (this->closevxi (this->ip.c_str (),this->client,this->link)) { error ("vxi11:Cannot close VXI11..."); return -1; } } #endif this->ip = ""; return retval; } int octave_vxi11::openvxi (const char *ip, CLIENT **client, Create_LinkResp **link, const char *device) { #ifdef CONST_CLNT_SUPPORT const char * tmpip = ip; #else char tmpip[256]; strncpy(tmpip, ip, 250); tmpip[250] = '\0'; #endif *client = clnt_create(tmpip, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp"); if (*client == NULL) { clnt_pcreateerror (tmpip); error ("vxi11: Error creating client..."); return -1; } 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 = (char *) device; *link = (Create_LinkResp *) calloc (1, sizeof(Create_LinkResp)); if (create_link_1 (&link_parms, *link, *client) != RPC_SUCCESS) { clnt_perror (*client, tmpip); error ("vxi11: Error creating client..."); return -2; } return 0; } int octave_vxi11::closevxi (const char *ip, CLIENT *client, Create_LinkResp *link) { Device_Error dev_error; memset (&dev_error, 0, sizeof(dev_error)); if (destroy_link_1 (&link->lid, &dev_error, client) != RPC_SUCCESS) { #ifdef CONST_CLNT_SUPPORT const char * tmpip = ip; #else char tmpip[256]; strncpy(tmpip, ip, 250); tmpip[250] = '\0'; #endif clnt_perror (client, tmpip); return -1; } clnt_destroy (client); return 0; } instrument-control-0.4.0/src/vxi11/vxi11_class.h0000644000000000000000000000401713460206417017641 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #ifndef VXI11_CLASS_H #define VXI11_CLASS_H #include #include #include "vxi11.h" #include using std::string; class octave_vxi11 : public octave_base_value { public: octave_vxi11 (void); ~octave_vxi11 (void); int open (string); int close (void); // Simple vxi11 commands int write (const char*, int); int read (char*, unsigned int); // Overloaded base functions string vxi11_value () const { return (string)this->ip; } virtual double scalar_value (bool frc_str_conv = false) const { return (double)0; } void print (std::ostream& os, bool pr_as_read_syntax = false); void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax) const; // Properties bool is_constant (void) const { return true;} bool is_defined (void) const { return true;} bool print_as_scalar (void) const { return true;} private: CLIENT *client; Create_LinkResp *link; std::string ip; std::string device; int openvxi (const char *, CLIENT **, Create_LinkResp **, const char *); int closevxi (const char *, CLIENT *, Create_LinkResp *); DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif instrument-control-0.4.0/src/vxi11/vxi11_clnt.c0000644000000000000000000001351313460206417017470 0ustar0000000000000000/* * Please do not edit this file. * It was generated using rpcgen. */ #include /* for memset */ #include "vxi11.h" /* VXI-11 RPCL definitions. Taken from appendix C of the VXI-11 specfication. * See http://www.vxi.org */ #include #include /* VXI-11 flags */ #define VXI11_FLAG_WAITLOCK 0x01 #define VXI11_FLAG_ENDW 0x08 #define VXI11_FLAG_TERMCHRSET 0x80 /* VXI-11 device_docmd 'cmd' values */ #define VXI11_DOCMD_SEND_COMMAND 0x020000 #define VXI11_DOCMD_BUS_STATUS 0x020001 #define VXI11_DOCMD_ATN_CONTROL 0x020002 #define VXI11_DOCMD_REN_CONTROL 0x020003 #define VXI11_DOCMD_PASS_CONTROL 0x020004 #define VXI11_DOCMD_BUS_ADDRESS 0x02000A #define VXI11_DOCMD_IFC_CONTROL 0x020010 /* VXI-11 device_docmd Bus Status values */ #define VXI11_DOCMD_STAT_REMOTE 1 #define VXI11_DOCMD_STAT_SRQ 2 #define VXI11_DOCMD_STAT_NDAC 3 #define VXI11_DOCMD_STAT_SYS_CTRLR 4 #define VXI11_DOCMD_STAT_CTRLR_CHRG 5 #define VXI11_DOCMD_STAT_TALKER 6 #define VXI11_DOCMD_STAT_LISTENER 7 #define VXI11_DOCMD_STAT_BUSADDR 8 /* VXI-11 device_read 'reason' bits */ #define VXI11_REASON_REQCNT 1 /* requested number of bytes read */ #define VXI11_REASON_CHR 2 /* read terminated by eos character */ #define VXI11_REASON_END 4 /* read terminated by EOI */ /* VXI-11 errors */ #define VXI11_ERR_SUCCESS 0 #define VXI11_ERR_SYNTAX 1 #define VXI11_ERR_NODEVICE 3 #define VXI11_ERR_LINKINVAL 4 #define VXI11_ERR_PARAMETER 5 #define VXI11_ERR_NOCHAN 6 #define VXI11_ERR_NOTSUPP 8 #define VXI11_ERR_RESOURCES 9 #define VXI11_ERR_LOCKED 11 #define VXI11_ERR_NOLOCK 12 #define VXI11_ERR_IOTIMEOUT 15 #define VXI11_ERR_IOERROR 17 #define VXI11_ERR_ADDRINVAL 21 #define VXI11_ERR_ABORT 23 #define VXI11_ERR_CHANEST 29 /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; enum clnt_stat device_abort_1(Device_Link *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_abort, (xdrproc_t) xdr_Device_Link, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat create_link_1(Create_LinkParms *argp, Create_LinkResp *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, create_link, (xdrproc_t) xdr_Create_LinkParms, (caddr_t) argp, (xdrproc_t) xdr_Create_LinkResp, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_write_1(Device_WriteParms *argp, Device_WriteResp *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_write, (xdrproc_t) xdr_Device_WriteParms, (caddr_t) argp, (xdrproc_t) xdr_Device_WriteResp, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_read_1(Device_ReadParms *argp, Device_ReadResp *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_read, (xdrproc_t) xdr_Device_ReadParms, (caddr_t) argp, (xdrproc_t) xdr_Device_ReadResp, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_readstb_1(Device_GenericParms *argp, Device_ReadStbResp *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_readstb, (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp, (xdrproc_t) xdr_Device_ReadStbResp, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_trigger_1(Device_GenericParms *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_trigger, (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_clear_1(Device_GenericParms *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_clear, (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_remote_1(Device_GenericParms *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_remote, (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_local_1(Device_GenericParms *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_local, (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_lock_1(Device_LockParms *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_lock, (xdrproc_t) xdr_Device_LockParms, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_unlock_1(Device_Link *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_unlock, (xdrproc_t) xdr_Device_Link, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_enable_srq_1(Device_EnableSrqParms *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_enable_srq, (xdrproc_t) xdr_Device_EnableSrqParms, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat device_docmd_1(Device_DocmdParms *argp, Device_DocmdResp *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, device_docmd, (xdrproc_t) xdr_Device_DocmdParms, (caddr_t) argp, (xdrproc_t) xdr_Device_DocmdResp, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat destroy_link_1(Device_Link *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, destroy_link, (xdrproc_t) xdr_Device_Link, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat create_intr_chan_1(Device_RemoteFunc *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, create_intr_chan, (xdrproc_t) xdr_Device_RemoteFunc, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } enum clnt_stat destroy_intr_chan_1(void *argp, Device_Error *clnt_res, CLIENT *clnt) { return (clnt_call(clnt, destroy_intr_chan, (xdrproc_t) xdr_void, (caddr_t) argp, (xdrproc_t) xdr_Device_Error, (caddr_t) clnt_res, TIMEOUT)); } instrument-control-0.4.0/src/vxi11/vxi11_close.cc0000644000000000000000000000317113460206417017777 0ustar0000000000000000// Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_VXI11 #include "vxi11_class.h" #endif // PKG_ADD: autoload ("vxi11_close", "vxi11.oct"); DEFUN_DLD (vxi11_close, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} vxi11_close (@var{vxi11})\n \ \n\ Close the interface and release a file descriptor.\n \ \n\ @var{vxi11} - instance of @var{octave_vxi11} class.\n \ @end deftypefn") { #ifndef BUILD_VXI11 error ("vxi11: Your system doesn't support the VXI11 interface"); return octave_value(); #else if (args.length () != 1 || args (0).type_id () != octave_vxi11::static_type_id()) { print_usage (); return octave_value (-1); } octave_vxi11* vxi11 = NULL; const octave_base_value& rep = args (0).get_rep (); vxi11 = &((octave_vxi11 &)rep); vxi11->close (); return octave_value (); #endif } instrument-control-0.4.0/src/vxi11/vxi11_read.cc0000644000000000000000000000526113460206417017607 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_VXI11 #include #include "vxi11_class.h" #endif // PKG_ADD: autoload ("vxi11_read", "vxi11.oct"); DEFUN_DLD (vxi11_read, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{data}, @var{count}] = } vxi11_read (@var{vxi11}, @var{n})\n \ \n\ Read from vxi11 slave device.\n \ \n\ @var{vxi11} - instance of @var{octave_vxi11} class.@* \ @var{n} - number of bytes to attempt to read of type Integer.\n \ \n\ The vxi11_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ @end deftypefn") { #ifndef BUILD_VXI11 error ("vxi11: Your system doesn't support the VXI11 interface"); return octave_value (); #else if (args.length () < 1 || args.length () > 2 || args (0).type_id () != octave_vxi11::static_type_id ()) { print_usage (); return octave_value (-1); } unsigned int buffer_len = 1; if (args.length () > 1) { if ( !(args (1).OV_ISINTEGER() || args (1).OV_ISFLOAT()) ) { print_usage (); return octave_value (-1); } buffer_len = args (1).int_value (); } OCTAVE_LOCAL_BUFFER (char, buffer, (buffer_len + 1)); if (buffer == NULL) { error ("vxi11_read: cannot allocate requested memory..."); return octave_value (-1); } octave_vxi11* vxi11 = NULL; const octave_base_value& rep = args(0).get_rep(); vxi11 = &((octave_vxi11 &)rep); int retval; retval = vxi11->read (buffer, buffer_len); octave_value_list return_list; uint8NDArray data( dim_vector(1, (retval > 0) ? retval : 0) ); for (int i = 0; i < retval; i++) data(i) = static_cast(buffer[i]); return_list (0) = data; return_list (1) = retval; return return_list; #endif } instrument-control-0.4.0/src/vxi11/vxi11_svc.c0000644000000000000000000002317113460206417017324 0ustar0000000000000000/* * Please do not edit this file. * It was generated using rpcgen. */ #include "vxi11.h" #include #include #include #include #include #include #include #ifndef SIG_PF #define SIG_PF void(*)(int) #endif /* VXI-11 RPCL definitions. Taken from appendix C of the VXI-11 specfication. * See http://www.vxi.org */ #include #include /* VXI-11 flags */ #define VXI11_FLAG_WAITLOCK 0x01 #define VXI11_FLAG_ENDW 0x08 #define VXI11_FLAG_TERMCHRSET 0x80 /* VXI-11 device_docmd 'cmd' values */ #define VXI11_DOCMD_SEND_COMMAND 0x020000 #define VXI11_DOCMD_BUS_STATUS 0x020001 #define VXI11_DOCMD_ATN_CONTROL 0x020002 #define VXI11_DOCMD_REN_CONTROL 0x020003 #define VXI11_DOCMD_PASS_CONTROL 0x020004 #define VXI11_DOCMD_BUS_ADDRESS 0x02000A #define VXI11_DOCMD_IFC_CONTROL 0x020010 /* VXI-11 device_docmd Bus Status values */ #define VXI11_DOCMD_STAT_REMOTE 1 #define VXI11_DOCMD_STAT_SRQ 2 #define VXI11_DOCMD_STAT_NDAC 3 #define VXI11_DOCMD_STAT_SYS_CTRLR 4 #define VXI11_DOCMD_STAT_CTRLR_CHRG 5 #define VXI11_DOCMD_STAT_TALKER 6 #define VXI11_DOCMD_STAT_LISTENER 7 #define VXI11_DOCMD_STAT_BUSADDR 8 /* VXI-11 device_read 'reason' bits */ #define VXI11_REASON_REQCNT 1 /* requested number of bytes read */ #define VXI11_REASON_CHR 2 /* read terminated by eos character */ #define VXI11_REASON_END 4 /* read terminated by EOI */ /* VXI-11 errors */ #define VXI11_ERR_SUCCESS 0 #define VXI11_ERR_SYNTAX 1 #define VXI11_ERR_NODEVICE 3 #define VXI11_ERR_LINKINVAL 4 #define VXI11_ERR_PARAMETER 5 #define VXI11_ERR_NOCHAN 6 #define VXI11_ERR_NOTSUPP 8 #define VXI11_ERR_RESOURCES 9 #define VXI11_ERR_LOCKED 11 #define VXI11_ERR_NOLOCK 12 #define VXI11_ERR_IOTIMEOUT 15 #define VXI11_ERR_IOERROR 17 #define VXI11_ERR_ADDRINVAL 21 #define VXI11_ERR_ABORT 23 #define VXI11_ERR_CHANEST 29 static void device_async_1(struct svc_req *rqstp, register SVCXPRT *transp) { union { Device_Link device_abort_1_arg; } argument; union { Device_Error device_abort_1_res; } result; bool_t retval; xdrproc_t _xdr_argument, _xdr_result; bool_t (*local)(char *, void *, struct svc_req *); switch (rqstp->rq_proc) { case NULLPROC: (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL); return; case device_abort: _xdr_argument = (xdrproc_t) xdr_Device_Link; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_abort_1_svc; break; default: svcerr_noproc (transp); return; } memset ((char *)&argument, 0, sizeof (argument)); if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { svcerr_decode (transp); return; } retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp); if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) { svcerr_systemerr (transp); } if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { fprintf (stderr, "%s", "unable to free arguments"); exit (1); } if (!device_async_1_freeresult (transp, _xdr_result, (caddr_t) &result)) fprintf (stderr, "%s", "unable to free results"); return; } static void device_core_1(struct svc_req *rqstp, register 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; union { Create_LinkResp create_link_1_res; Device_WriteResp device_write_1_res; Device_ReadResp device_read_1_res; Device_ReadStbResp device_readstb_1_res; Device_Error device_trigger_1_res; Device_Error device_clear_1_res; Device_Error device_remote_1_res; Device_Error device_local_1_res; Device_Error device_lock_1_res; Device_Error device_unlock_1_res; Device_Error device_enable_srq_1_res; Device_DocmdResp device_docmd_1_res; Device_Error destroy_link_1_res; Device_Error create_intr_chan_1_res; Device_Error destroy_intr_chan_1_res; } result; bool_t retval; xdrproc_t _xdr_argument, _xdr_result; bool_t (*local)(char *, void *, struct svc_req *); switch (rqstp->rq_proc) { case NULLPROC: (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL); return; case create_link: _xdr_argument = (xdrproc_t) xdr_Create_LinkParms; _xdr_result = (xdrproc_t) xdr_Create_LinkResp; local = (bool_t (*) (char *, void *, struct svc_req *))create_link_1_svc; break; case device_write: _xdr_argument = (xdrproc_t) xdr_Device_WriteParms; _xdr_result = (xdrproc_t) xdr_Device_WriteResp; local = (bool_t (*) (char *, void *, struct svc_req *))device_write_1_svc; break; case device_read: _xdr_argument = (xdrproc_t) xdr_Device_ReadParms; _xdr_result = (xdrproc_t) xdr_Device_ReadResp; local = (bool_t (*) (char *, void *, struct svc_req *))device_read_1_svc; break; case device_readstb: _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; _xdr_result = (xdrproc_t) xdr_Device_ReadStbResp; local = (bool_t (*) (char *, void *, struct svc_req *))device_readstb_1_svc; break; case device_trigger: _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_trigger_1_svc; break; case device_clear: _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_clear_1_svc; break; case device_remote: _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_remote_1_svc; break; case device_local: _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_local_1_svc; break; case device_lock: _xdr_argument = (xdrproc_t) xdr_Device_LockParms; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_lock_1_svc; break; case device_unlock: _xdr_argument = (xdrproc_t) xdr_Device_Link; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_unlock_1_svc; break; case device_enable_srq: _xdr_argument = (xdrproc_t) xdr_Device_EnableSrqParms; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))device_enable_srq_1_svc; break; case device_docmd: _xdr_argument = (xdrproc_t) xdr_Device_DocmdParms; _xdr_result = (xdrproc_t) xdr_Device_DocmdResp; local = (bool_t (*) (char *, void *, struct svc_req *))device_docmd_1_svc; break; case destroy_link: _xdr_argument = (xdrproc_t) xdr_Device_Link; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))destroy_link_1_svc; break; case create_intr_chan: _xdr_argument = (xdrproc_t) xdr_Device_RemoteFunc; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))create_intr_chan_1_svc; break; case destroy_intr_chan: _xdr_argument = (xdrproc_t) xdr_void; _xdr_result = (xdrproc_t) xdr_Device_Error; local = (bool_t (*) (char *, void *, struct svc_req *))destroy_intr_chan_1_svc; break; default: svcerr_noproc (transp); return; } memset ((char *)&argument, 0, sizeof (argument)); if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { svcerr_decode (transp); return; } retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp); if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) { svcerr_systemerr (transp); } if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { fprintf (stderr, "%s", "unable to free arguments"); exit (1); } if (!device_core_1_freeresult (transp, _xdr_result, (caddr_t) &result)) fprintf (stderr, "%s", "unable to free results"); return; } int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (DEVICE_ASYNC, DEVICE_ASYNC_VERSION); pmap_unset (DEVICE_CORE, DEVICE_CORE_VERSION); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, udp)."); exit(1); } if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, tcp)."); exit(1); } if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ } instrument-control-0.4.0/src/vxi11/vxi11_write.cc0000644000000000000000000000467013460206417020031 0ustar0000000000000000// Copyright (C) 2018 John Donoghue // Copyright (C) 2013 Stefan Mahr // Copyright (C) 2012 Andrius Sutas // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see . #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifdef BUILD_VXI11 #include "vxi11_class.h" #endif // PKG_ADD: autoload ("vxi11_write", "vxi11.oct"); DEFUN_DLD (vxi11_write, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{n} = } vxi11_write (@var{vxi11}, @var{data})\n \ \n\ Write data to a vxi11 slave device.\n \ \n\ @var{vxi11} - instance of @var{octave_vxi11} class.@* \ @var{data} - data to be written to the slave device. Can be either of String or uint8 type.\n \ \n\ Upon successful completion, vxi11_write() shall return the number of bytes written as the result @var{n}.\n \ @end deftypefn") { #ifndef BUILD_VXI11 error ("vxi11: Your system doesn't support the VXI11 interface"); return octave_value (); #else if (args.length () != 2 || args (0).type_id () != octave_vxi11::static_type_id ()) { print_usage (); return octave_value (-1); } octave_vxi11* vxi11 = NULL; const octave_base_value& rep = args (0).get_rep (); vxi11 = &((octave_vxi11 &)rep); const octave_base_value& data = args (1).get_rep (); int retval; if (data.is_string ()) { string buf = data.string_value (); retval = vxi11->write (buf.c_str (), buf.length ()); } else if (data.is_uint8_type ()) { NDArray dtmp = data.array_value (); OCTAVE_LOCAL_BUFFER (char, buf, (dtmp.numel ())); for (int i = 0; i < dtmp.numel (); i++) buf[i] = (char)dtmp(i); retval = vxi11->write (buf, data.byte_size()); } else { print_usage (); return octave_value (-1); } return octave_value (retval); #endif } instrument-control-0.4.0/src/vxi11/vxi11_xdr.c0000644000000000000000000003076413460206417017334 0ustar0000000000000000/* * Please do not edit this file. * It was generated using rpcgen. */ #include "vxi11.h" /* VXI-11 RPCL definitions. Taken from appendix C of the VXI-11 specfication. * See http://www.vxi.org */ #include #include /* VXI-11 flags */ #define VXI11_FLAG_WAITLOCK 0x01 #define VXI11_FLAG_ENDW 0x08 #define VXI11_FLAG_TERMCHRSET 0x80 /* VXI-11 device_docmd 'cmd' values */ #define VXI11_DOCMD_SEND_COMMAND 0x020000 #define VXI11_DOCMD_BUS_STATUS 0x020001 #define VXI11_DOCMD_ATN_CONTROL 0x020002 #define VXI11_DOCMD_REN_CONTROL 0x020003 #define VXI11_DOCMD_PASS_CONTROL 0x020004 #define VXI11_DOCMD_BUS_ADDRESS 0x02000A #define VXI11_DOCMD_IFC_CONTROL 0x020010 /* VXI-11 device_docmd Bus Status values */ #define VXI11_DOCMD_STAT_REMOTE 1 #define VXI11_DOCMD_STAT_SRQ 2 #define VXI11_DOCMD_STAT_NDAC 3 #define VXI11_DOCMD_STAT_SYS_CTRLR 4 #define VXI11_DOCMD_STAT_CTRLR_CHRG 5 #define VXI11_DOCMD_STAT_TALKER 6 #define VXI11_DOCMD_STAT_LISTENER 7 #define VXI11_DOCMD_STAT_BUSADDR 8 /* VXI-11 device_read 'reason' bits */ #define VXI11_REASON_REQCNT 1 /* requested number of bytes read */ #define VXI11_REASON_CHR 2 /* read terminated by eos character */ #define VXI11_REASON_END 4 /* read terminated by EOI */ /* VXI-11 errors */ #define VXI11_ERR_SUCCESS 0 #define VXI11_ERR_SYNTAX 1 #define VXI11_ERR_NODEVICE 3 #define VXI11_ERR_LINKINVAL 4 #define VXI11_ERR_PARAMETER 5 #define VXI11_ERR_NOCHAN 6 #define VXI11_ERR_NOTSUPP 8 #define VXI11_ERR_RESOURCES 9 #define VXI11_ERR_LOCKED 11 #define VXI11_ERR_NOLOCK 12 #define VXI11_ERR_IOTIMEOUT 15 #define VXI11_ERR_IOERROR 17 #define VXI11_ERR_ADDRINVAL 21 #define VXI11_ERR_ABORT 23 #define VXI11_ERR_CHANEST 29 bool_t xdr_Device_Link (XDR *xdrs, Device_Link *objp) { register int32_t *buf; if (!xdr_long (xdrs, objp)) return FALSE; return TRUE; } bool_t xdr_Device_AddrFamily (XDR *xdrs, Device_AddrFamily *objp) { register int32_t *buf; if (!xdr_enum (xdrs, (enum_t *) objp)) return FALSE; return TRUE; } bool_t xdr_Device_Flags (XDR *xdrs, Device_Flags *objp) { register int32_t *buf; if (!xdr_long (xdrs, objp)) return FALSE; return TRUE; } bool_t xdr_Device_ErrorCode (XDR *xdrs, Device_ErrorCode *objp) { register int32_t *buf; if (!xdr_long (xdrs, objp)) return FALSE; return TRUE; } bool_t xdr_Device_Error (XDR *xdrs, Device_Error *objp) { register int32_t *buf; if (!xdr_Device_ErrorCode (xdrs, &objp->error)) return FALSE; return TRUE; } bool_t xdr_Create_LinkParms (XDR *xdrs, Create_LinkParms *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_long (xdrs, &objp->clientId)) return FALSE; if (!xdr_bool (xdrs, &objp->lockDevice)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { IXDR_PUT_LONG(buf, objp->clientId); IXDR_PUT_BOOL(buf, objp->lockDevice); IXDR_PUT_U_LONG(buf, objp->lock_timeout); } if (!xdr_string (xdrs, &objp->device, ~0)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_long (xdrs, &objp->clientId)) return FALSE; if (!xdr_bool (xdrs, &objp->lockDevice)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { objp->clientId = IXDR_GET_LONG(buf); objp->lockDevice = IXDR_GET_BOOL(buf); objp->lock_timeout = IXDR_GET_U_LONG(buf); } if (!xdr_string (xdrs, &objp->device, ~0)) return FALSE; return TRUE; } if (!xdr_long (xdrs, &objp->clientId)) return FALSE; if (!xdr_bool (xdrs, &objp->lockDevice)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_string (xdrs, &objp->device, ~0)) return FALSE; return TRUE; } bool_t xdr_Create_LinkResp (XDR *xdrs, Create_LinkResp *objp) { register int32_t *buf; if (!xdr_Device_ErrorCode (xdrs, &objp->error)) return FALSE; if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_u_short (xdrs, &objp->abortPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->maxRecvSize)) return FALSE; return TRUE; } bool_t xdr_Device_WriteParms (XDR *xdrs, Device_WriteParms *objp) { register int32_t *buf; if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) return FALSE; return TRUE; } bool_t xdr_Device_WriteResp (XDR *xdrs, Device_WriteResp *objp) { register int32_t *buf; if (!xdr_Device_ErrorCode (xdrs, &objp->error)) return FALSE; if (!xdr_u_long (xdrs, &objp->size)) return FALSE; return TRUE; } bool_t xdr_Device_ReadParms (XDR *xdrs, Device_ReadParms *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->requestSize)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { IXDR_PUT_U_LONG(buf, objp->requestSize); IXDR_PUT_U_LONG(buf, objp->io_timeout); IXDR_PUT_U_LONG(buf, objp->lock_timeout); } if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_char (xdrs, &objp->termChar)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->requestSize)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { objp->requestSize = IXDR_GET_U_LONG(buf); objp->io_timeout = IXDR_GET_U_LONG(buf); objp->lock_timeout = IXDR_GET_U_LONG(buf); } if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_char (xdrs, &objp->termChar)) return FALSE; return TRUE; } if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_u_long (xdrs, &objp->requestSize)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_char (xdrs, &objp->termChar)) return FALSE; return TRUE; } bool_t xdr_Device_ReadResp (XDR *xdrs, Device_ReadResp *objp) { register int32_t *buf; if (!xdr_Device_ErrorCode (xdrs, &objp->error)) return FALSE; if (!xdr_long (xdrs, &objp->reason)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) return FALSE; return TRUE; } bool_t xdr_Device_ReadStbResp (XDR *xdrs, Device_ReadStbResp *objp) { register int32_t *buf; if (!xdr_Device_ErrorCode (xdrs, &objp->error)) return FALSE; if (!xdr_u_char (xdrs, &objp->stb)) return FALSE; return TRUE; } bool_t xdr_Device_GenericParms (XDR *xdrs, Device_GenericParms *objp) { register int32_t *buf; if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; return TRUE; } bool_t xdr_Device_RemoteFunc (XDR *xdrs, Device_RemoteFunc *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->hostAddr)) return FALSE; if (!xdr_u_short (xdrs, &objp->hostPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->progNum)) return FALSE; if (!xdr_u_long (xdrs, &objp->progVers)) return FALSE; } else { IXDR_PUT_U_LONG(buf, objp->hostAddr); IXDR_PUT_U_SHORT(buf, objp->hostPort); IXDR_PUT_U_LONG(buf, objp->progNum); IXDR_PUT_U_LONG(buf, objp->progVers); } if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->hostAddr)) return FALSE; if (!xdr_u_short (xdrs, &objp->hostPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->progNum)) return FALSE; if (!xdr_u_long (xdrs, &objp->progVers)) return FALSE; } else { objp->hostAddr = IXDR_GET_U_LONG(buf); objp->hostPort = IXDR_GET_U_SHORT(buf); objp->progNum = IXDR_GET_U_LONG(buf); objp->progVers = IXDR_GET_U_LONG(buf); } if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily)) return FALSE; return TRUE; } if (!xdr_u_long (xdrs, &objp->hostAddr)) return FALSE; if (!xdr_u_short (xdrs, &objp->hostPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->progNum)) return FALSE; if (!xdr_u_long (xdrs, &objp->progVers)) return FALSE; if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily)) return FALSE; return TRUE; } bool_t xdr_Device_EnableSrqParms (XDR *xdrs, Device_EnableSrqParms *objp) { register int32_t *buf; if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_bool (xdrs, &objp->enable)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, 40)) return FALSE; return TRUE; } bool_t xdr_Device_LockParms (XDR *xdrs, Device_LockParms *objp) { register int32_t *buf; if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; return TRUE; } bool_t xdr_Device_DocmdParms (XDR *xdrs, Device_DocmdParms *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_long (xdrs, &objp->cmd)) return FALSE; if (!xdr_bool (xdrs, &objp->network_order)) return FALSE; if (!xdr_long (xdrs, &objp->datasize)) return FALSE; } else { IXDR_PUT_U_LONG(buf, objp->io_timeout); IXDR_PUT_U_LONG(buf, objp->lock_timeout); IXDR_PUT_LONG(buf, objp->cmd); IXDR_PUT_BOOL(buf, objp->network_order); IXDR_PUT_LONG(buf, objp->datasize); } if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_long (xdrs, &objp->cmd)) return FALSE; if (!xdr_bool (xdrs, &objp->network_order)) return FALSE; if (!xdr_long (xdrs, &objp->datasize)) return FALSE; } else { objp->io_timeout = IXDR_GET_U_LONG(buf); objp->lock_timeout = IXDR_GET_U_LONG(buf); objp->cmd = IXDR_GET_LONG(buf); objp->network_order = IXDR_GET_BOOL(buf); objp->datasize = IXDR_GET_LONG(buf); } if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) return FALSE; return TRUE; } if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_long (xdrs, &objp->cmd)) return FALSE; if (!xdr_bool (xdrs, &objp->network_order)) return FALSE; if (!xdr_long (xdrs, &objp->datasize)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) return FALSE; return TRUE; } bool_t xdr_Device_DocmdResp (XDR *xdrs, Device_DocmdResp *objp) { register int32_t *buf; if (!xdr_Device_ErrorCode (xdrs, &objp->error)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data_out.data_out_val, (u_int *) &objp->data_out.data_out_len, ~0)) return FALSE; return TRUE; }