Prerequisites:
1. Install pyserial on RaspberryPi
-
a. Download pyserial-2.5.tar.gz (106.3 kB)
b. unzipping and untaring
gunzip pyserial-2.5.tar.gz tar -xvf pyserial-2.5.tar
c. Install pySerial
cd pyserial-2.5 sudo python setup.py install
2.Testing
-
Saving following python CGI scripts to your CGI folder.
Filename: shows.py
#!/usr/bin/python
import os
ser = os.popen("sudo python stest.py").readlines()
# print "Content-Type: text/html"
# print
print ser[0]
print ser[2]
Filename: stest.py
#!/usr/bin/python
import serial
serialport = serial.Serial("/dev/ttyAMA0",9600,timeout=0.5)
serialport.write("\r")
response = serialport.readlines(None)
serialport.write("version\r")
response = serialport.readlines(None)
print response[1]
print response[2]
The python CGI script shows.py will acquire and return the Version Information of the Shell(This shell is a part of my real time operating system) which runs on the serial port of the STM32 MCU.