133

It finally hit me the other day.
I'm working on an IoT project for a late-stage ALS patient. The setup is that he has a tablet he controls with his eye movements, and he wants to be able to control furnishings in his room without relying on anyone else.
I set up a socket connection between his tablet and the Raspberry Pi. From there it was a simple matter of using GPIO to turn a lamp or fan on or off. I did the whole thing in C, even the socket programming on the Pi.
As I was finishing up the main control of the program on the Pi I realized that I need to be more certain of this than anything I've ever done before.
If something breaks, the client may be forced to go days without being able to turn his room light on, or his fan off.
Understand he is totally trapped in his own body so it's not like he can simply turn the fan off. The nursing staff are not particularly helpful and his wife is tied up a lot with work and their two small children so she can't spend all day every day doting on him.
Think of how annoying it is when you're trying to sleep and someone turns the light on in your room; now imagine you can't turn it off yourself, and it would take you about twenty minutes to tell someone to turn it off -- that is once you get their attention, again without being able to move any part of your body except your eyes.
As programmers and devs, it's a skill to do thorough testing and iron-out all the bugs. It is an entirely different experience when your client will be depending on what you're doing to drastically improve his quality of life, by being able to control his comfort level directly without relying on others -- that is, to do the simplest of tasks that we all take for granted.
Giving this man some independence back to his life is a huge honor; however, it carries the burden of knowing that I need to be damned confident in what I am doing, and that I have designed the system to recover from any catastrophe as quickly as possible.

In case you were wondering how I did it all: The Pi launches a wrapper for the socket connection on boot.
The wrapper launches the actual socket connection in a child process, then waits for it to exit. When the socket connection exits, the wrapper analyzes the cause for the exit.
If the socket connection exited safely -- by passing a special command from the tablet to the Pi -- then the wrapper exits the main function, which allows updating the Pi. If the socket connection exited unexpectedly, then the Pi reboots automatically -- which is the fastest way to return functionality and to safeguard against any resource leaks.
The socket program itself launches its own child process, which is an executable on the Pi. The data sent by the tablet is the name of the executable on the Pi. This allows a dynamic number of programs that can be controlled from the tablet, without having to reprogram the Pi, except for loding the executable onto it. If this child of the socket program fails, it will not disrupt its parent process, which is the socket program itself.

Comments
  • 29
    Don't worry you are doing great Work. I work for a company that writes aviation Software so I can't have bugs to :)
  • 4
    What are you using for comms - WiFi? Did you consider using something lower level like a Nordic SoC instead for more realtime latency and safety? How about MISRA-C?
  • 14
    Wow, that's really incredible.....congrats on being awesome ☺
  • 2
    You sir have my respect.
  • 2
    Great project - let me know if you need any Azure help. Pi could send statuses to cloud as additional check or feedback from customer.
  • 0
  • 0
    You, sir, are a true hero.
  • 8
    Delivery is next week, and I've been running the Pi with the connection software since yesterday to see if there is any errant activity. So far there is none.
    Fingers crossed!
  • 0
    help him... what could go wrong? worst case scenario!

    What happens when there is a power outage will your system be back online once the power is restored?

    did you consider an braininterface?
  • 1
    @heyheni Everything is automated, so the socket opens and is ready to go mere seconds after the Pi boots up.
  • 3
    Update: 3 Days up and running, still no errant activity! (the socket program logs all connections and commands given to it, that's how I know)
    Socket program is still working, and the Pi has not rebooted at all. Looking very good for delivery next week!
  • 4
    @iNCEPTiON That brings up memories about my programming teacher. For each little error/bug/glitch he looked someone dead serious into the eyes and said: "And the plane crashed. Good work!"... Such a wonderful teacher (i am serious)
  • 1
    @lorki97 What a nice teacher...:)
    Sometimes I can test the software in a Airbus Sim only to stall after 5 min. ; ) Don't worry flying is save! ;;)
Add Comment