Radio and PodcastRadio and PodcastLive Radio & Podcasts
Using Perl to read Linux events artwork
Technology

Using Perl to read Linux events

BeagleBoard by Jason Kridner, Gerald Coley and Jeffery Osier-Mixon

Feb 28, 2011Technology

For a simple demo that played a movie on a BeagleBoard, I wanted to add a simple mechanism to start the movie over again if the USER button was pressed. To read a Linux input event, it is as simple as just performing a r...

About This Episode

Using Perl to read Linux events is an episode from BeagleBoard by Jason Kridner, Gerald Coley and Jeffery Osier-Mixon. For a simple demo that played a movie on a BeagleBoard, I wanted to add a simple mechanism to start the movie over again...

Podcast

This episode belongs to BeagleBoard.

Listen Online

Audio availability depends on the podcast feed.

Episode Details

Published Feb 28, 2011.

Questions About This Episode

What is Using Perl to read Linux events about?

For a simple demo that played a movie on a BeagleBoard, I wanted to add a simple mechanism to start the movie over again if the USER button was pressed. To read a Linux input event, it is as simple as just performing a read. The only trick to this for me, however, is that I wanted the read to timeout. This was resolved by using the Perl alarm() function can catching the signal within an eval(). I've uploaded a gist of my example play_movie.pl script: #!/usr/bin/perl $ENV{'DISPLAY'} = ":0.0"; system("xhost +"); ("totem --quit"); ("nice -n -5 totem --fullscreen /home/root/playlist.xml &"); $cmdline_start = "nice -n -5 mplayer /home/root/*.mov &"; system($cmdline_start); open(FILE, "/dev/input/event0"); binmode(FILE); while(1) { eval { local $SIG{ALRM} = sub { die("Alarm!\n") }; alarm(60*28); # 28 minutes read(FILE, $buf, 16); alarm(0); }; if($@) { printf("Restarting due to timeout\n"); ("totem --next"); system("killall -15 mplayer"); sleep(1); system("killall -9 mplayer"); sleep(1); system($cmdline_start); } else { ($time1, $time2, $type, $code, $value) = unpack("iissi", $buf); printf("%f %05d %05d 0x%08x\n", $time1+$time2/1000000, $type, $code, $value); if($code == 276 && $value == 1) # USER button pressed { printf("Restarting due to USER button press\n"); ("totem --next"); system("killall -15 mplayer"); sleep(1); system("killall -9 mplayer"); sleep(1); system($cmdline_start); } } }

Where can I listen to Using Perl to read Linux events?

You can listen to Using Perl to read Linux events online on Radio and Podcast. Open the player on this page to stream the available audio.

Which podcast is Using Perl to read Linux events from?

Using Perl to read Linux events is an episode from BeagleBoard by Jason Kridner, Gerald Coley and Jeffery Osier-Mixon.

How long is this episode?

The episode duration depends on the source podcast feed and may not always be available.

When was this episode published?

This episode was published on Feb 28, 2011.

Can I save Using Perl to read Linux events for later?

Yes. Use the heart button on the episode page to add it to your favorite episodes list.

Are there related episodes from BeagleBoard?

Yes. This page shows related episodes from BeagleBoard when more episodes are available from the podcast feed.

Quick Answers About This Episode

Where can I listen to Using Perl to read Linux events?

You can listen to Using Perl to read Linux events on this page when the episode audio is available from the podcast feed.

Which podcast is this episode from?

Using Perl to read Linux events is from BeagleBoard by Jason Kridner, Gerald Coley and Jeffery Osier-Mixon.

What are the episode details?

Published Feb 28, 2011