Skip to content

Instantly share code, notes, and snippets.

@elijahc
Last active August 7, 2018 00:00
Show Gist options
  • Save elijahc/0880be06e83b044f5340c4c6031577c2 to your computer and use it in GitHub Desktop.
Save elijahc/0880be06e83b044f5340c4c6031577c2 to your computer and use it in GitHub Desktop.
ACTION=="add"
KERNEL=="sd?1", \
ATTRS{busnum}=="3", \
ATTRS{devpath}=="2", \
ENV{mount_point}=df "$env{DEVNAME}" | tail -1 | awk '{ print $6}'
SYMLINK+="bak_src", \
RUN+="/bin/rm /media/bak_src", RUN+="/bin/ln -s $env{mount_point} /media/bak_src"
ACTION=="remove"
KERNEL=="sd?1", \
ATTRS{busnum}=="3", \
ATTRS{devpath}=="2", \
RUN+="/bin/rm /media/bak_src"

Goal

Create raspberry pi device for backing up camera raw SD cards onto flash drives either in the field powered by battery or when plugged in

Reading from SD Card

Just use USB SD card reader

Configuration

How do we set params and/or configure the raspberry pi for certain tasks

None

Static config, have to have hooked up to monitor or ssh to change

Wifi webservice

Ideally could be turned on and off with a hardware button or BLE...

Setup a slick go webservice to be run on the raspberry pi for setting different params / options

Some examples of people doing this:

USB stick auto-copy

Use a hook/service kind of like retro-pie that would copy and merge config options from a file in a certain place on inserted USB media.

Interface Inputs

How does the raspberry pi know when to start copy over files from source to destination?

None

Have prescribed source, dest USB ports. Since all of these will be block devices, plug in device and find it in /dev

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 915.6G  0 part /
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0  15.9G  0 part [SWAP]
sdb      8:16   1  14.6G  0 disk 
└─sdb1   8:17   1  14.6G  0 part /media/elijahc/CHERRY
sr0     11:0    1  1024M  0 rom  

Then find it in /sys/class

$ tree /sys/class/block/
/sys/class/block/
├── sda -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/port-0:0/end_device-0:0/target0:0:0/0:0:0:0/block/sda
├── sda1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/port-0:0/end_device-0:0/target0:0:0/0:0:0:0/block/sda/sda1
├── sda2 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/port-0:0/end_device-0:0/target0:0:0/0:0:0:0/block/sda/sda2
├── sda5 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/port-0:0/end_device-0:0/target0:0:0/0:0:0:0/block/sda/sda5
├── sdb -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/host10/target10:0:0/10:0:0:0/block/sdb
├── sdb1 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/host10/target10:0:0/10:0:0:0/block/sdb/sdb1
└── sr0 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host1/target1:0:0/1:0:0:0/block/sr0

Detect when SD card is inserted and when USB drive is inserted

Use GPIO

Use python or other listeners to detect when switches or buttons have been pressed https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/

Pro's

  • Don't need power

Use USB remote

https://www.amazon.com/slp/raspberry-pi-3-remote/xjww5q3ee4j9887 http://averagemaker.com/2015/05/7-remote-control-options-for-your.html

Use BTLE + Phone App

https://medium.com/@superlopuh/raspberry-pi-ios-communication-in-bluetooth-c7599e257f2

Interface outputs

It would be convenient for the device to communicate to the user since it will be slow and we will often have to wait for things to be ready and/or done

Things useful to communicate to user:

  • When is the pi ready?
  • When has it started?
  • When has it finished?

None

GPIO LED's

E-Ink display

Seems most straightforward, can communicate configuration, status. Could also build this on top of simple defaults option

Todo:

  • Flash clean SD with raspbian
  • Experiment with creating udev rules
  • Prototype rdiff-backup script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment