3

I am relatively new to the Raspberry PI platform and more experienced with Arduino.

I have noticed in the examples for Infrared Receiving and 1-Wire protocol that the Python sketches to interact with these protocols revolve around native operating system support (like LIRC and reading from the /devices file.

Is this common in Raspberry PI?

Usually I like to access the GPIO sensors directly, in code, as opposed to reading files and pipes from the underlying file system.

I am wondering if there is a reason there aren't more direct libraries for things interface / protocol control.

So, phrased as a question: Why does Raspberry Pi rely so much on operating system support as opposed to direct python libraries to interface with 1Wire and IR ?

Startec
  • 297
  • 1
  • 3
  • 8

2 Answers2

6

The Raspberry Pi is generally used with an operating system. The most common is the Linux based Raspbian.

Linux is a multi-user, multi-tasking operating system. Many people may be using the Pi at any one time.

My idle Pi has 120 tasks running currently.

If all those tasks were allowed to access resources in an ad hoc fashion nothing would work. The operating system has to control and arbitrate accesses to resources. Resources being things like processing time, memory, files, GPIO, etc. etc.

The Arduino has no operating system and only one program runs at a time. It doesn't matter how that program accesses resources as there is nothing else running to care.

Stuggi
  • 268
  • 1
  • 2
  • 4
joan
  • 71,852
  • 5
  • 76
  • 108
0

I stumbled across this Question and while Joan's answer is correct and her libraries (generally) use socket and pipe interfaces; there are a great number of programs (in C, Python and occasionally other languages) which directly access the Pi peripheral hardware - usually GPIO pins.

Most programs use one of the libraries to access the hardware (just as most Arduino programs use libraries). See https://raspberrypi.stackexchange.com/a/117592/8697

This directly hardware access is generally frowned on by Linux purists (for good reasons) but on a single user device or embedded system there is little problem.

Milliways
  • 62,573
  • 32
  • 113
  • 225