0

I have a small robot which runs on a raspberry pi.

I need to be able to control it with an RF remote to trigger a few different terminal commands which run short python scrips.

Previously I did this with a GUI on my macbook, triggering these commands over ssh, but I now need to be able to trigger them in the absence of an internet connection.

The remote I bought is: https://www.adafruit.com/products/3092?gclid=CNPj7LjTgNECFdOPswodsiULYA I realize that this is designed for OSMC.

This remote shows up as a USB keyboard on the Pi, which makes the challenge more general:

* - How could one rig a 'USB keyboard device' to trigger entire terminal commands with the click of one key?*

My low-level knowledge of hardware is limited, and my programming experience extends little beyond python.

Any direct solution or suggested reading is much appreciated.
I am also open to alternatives, however I do not have time to order new hardware online.

perl598
  • 1
  • 1
  • Mmm....creating a client app that listen to specific keyboard events? – Hackerman Dec 19 '16 at 17:06
  • @Hackerman Thanks for the suggestion. I've never done something like this. Where would you recommend I start? – perl598 Dec 19 '16 at 22:17
  • Maybe with a combination of this two topics: http://shahmirj.com/blog/beginners-guide-to-creating-a-daemon-in-linux and http://stackoverflow.com/questions/17501014/how-to-handle-key-press-events-in-c – Hackerman Dec 19 '16 at 23:28

1 Answers1

0

You could write a python script which uses the 'os' library to interact with the terminal, have it looking for certain keystrokes and then writing the relevant commands to the terminal via os.

e.g

if (KEY == "F"):

 os.system("cd Dropbox")

I have no idea how to do formatting here, but you get the idea.

Ben Bird
  • 374
  • 1
  • 5
  • 16
  • I'm familiar with os library but I'm not sure how to have it return keystroke values. any advice? – perl598 Dec 22 '16 at 00:02
  • python raw_input should do that for you - http://stackoverflow.com/questions/5563089/raw-input-function-in-python – Ben Bird Dec 30 '16 at 23:02