Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: XS, raspberry pi, and a hundred bucks

by stevieb (Canon)
on Nov 01, 2021 at 14:36 UTC ( #11138296=note: print w/replies, xml ) Need Help??


in reply to XS, raspberry pi, and a hundred bucks

Hi Aldebaran,

Thanks for buying the book! :)

Buy a Pi 3 and a NoIR Camera Board v2. Make sure you've got a 2.1A USB charger plug with a good quality cable. You'll also need a good micro SD card. Mine all range from 16-64GB. Spend a little more here; a quality card makes a difference. All in all, you should be right there in around $100.

I learned XS over time and don't remember the reading I did. WiringPi, which is the backend to RPi::WiringPi which the Raspberry Pi book is based on is an XS module. Most of the code wraps an external C/C++ library, but there is some XS involved. A very trivial XS module I've written is Bit::Manip. There's not much XS there either, but it's a good example of how to present C functions to Perl code, how the files all hang together and such.

Happy travels,

-stevieb

  • Comment on Re: XS, raspberry pi, and a hundred bucks

Replies are listed 'Best First'.
Re^2: XS, raspberry pi, and a hundred bucks
by perlfan (Vicar) on Nov 01, 2021 at 16:21 UTC
    Inline::C is a very nice way to introduce compiled libs, if you're doing C stuff. It handles a lot of situations including presenting interface to shared libraries, if needed. There are other FFIs out there, and XS is also the most fundamental option.

      I usually use Inline::C for initial prototypes and quick one-off tests before I write an actual XS module. I never want a user to have to require Inline.

        Check out Inline::Module. It lets you develop using Inline and then package it in a way that all the Inline compilation happens during Makefile.PL and then the resulting installed module doesn't require Inline.

        It's a bit of effort to learn, but I got it working in OpenGL::Sandbox, even packaged up with Dist::Zilla!

        That seems fair - mind explaining why? I am only asking for my own edification. I've written exactly one XS module on CPAN, and I had a lot of help; but I can say for sure that any use of Inline::C has not been for anything I plan to distribute broadly. That said, the one difference I can see between the 2 is that XS modules are compiled once on install; Inline::C run the risk of being recompiled if the cache goes away - usually at an inopportune time.
Re^2: XS, raspberry pi, and a hundred bucks
by Aldebaran (Curate) on Nov 09, 2021 at 08:40 UTC
    Thanks for buying the book! :)

    Youbetcha.

    Buy a Pi 3 and a NoIR Camera Board v2. Make sure you've got a 2.1A USB charger plug with a good quality cable. You'll also need a good micro SD card. Mine all range from 16-64GB. Spend a little more here; a quality card makes a difference. All in all, you should be right there in around $100.

    I got a pi 3B+, NoIR Camera Board v2, 3000 mA power, 32 gig micro sd card. I can hardly believe that it already works. I did not fdisk the sd card as it was already loaded with a perfectly-good unix. Output is vivid and quick.

    I learned XS over time and don't remember the reading I did. WiringPi, which is the backend to RPi::WiringPi which the Raspberry Pi book is based on is an XS module. Most of the code wraps an external C/C++ library, but there is some XS involved. A very trivial XS module I've written is Bit::Manip. There's not much XS there either, but it's a good example of how to present C functions to Perl code, how the files all hang together and such.

    It was very helpful for me to work through the first 2 examples, EX-1. XS interface description is comprehensive, and difficult. Before this, I never understood what was happening in the command:

    h2xs -A -n Mytest

    It finally covers page 176 of Intermediate Perl to work through it.

    Regarding the install, things are moving forward pretty well, but I have run into my first roadblock. I'm getting 404's beginning with this guy:

    libgstreamer-plugins-base1.0-dev

    and it tanks whatever is to follow.

    E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/ +g/gst-plugins-base1.0/gir1.2-gst-plugins-base-1.0_1.14.4-2_armhf.deb + 404 Not Found [IP: 93.93.128.193 80] E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/ +g/gst-plugins-ugly1.0/gstreamer1.0-plugins-ugly_1.14.4-1_armhf.deb 4 +04 Not Found [IP: 93.93.128.193 80] E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/ +g/gst-plugins-base1.0/libgstreamer-plugins-base1.0-dev_1.14.4-2_armhf +.deb 404 Not Found [IP: 93.93.128.193 80] E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/ +g/gst-plugins-bad1.0/gir1.2-gst-plugins-bad-1.0_1.14.4-1+b1_armhf.deb + 404 Not Found [IP: 93.93.128.193 80] E: Unable to fetch some archives, maybe run apt-get update or try with + --fix-missing? pi@raspberrypi:~ $ sudo apt-get update Hit:1 http://archive.raspberrypi.org/debian buster InRelease Get:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 +kB] Reading package lists... Done E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelea +se' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository + can be applied. See apt-secure(8) manpage for details.
    Update:

    I've isolated the commands that result in 404-errors:

    sudo apt-get install gstreamer1.0-plugins-ugly sudo apt-get install gir1.2-gst-plugins-bad-1.0 sudo apt-get install gir1.2-gst-plugins-base-1.0 sudo apt-get install libgstreamer-plugins-base1.0-dev

    Since the problem seems to be in the plugins department, I thought I might be able to get away with autogen.sh, but no dice:

    checking for GST... no configure: error: You need to install or upgrade the GStreamer development packages on your system. On debian-based systems these are libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev. on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel or similar. The minimum version required is 1.0.0. configure failed

    I think this brands me as a debian user:

    $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster $ cat /etc/apt/sources.list deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non- +free rpi # Uncomment line below then 'apt-get update' to enable 'apt-get source +' #deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib + non-free rpi $

    I took a look around to see what what I could checking both gst-plugins-base1.0 and gstreamer. I seem not to have a lot of elbow grease when it comes to distributions, if it veers off the main path....

    Q1) Do I look for newer versions or change my settings?

    Thx all for comments,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-01-16 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (49 votes). Check out past polls.

    Notices?