How Too Peripherals Python Tutorials

Creating Mac shares on Raspberry Pi

Post Reply
raspberrypi / howtoo     Views: 531Prev .. Next
Creating Mac shares on Raspberry PiPosted: Tuesday, April 21, 2020 [12:28:55] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Trying to run gphoto2 shooting time-lapse using Raspberry Pi and saving images on Hard Drive.
Using RPi's MicroSD is one way of doing it, but saving them on external Hard Drive sometimes is a better option.

Connecting an Apple share is quite easy. First we need to install afpfs:
View Codesudo apt-get install fuse afpfs-ng


Then create a mount folder on Raspberry Pi:
View Codemkdir ~/YourMac
chmod og-rwx ~/YourMac


Then, before using it, just mount it:
View Codemount_afp afp://Your_Mac_User:Your_Mac_Password@Mac_IP_Address/Mac_HD /home/pi/YourMac
i.e.
mount_afp afp://user:[email protected]/root /home/pi/MacProShare

Creating Mac shares on Raspberry Pi
Once done using a share - unmount it:
View Codeumount /home/pi/YourMac


It works flawlessly as far as saving files to a mounted share, creating directories, deleting files etc.
One issue, though - if relative file name used - it may not work, but works every time when fully qualified file name used, i.e.
View Code~/YourMac/images/test.jpg - may not work
/home/pi/YourMac/images/test.jpg - works

Happy time-lapse shooting!There's no place like ~
Running a simple script to capturePosted: Tuesday, April 21, 2020 [14:30:32] - 2
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
This is a simple Perl script to capture images:
View Code#!/usr/bin/perl
my $dest='/home/pi/MacPro2010/testing';
unless(-d $dest) {`mkdir $dest`; print "Created folder $dest\n";}

while(1) { ## Infinite loop, to stop the capture press Ctrl + C
my $frdel = time; $frdel = localtime($frdel); $frdel =~ tr/ //s;
my($wdr,$mor,$dar,$tir,$yer) = split(/\s/,$frdel);
my($hr,$min,$sec) = split(/\:/,$tir);
print "/usr/local/bin/gphoto2 --capture-image-and-download "$dest/$mor.$dar.$yer.$hr.$min.$sec.jpg"\n";
`/usr/local/bin/gphoto2 --capture-image-and-download "$dest/$mor.$dar.$yer.$hr.$min.$sec.jpg"`;
sleep(5); ## Adjust delay accordingly
} ## WHILE LOOP END


Please keep in-mind - Apple share has to be mounted manually before running this script.
Make sure gphoto2 program is not running prior to starting the program by checking "ps axj" and use "kill -9 Process_ID" if necessary.

Also, you camera has to be set properly before running the program above. I.e. code in ticks has to run without any errors.
Check your camera and gphoto2 help files to make your camera run smoothly.There's no place like ~
raspberrypi / howtooPrev .. Next
 
Post Reply
Home - Raspberrypi: How Too Peripherals Python Tutorials
Our Telegram Group