jmlynesjr has asked for the wisdom of the Perl Monks concerning the following question:

I am looking at buying a budget O-Scope. I asked on chipkit.net if anyone had any experience with any of these products(Rigol or Owon). One poster recommended looking at the Digilent Inc. Analog Discovery USB O-Scope/Logic Analyser.

This looks like a nice product, but the GUI is only supported on Windows, while I am an Ubuntu user. There is an SDK available for Linux provided as a header file and a shared library. Several non-GUI Python examples are also provided along with a .py file of the constants defined in the header file.

Before I spend the $279 USD for this device, I'd like a feel for what it would take to wrap this shared library for use in a Perl/wxPerl GUI application. I have seen references to h2xs and Inline::C. The Inline::C::Cookbook shows this example:

use IO::All; use Inline::C => sub { io('allheaders.h')->all =~ s/LEPT_DLL extrn/gr }, enable => "autowrap", libs => '-lleptonica';

Is it really that simple? Just substitute my library and header files? Are the constants within the header file also wrapped? Is any kind of xs source file produced that can be reviewed?

Thanks in advance.

James

There's never enough time to do it right, but always enough time to do it over...

Replies are listed 'Best First'.
Re: Digilent Inc. Analog Discovery
by bitingduck (Deacon) on Jun 12, 2015 at 04:08 UTC

    I don't have experience with that specific device, but I recently built up a Ubuntu based instrument using a bunch of USB boards for A/D, D/A, DIO, and temperature IO and relays. All the devices were marketed for the Windows world, but either had linux drivers downloadble or pointers to drivers someone else had made for their hardware for linux, and it all worked pretty well (most of it was from measurement computing). I did a kind of kludgy thing for debugging speed (since I didn't need high speed IO, and was on a really tight schedule) and compiled little atomic chunks of the C code that did the basic functions, then wrote perl modules to call them.

    The board you're looking at is really just a multi-function IO board-- it's got 2 A/D channels, 2 D/A, and a bunch of digital IO-- there are lots of boards that will do this. What looks nice about that one from Digilent is price/performance, especially if you can get the student deal ($99!), for a 100 Mhz board. But it won't really be an oscilloscope out of the box. The software is really what gives it the scope features.

    If what you want is a budget oscilloscope for dealing with other projects, it looks like there are a fair number out there in the ~$300 range, and you can get new or used ones on ebay. If you want an inexpensive high performance multifunction board that you can use as a scope if you wrap some of your own software around it, it looks like a pretty good deal, and I would guess that the library does work out fine.

      Thank you for the feedback bitingduck!

      Unfortunately I haven't been a "student" for about 40 years!. I am considering asking Digilent for a freebe or student rate in exchange for posting whatever GUI front end I come up with on Linux/Perl/wxPerl. I think $279 is too much to pay for a device I can't use out of the box.

      The Rigol at $329 looks pretty good for a stand alone O-Scope and an additional consideration is it wouldn't require my laptop to be connected for general use. But, the Analog Discovery device would make a fun project!

      James

      There's never enough time to do it right, but always enough time to do it over...

Re: Digilent Inc. Analog Discovery
by cavac (Prior) on Jun 12, 2015 at 12:42 UTC

    Did something like this (but for U2F authentication). It's not that hard, but depending on the library you Do have to play around with C code a bit.

    Thankfully, most libraries also come with a open source example on how to use them, most likely some test program that let's you exercise all (or most) hardware function.

    So, first thing i usually do is to write a small, low level wrapper library around the original library by hacking up the example code. This will give me the option of abstracting away stuff like memory managment.

    On this, my low level wrapper library, i run h2xs to turn it into a low level Perl module. Depending on what i want to do with that, most of the time i create a high level Perl module around THAT to have nice and easy access.

    You can kind of see that in Crypt::U2F (which reminds me i have to fix some things and release a new version).

    If there's interest, i'll be willing to write up a step-by-step description as a meditation. (Since it's a lot of work, knowing that there is at least one interested reader would be nice).

    "For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."

      cavac, I am an interested reader! I have read the h2xs man page. It's a little cryptic with many options. I haven't tried to run it yet. I will look at Crypt::U2F in a few minutes.

      The shared library(libdwf.so.2.7.5) has 80 +/- functions and the header file(dwf.h) defines many constants. A custom USB driver is also provided. This driver has been tested on Ubuntu up to 12.xx, so it should be ok on my 14.04 system.

      Thank you for your

      James

      There's never enough time to do it right, but always enough time to do it over...

        The cross-platform software, WaveForms3 is under development:
        https://forum.digilentinc.com/topic/98-waveforms3-beta/

        Ok, i'll do my best to come up with a step-by-step walkthrough on how to h2xs a small library. May take a few days, though, what with the weekend comming up and all (my office at home isn't climate controlled and it's a gazillion degrees out there).

        Will post here when i'm finished.

        "For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."