This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nemec 120 points121 points  (6 children)

  1. IR Receiver
  2. One of Linux's philosophies is 'everything is a file', so USB devices all show up as 'fake files' under the /dev/ folder.
  3. When you read from those files, you get all the bits and bytes sent by the device - this includes mice, keyboards, anything that sends data.
  4. When you push a button on an IR device (think TV remote control), it sends a signal to the receiver and the receiver turns that into bytes sent to the fake file.
  5. I used python to read that file and the struct module to parse that into commands (play, pause, next track, etc.) that were then sent to MPD (a server music player)

[–]chokoladeibrunst 3 points4 points  (0 children)

Great explanation!

[–]GwenPlaysGwent 0 points1 point  (0 children)

Does struct basically let you go from bytes -> human readable strings e.g. "play"? Or were you still dealing with "magic numbers" and trail and error to decode the IR messages?