1. 9

  2. 2

    I might be wrong, but if GPIO.input() does not block, that script will be basically an infinite read loop pegging a core to 100% all the time? Not even the usual time.sleep(0.1). Can’t an interrupt be used to block?

    1. 2

      I’m not particularly familiar with raspian (It’s not stated, but I think that’s what they’re running here?), but doesn’t rc.local execute their script as root, meaning that it shouldn’t need to use sudo?

      1. 2

        “Important safety tip”, but I’m nervous that this is needed at all. “Pulling the plug on your Raspberry Pi before it safely shuts down… is a bad idea! This can result in a corrupt microSD card and file system.” So Raspbian doesn’t use a durable enough filesystem that isn’t corruptible on power failures? 😬

        1. 2

          I’d recommend seeing Files by Dan Luu talk. But I probably wouldn’t trust the SD card to handle it properly either.

          That being said, I use my RPi as a playground for things, so I fearlessly pull the plug 😄

          1. 2

            The filesystem on my Rpi is ext4 according to /etc/fstab. I honestly don’t know how resistant that FS is to sudden power interrupts. I’ve been religious about running shutdown -h ever since I installed Debian from floppies on a 386…

            Edit I’ve read up a bit now (this article was a good resource) and I figure that ext4 should handle power being cut. But the root filesystem is usually a micro-SD card, and who knows how good the “connection” is there.

            Not to mention there’s a lot of cargo-culting around best practices for the Raspberry Pi… and the linked article wants to sell a hardware project.

            1. 2

              At $work, we use RPis for bespoke monitoring systems (aircon, refridgerators, doors, …) and initially went with the cheap microSD cards that shipped with the 3rd party kits we bought. They all died within the first year of operation (without being subjected to power outages). I suspect that those having problems with corrupted sdcards are in many cases just using cheap cards that would’ve died anyways, and power cuts just increase the chances of sdcard corruption.

              1. 1

                Thanks for the input! The card I got in my kit was branded “SanDisk” (who knows if it’s genuine though). What card or alternatives are you using now?

                1. 3

                  I don’t remember off-hand (we hadn’t had a single failure in years), but the ones we’re using now are “industrial”/“surveilance camera grade”. the packaging from “Transcend High Endurance” cards look familiar, but no guarantees ;)