Getting started using the API with Linux

Post your Linux discussions here
Post Reply
mala
Newbie
Posts: 0
Joined: Fri Mar 21, 2014 8:42 pm

Getting started using the API with Linux

Post by mala »

I'm having trouble getting started. I'm on 64 bit Linux, and I would like to stream data from my Picoscope 2205A to a file on my computer. I gather that while the Windows PicoScope software can do this, Linux users will need to use the API. I haven't been able to find any READMEs or instructions, but after googling around for a while I came up with the following steps. Unfortunately, I haven't gotten them working yet.

Step 0:
Verify that your device is compatible with your computer here: http://www.picotech.com/support/kb/PicoScopeSDK-kb247
I'm using a PicoScope 2205A, which is compatible with both 32-bit and 64-bit Linux.

Step 1:
Install drivers and PicoScop software and run it to make sure everything works.

Step 2:
Install the SDK. You can get it from here: http://www.picoapps.com/coders-corner/sdks.html
I'm using the PicoScope 2205A, which currently results in version "R10.5.0.11", released in March 2013

Step 3:
Unzip the archive. There's a file "ps2000pg.en.pdf" which is the programmer's guide, and will walk you through how to use the API. Unfortunately, it only seems to have install instructions for Windows, and there doesn't appear to be a README file anywhere. However, there's a folder called "PS2000Con-Linux" which looks promising, so we'll start there.

Step 4:
First, make 'automake.sh' executable (chmod +x automake.sh). It won't run as is because was saved with DOS line endings, so you'll need to fix it first (most Linux text editors have this ability, or you can simply use the dos2unix command to convert it automatically. Once that's fixed, running it will generate a 'configure' script and run it.

Step 5:
Run "make". This is where it starts to break down for me. "make" fails with the following:

Code: Select all

make  all-am
make[1]: Entering directory `/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux'
gcc -DHAVE_CONFIG_H -I.     -g -O0 -Wall -MT PS2000con.o -MD -MP -MF .deps/PS2000con.Tpo -c -o PS2000con.o PS2000con.c
PS2000con.c:64:34: fatal error: libps2000-1.0/ps2000.h: No such file or directory
compilation terminated.
make[1]: *** [PS2000con.o] Error 1
make[1]: Leaving directory `/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux'
make: *** [all] Error 2
It can't find a "ps2000.h" file in a "libps2000-1.0" directory. Indeed, there is no "libps2000-1.0" directory. However, there was a "ps2000.h" file in the parent directory, so let's create a "libps2000-1.0" directory and copy ../ps2000.h into it.

At this point, it fails like so:

Code: Select all

make  all-am
make[1]: Entering directory `/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux'
gcc  -g -O0 -Wall   -o ps2000con PS2000con.o  
PS2000con.o: In function `set_defaults':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:277: undefined reference to `ps2000_set_ets'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:281: undefined reference to `ps2000_set_channel'
PS2000con.o: In function `set_trigger_advanced':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:329: undefined reference to `ps2000SetAdvTriggerChannelConditions'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:330: undefined reference to `ps2000SetAdvTriggerChannelDirections'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:336: undefined reference to `ps2000SetAdvTriggerChannelProperties'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:365: undefined reference to `ps2000SetAdvTriggerDelay'
PS2000con.o: In function `collect_block_immediate':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:395: undefined reference to `ps2000_set_trigger'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:401: undefined reference to `ps2000_get_timebase'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:414: undefined reference to `ps2000_run_block'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:415: undefined reference to `ps2000_ready'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:420: undefined reference to `ps2000_stop'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:426: undefined reference to `ps2000_get_times_and_values'
PS2000con.o: In function `collect_block_triggered':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:514: undefined reference to `ps2000_set_trigger'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:526: undefined reference to `ps2000_get_timebase'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:538: undefined reference to `ps2000_run_block'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:543: undefined reference to `ps2000_ready'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:556: undefined reference to `ps2000_stop'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:561: undefined reference to `ps2000_get_times_and_values'
PS2000con.o: In function `collect_block_advanced_triggered':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:644: undefined reference to `ps2000_get_timebase'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:656: undefined reference to `ps2000_run_block'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:661: undefined reference to `ps2000_ready'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:674: undefined reference to `ps2000_stop'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:679: undefined reference to `ps2000_get_times_and_values'
PS2000con.o: In function `collect_block_ets':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:772: undefined reference to `ps2000_set_trigger'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:783: undefined reference to `ps2000_set_ets'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:788: undefined reference to `ps2000_run_block'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:793: undefined reference to `ps2000_ready'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:805: undefined reference to `ps2000_stop'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:809: undefined reference to `ps2000_get_times_and_values'
PS2000con.o: In function `collect_streaming':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:902: undefined reference to `ps2000_set_trigger'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:911: undefined reference to `ps2000_run_streaming'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:920: undefined reference to `ps2000_get_values'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:960: undefined reference to `ps2000_stop'
PS2000con.o: In function `collect_fast_streaming':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:990: undefined reference to `ps2000_set_trigger'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1001: undefined reference to `ps2000_run_streaming_ns'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1010: undefined reference to `ps2000_get_streaming_last_values'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1022: undefined reference to `ps2000_stop'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1024: undefined reference to `ps2000_get_streaming_values_no_aggregation'
PS2000con.o: In function `collect_fast_streaming_triggered':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1106: undefined reference to `ps2000_run_streaming_ns'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1114: undefined reference to `ps2000_get_streaming_last_values'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1123: undefined reference to `ps2000_stop'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1125: undefined reference to `ps2000_get_streaming_values_no_aggregation'
PS2000con.o: In function `get_info':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1189: undefined reference to `ps2000_get_unit_info'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1291: undefined reference to `ps2000_get_unit_info'
PS2000con.o: In function `set_sig_gen':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1327: undefined reference to `ps2000_set_sig_gen_built_in'
PS2000con.o: In function `set_sig_gen_arb':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1373: undefined reference to `ps2000_set_sig_gen_arbitrary'
PS2000con.o: In function `set_timebase':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1396: undefined reference to `ps2000_get_timebase'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1412: undefined reference to `ps2000_get_timebase'
PS2000con.o: In function `main':
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1471: undefined reference to `ps2000_open_unit'
/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux/PS2000con.c:1608: undefined reference to `ps2000_close_unit'
collect2: error: ld returned 1 exit status
make[1]: *** [ps2000con] Error 1
make[1]: Leaving directory `/home/poe/Desktop/picoscope/R10.5.0.11/PS2000Con-Linux'
make: *** [all] Error 2
It looks like it's trying to use the API functions, and these are undefined. This would suggest to me that I have not installed the SDK correctly. This isn't too surprising because as far as I can tell that's what I'm trying to do. Perhaps I skipped a step?

Is there any definitive documentation on how to get this up and running? If so, where is it?

Thanks!

Martyn
Site Admin
Site Admin
Posts: 4483
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Getting started using the API with Linux

Post by Martyn »

We have updated our Linux support, please check

http://www.picotech.com/linux.html

where you will find details of Picoscope 6 software for Linux.
Martyn
Technical Support Manager

mala
Newbie
Posts: 0
Joined: Fri Mar 21, 2014 8:42 pm

Re: Getting started using the API with Linux

Post by mala »

Thanks! I had "libps2000" installed but wasn't sure how to use it. Looking at the files it installed, it seems I should be looking in /opt/picoscope/share/doc/libps2000. I shall explore in there and report back.

EDIT: lovely! It works a charm.

rcox
Newbie
Posts: 0
Joined: Wed Apr 09, 2014 10:15 pm

Re: Getting started using the API with Linux

Post by rcox »

Mala, I ran into the exact same thing as you did, but I don't quite understand how you solved it from your comment. Can you elaborate?

make all-am
make[1]: Entering directory `/home/virtjoule/Documents/PS2000Con-Linux'
gcc -g -O0 -Wall -o ps2000con PS2000con.o
PS2000con.o: In function `set_defaults':
/home/virtjoule/Documents/PS2000Con-Linux/PS2000con.c:277: undefined reference to `ps2000_set_ets'
/home/virtjoule/Documents/PS2000Con-Linux/PS2000con.c:281: undefined reference to `ps2000_set_channel'
PS2000con.o: In function `set_trigger_advanced':
/home/virtjoule/Documents/PS2000Con-Linux/PS2000con.c:329: undefined reference to `ps2000SetAdvTriggerChannelConditions'
/home/virtjoule/Documents/PS2000Con-Linux/PS2000con.c:330: undefined reference to `ps2000SetAdvTriggerChannelDirections'
/home/virtjoule/Documents/PS2000Con-Linux/PS2000con.c:336: undefined reference to `ps2000SetAdvTriggerChannelProperties'
/home/virtjoule/Documents/PS2000Con-Linux/PS2000con.c:365: undefined reference to `ps2000SetAdvTriggerDelay'
PS2000con.o: In function `collect_block_immediate':
......

mario_
Site Admin
Site Admin
Posts: 112
Joined: Fri Sep 13, 2013 12:57 pm

Re: Getting started using the API with Linux

Post by mario_ »

Hi rcox,

It looks like you don't have ps2000.h header in the path. By default it is installed in /opt/picoscope/include/libps2000-2.1. (Assuming, you use the latest package?)

The example in /opt/picoscope/share/doc/libps2000 uses autotools to configure that, have a look to get the idea. Otherwise you could specify this path by adding following to compiler options:

Code: Select all

-I /opt/picoscope/include/libps2000-2.1
Further you may need to add library options to link the right one:

Code: Select all

-L /opt/picosope/lib -lps2000

Mario

rcox
Newbie
Posts: 0
Joined: Wed Apr 09, 2014 10:15 pm

Re: Getting started using the API with Linux

Post by rcox »

I got it going with a few changes. After rebuilding an Ubuntu 13.10 server from scratch on VMWare, I apt-get'd the build essentials, autoconf, unzip, and dos2unix. I installed the picoscope app for my 2204A via the instructions in: http://www.picotech.com/linux.html

sudo bash -c 'echo "deb http://labs.picotech.com/debian/ picoscope main" >/etc/apt/sources.list.d/picoscope.list'
wget -O - http://labs.picotech.com/debian/dists/p ... se.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install picoscope

Since I have 2204A, I installed the library driver via instructions:

sudo apt-get install libps2000

From http://www.picotech.com/drivers.html I selected the SDK for C and Picoscope 2204 and downloaded that zip.
I unzipped that SDK which produced the root directory with a PS2000Con-Linux directory in it along with a ps2000.h directory in the root of that unzip.

cd'd to the Linux directory.
Executed dox2Unix on the autogen.sh, Makefile.am, and the other files in there. Not doing so gets \r errors due to pc formatting.
Made autogen.sh executable
chmod +x autogen.sh

./autogen.sh

Then attempted to build it:

make

This is the point where you first run into problems loading the ps2000.h file:
----------------------------------------------------------------------------------------------------
gcc -DHAVE_CONFIG_H -I. -g -O0 -Wall -MT PS2000con.o -MD -MP -MF .deps/PS2000con.Tpo -c -o PS2000con.o PS2000con.c
PS2000con.c:64:34: fatal error: libps2000-1.0/ps2000.h: No such file or directory
#include
^
compilation terminated.
-----------------------------------------------------------------------------------------------------

It should be noted that the ps2000.h that comes with the SDK is not the same as the one in /opt/picoscope/include/libps2000-2.1.

nano PS2000.c
- took out the directory prefix on ps2000.h and saved it

nano Makefile
- Found DEFAULT_INCLUDE directive and added -I my root directory for the SDK where ps2000.h resides. I had unzipped that SDK in a directory called ~/Documents/pico
DEFAULT_INCLUDES = -I /home/myloginname/Documents/pico/

Now when I make it I get PS2000.c compiled with a couple of warnings which are ok.

The Makefile moves on to link with a command: gcc -g -O0 -Wall -o ps2000con PS2000con.o

This is where all the errors came from in my original post:

gcc -g -O0 -Wall -o ps2000con PS2000con.o
PS2000con.o: In function `set_defaults':
/home/virtjoule/Documents/pico/PS2000Con-Linux/PS2000con.c:277: undefined reference to `ps2000_set_ets'
/home/virtjoule/Documents/pico/PS2000Con-Linux/PS2000con.c:281: undefined reference to `ps2000_set_channel'
PS2000con.o: In function `set_trigger_advanced':
/home/virtjoule/Documents/pico/PS2000Con-Linux/PS2000con.c:329: undefined reference to `ps2000SetAdvTriggerChannelConditions'
/home/virtjoule/Documents/pico/PS2000Con-Linux/PS2000con.c:330: undefined reference to `ps2000SetAdvTriggerChannelDirections'
/home/virtjoule/Documents/pico/PS2000Con-Linux/PS2000con.c:336: undefined reference to `ps2000SetAdvTriggerChannelProperties'
/home/virtjoule/Documents/pico/PS2000Con-Linux/PS2000con.c:365: undefined reference to `ps2000SetAdvTriggerDelay'
.....

So the problem here is that the library isn't being linked. Your suggestion of adding -L /opt/picoscope/lib -lps2000 does work.

If I manually copy the command that Make tried to do and then add those library directives on the end, it does link:

gcc -g -O0 -Wall -o ps2000con PS2000con.o -L /opt/picoscope/lib -lps2000

and my program is finally built. Martin, I believe you had an earlier topic in the forum that discussed a transition where the -L -l options had to come at the end of the line. The current build scripts do not do this and they don't work because of that problem.

I didn't go back and fix the Makefile for this, I just took the executable and ran with it, but wanted to get this down in writing for my own benefit and perhaps it might help someone else. I suspect there may have been some cooler Linux/Unix ways to get this done, but it worked for me.

So to summarize, I had to make sure the ps2000.h that was being used was the one from the SDK and the library was from the picoscope install.

chubby23280
User
User
Posts: 4
Joined: Wed Apr 22, 2020 11:06 am

Re: Getting started using the API with Linux

Post by chubby23280 »

Hi,

I had a similar problem when running autogen.sh. I got the following error:

checking libps2000-2.1/ps2000.h usability... no
checking libps2000-2.1/ps2000.h presence... no
checking for libps2000-2.1/ps2000.h... no
configure: error: libps2000-2.1/ps2000.h missing!

I had a look in my /opt/picoscope/include/ folder and found that the relevant folder was named "libps2000" and not "libps2000-2.1". So, I used a text editor to change the following section of configure.ac from the linux-build-files from:

AC_CHECK_HEADER([stdio.h])
AC_CHECK_HEADER([sys/types.h])
AC_CHECK_HEADER([termios.h])
AC_CHECK_HEADER([sys/ioctl.h])
AC_CHECK_HEADER([libps2000-2.1/ps2000.h], [],
AC_MSG_ERROR([libps2000-2.1/ps2000.h missing!]))

to:

AC_CHECK_HEADER([stdio.h])
AC_CHECK_HEADER([sys/types.h])
AC_CHECK_HEADER([termios.h])
AC_CHECK_HEADER([sys/ioctl.h])
AC_CHECK_HEADER([libps2000/ps2000.h], [],
AC_MSG_ERROR([libps2000/ps2000.h missing!]))

I also changed the header in ps2000Con.h from #include "libps2000-2.1/ps2000.h" to #include "libps2000/ps2000.h" (I'll also use this for any future .c programs).

This seemed to work for me anyway so hopefully its helpful.

Post Reply