Yun Serial connection between Arduino and Linux

So, I am doing research with the Yun for college, and I am trying to read data in from the pins using the Arduino and then pass that to Linux so I can use python to send the data over wifi to a RPI. All solutions for this point towards the bridge connection, so I studied it and then realized that it is communicating via HTTP.

I have found plenty of tutorials for doing this on the Arduino side, but not on the linux side. How would I get python to read data in from this?

But a more important question is... Why? Why is this communicating through HTTP? This is a circuit board with the processors close together. Isn't there some way to communicate through serial that doesn't involve setting up a client on both ends? This seems so overly complicated.

Accepting HTTP connections, as shown in the Bridge tutorial, is but one facet of the Bridge library. (And probably the least useful and least efficient facet.) It is intended for accepting incoming connections from the greater network, not necessarily the local Linux processor.

The Bridge library is a collection of different classes that perform a variety of operations, all over the serial link between the two processors, and all can be used at the same time. The Bridge uses a network port paradigm, not HTTP. Using ports gives it a little more overhead, but it allows multiple simultaneous "connections" between the sketch and Linux sides.

I suggest you take a look at the Process tutorial. It does what you want, and 95% of the time it is the only part of the Bridge library that I use. The example defines Process objects that are local to a function, which run simple commands that do a little bit different f processing, return a result, and then exit.

My projects typically define a global Process object which starts a Python script, and keeps the connection open. Once open, the sketch can write to the Process object at any time, and the Python script reads that data from STDIN. Python can write to STDOUT at any time, and the sketch can read it from the Process object. The Process class derives from the Stream class, just like Serial, so your sketch can use any of the read/write methods you would use for a serial port. On the Linux side, you are just reading/writing as you would to the console. By default, Pythons runs in a buffered mode: I've found that you need to add the -u option to the command line that runs your Python script, or add it to the hashbang at the beginning of your script.

There are those who disable the Bridge library, and use the serial port manually on both sides. This can be done, but I've not had to resort to that yet. The Process class does everything that a direct serial connection can do, and more: you can have multiple simultaneous Process connections going, and you can still use all of the other Bridge library features. If you disable the Bridge library, you get just the one connection stream. It would be a bit more efficient, but unless you are dealing with high amounts of data, I'll bet you don't need to do that.

My typical project has the sketch running as a rather dumb I/O processor, passing barely digested input data down though one or more Process objects to a Python script. The Linux side does all of the heavy processing and network communications, and then sends output data back up the sketch which outputs it to the pins.