As sonnyyu said, pyserial is one of the available packages for the Yun. BTW there are more than 3000 of them, chances are what you need is ready to be installed. And if it's not, request it on github [1]
opkg update
opkg install python-openssl #adds ssl support to python
opkg install distribute #it contains the easy_install command line tool (this can take some time)
easy_install pip #installs pip (this can take some time)
#easy_install -m pyserial #remove it
cd /mnt/sda1
wget https://pypi.python.org/packages/source/p/pyserial/pyserial-2.7.tar.gz#md5=794506184df83ef2290de0d18803dd11
tar zxf pyserial-2.7.tar.gz
cd pyserial-2.7
python setup.py install
This allow you install latest version of pyserial-2.7 or the version you like!
Did the opkg version fail?
By the commands you used it looks like you're using the old image. Please upgrade it ASAP following the link in my signature. A list of improvements in available in the sticky topic "Please upgrade your Yun" Please upgrade your Yún - latest is 1.3 - Arduino Yún - Arduino Forum
Only a few times it works.
I commented line of ttyATH0::askfirst:/bin/ash --login on /etc/inittab
YUN Code (YUNSerialTerminal mod)
long linuxBaud = 9600;
void setup() {
Serial.begin(115200); // open serial connection via USB-Serial
Serial1.begin(linuxBaud); // open serial connection to Linux
}
void loop() {
// copy from virtual serial line to uart and vice versa
if (Serial.available()) { // got anything from USB-Serial?
char c = (char)Serial.read(); // read from USB-serial
Serial.print("Char: ");
Serial.println(c);
Serial1.print(c); // otherwise write char to Linux
}
}
Python Code
import serial
ser = serial.Serial ('/dev/ttyATH0',9600 )
while True:
print ser.readline()
It depends on the device you're plugging to the you, but you'll need additional kernel modules for talking to another Arduino (say a UNO) plugged to the yun. Try
the linino(UBS host) <-> FDTI is working. I can read in the python console the Strings coming up from the FTDI, what I cant make it work is the Arduino<-> linino communication.-
edit: Commenting the line in inittab seems to work. Can I change the serial1 port as MAMU suggested so I leave inittab as default??