Help with thinking through this


Forum: Other Help Topics
Topic: Help with thinking through this
started by: beakmyn

Posted by beakmyn on May 16 2007,12:46
So, I'm looking into ways to make my digital picture frame 'parent' friendly. I'd like to ultimately have it so that "mom or dad" could take the memory card out of their camera and plug it into a USB SD  adapter and DSL would magically mount the device, search it for jpegs and copy those jpegs to a pre-defined directory.

So far I know I probably need something like automount or similar and a some way for automount to call a script that copies the files off the drive to my picture drive.

There is something for that other OS
< http://www.dps.uk.com/freeware_transferer.htm >

in case you can't figure out what I'm trying to do. My version will not have a gui.

Since the copy operation would be in a script I could add aplay to play a "Files copied" wav to indicate the copy process was finished or maybe kill feh and start it back up pointing to a "finished" jpeg then timeout after 5 seconds.

But, that's all bells and whistles right now I'm trying to iron out the automgacial mount, copy, unmount part.

So is my idea far fetched or is there something that already does this that I can wedge into DSL?

Posted by mikshaw on May 16 2007,13:25
The only thing that might present a problem is the auto mount part. I still don't understand why people want this behavior so badly, but I guess that's a matter of opinion.

The first thing I'd suggest is searching these forums. There have been a number of DSL picture frame projects done, and I can remember at least one thread that was almost identical to this one several months ago.

Posted by beakmyn on May 16 2007,13:44
Quote (mikshaw @ May 16 2007,09:25)
The only thing that might present a problem is the auto mount part. I still don't understand why people want this behavior so badly, but I guess that's a matter of opinion.

The first thing I'd suggest is searching these forums. There have been a number of DSL picture frame projects done, and I can remember at least one thread that was almost identical to this one several months ago.

It was probably my project since I keep asking questions about it, and I don't believe anyone else has taken it as far as I have.

I understand your concerns about automount (I've read the posts) and I agree in a typical deployment there's no need for it.  However, this is a specific case where the system has no mouse or hard-drive and I can't very explain to "mom and dad" how to vnc into the frame and mount, copy, etc the pictures over. It needs to be easy for them. I am aware that it will see the device on bootup but I'd rather not have to make them shut it down and reboot in order to add new pictures (I have that script on my site). I hoping to make it as simple as they plug it in and it copies their pictures over and then gives some indication of progress, without rebooting.

My scripting abilities are sub-par at best. My thought is that automount would use far less system resources then anything I could write. I would cobble something together that would constantly poll the /dev and chew up what little RAM I have.

I'm more or less looking for someone to say the 'concept' is sound but you may have a problem with this or that and might I suggest you look into....

Posted by curaga on May 16 2007,13:58
Hey.. If there's no hd, then where do you copy pics into?

I like supermount over automount, umounting with it is plainly taking the device off, with automount you have to wait predefined seconds before pulling the stick, and 'cause automount counts from last operation, it could umount when that's not wanted...

But autorunning a script is hard. In M$ it's a security risk. ???
I don't have a clue on how to do it (not on DSL, but with Udev I've done similar things)
Maybe you could make a button labeled "copy images" or something?
Or use an existing reset/power button with acpid for that?

Posted by beakmyn on May 16 2007,14:54
It has a hard-drive, just no mouse or keyboard.

I did find a script

Code Sample

#!/usr/bin/perl

$ENV{PATH} = "$ENV{PATH}:/usr/bin";
$ENV{PATH} = "$ENV{PATH}:/bin";

$imgdir = "/mnt/hd/images";
$camdir = "$imgdir/camera";

   open DEVICES, "/proc/bus/usb/devices";
   undef $/;
   $olddevice = <DEVICES>;
   close DEVICES;


while (1) {
   open DEVICES, "/proc/bus/usb/devices";
   undef $/;
   $device = <DEVICES>;
   close DEVICES;
   if ($device ne $olddevice) {
$olddevice = $device;
print "usb device changed.\n";
system("kill -USR1 `cat /var/run/slideshow.pid`");
system ("cd $camdir; gphoto2 -P");
&scale_camera_images;
system ("killall fbi");
   }
   sleep 10;
}


sub scale_camera_images {
   opendir CAMERA, $camdir;
   @files = readdir CAMERA;
   for $f (@files) {
if ($f =~ m/jpg/i) {
   system ("jpegtopnm < $camdir/$f | pnmscale -xysize 1024 768 | pnmtojpeg > $imgdir/$f");
   unlink ("$camdir/$f");
   sleep 1; # keep processor from overheating!
}
   }
}
   


I see 2 options with this run it a boot so it's running all the time. After the frame really has 1 purpose so as long as feh keeps working then I don't neccesarily mind this thing running also

The other option would be to tweak it and have a cron job run it every 5 seconds.


Of course there is a 3rd option which is to put in a wireless card and have the frame use pictures from a network drive instead. Then they copy pictures from their camera whenever, similarily I could also use flickrframe if the frame has internet.

Right now I have to use PuTTY to access the frame and move pictures via a networked drive.

Posted by mikshaw on May 16 2007,18:51
I don't see any reason to put it on a cron job, since it would probably consume more resources that way. The script sleeps for 10 seconds between each run anyway, so it's essentially the same result from running fewer processes.
Posted by beakmyn on May 17 2007,12:34
Quote (mikshaw @ May 16 2007,14:51)
I don't see any reason to put it on a cron job, since it would probably consume more resources that way. The script sleeps for 10 seconds between each run anyway, so it's essentially the same result from running fewer processes.


Hopefully I'll have time to work on this, this weekend. I'll let you know how it turns out.
Ah, I didn't realize the sleep statement is seconds. I'm used to it being milliseconds. That makes sense then.

Posted by buzzard on May 20 2007,01:27
Quote (beakmyn @ May 16 2007,08:46)
So, I'm looking into ways to make my digital picture frame 'parent' friendly. I'd like to ultimately have it so that "mom or dad" could take the memory card out of their camera and plug it into a USB SD  adapter and DSL would magically mount the device, search it for jpegs and copy those jpegs to a pre-defined directory.

So far I know I probably need something like automount or similar and a some way for automount to call a script that copies the files off the drive to my picture drive.

There is something for that other OS
< http://www.dps.uk.com/freeware_transferer.htm >

in case you can't figure out what I'm trying to do. My version will not have a gui.

Since the copy operation would be in a script I could add aplay to play a "Files copied" wav to indicate the copy process was finished or maybe kill feh and start it back up pointing to a "finished" jpeg then timeout after 5 seconds.

But, that's all bells and whistles right now I'm trying to iron out the automgacial mount, copy, unmount part.

So is my idea far fetched or is there something that already does this that I can wedge into DSL?

Just a possibility here.....


The BASH script (looping.sh):

#!/bin/sh
while true; do
mount /dev/sda1 /mnt/hd && cp /mnt/hd/* /mnt/hda1
sleep 3
umount /mnt/hd &&  beep
sleep 15;
done;


the beep file (beep.c)  compile it using tcc:

main() {
printf("%c",7);
}


Have looping.sh start in your bootlocal.sh maybe? (with & after it)
might have to tweak the dir names...
It should keep going, even when no usb thing inserted, just declaring
"Oh, theres nothing there" over and over,
until someone inserts one.

I haven't actually tested looping.sh
but beep.c will beep
(note the &&... it should only beep if it loaded some files... hopefully.)

Oh, and when it beeps, you must remove the USB thing within 15 seconds.

:p

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.