OHHH MYYYYY GOD! Thank you!
After struggling for a few days, unable to find a solution to Python – Raspberry Pi – Web2py (this triangle love, urgh), i have a little progress today!
Yesterday, i was able to log in to the home automation system through python right after my boss asked me about it. it is a bit ashamed when i told him, i’m sure it doesnt work but it did work when i tried it again.
So, is \x03 and is \x0D so here is my code in python console:
>>>serialport = serial.Serial(“/dev/ttyAMA0”, 9600, timeout=0.5)
>>>serialport.write(“\x03LI1234\x0D”) #LI1234 is the default log in
[‘\x03LU01\x0D’] # it returns “user 1 logged in”
Now what? writing this into my web2py application!
I seriously have no idea how to start and the documentation on web2py is 500 over pages and how am i suppose to find the exact information i need? in fact, i am not sure what information i need. I requested some notes from my senior (a national professional Archer, wow!) regarding “Web Applications Design”. Argh, it’s a pity that my prince charming hasn’t take that module
Okay, called myself an EEE undergraduate, who has zero knowledge in Java, Python, HTML, CSS, PHP, SQL, Apache, etc huh?
I doubt myself.
Anyway, i struggled for the past 8 hours, fighting off the sleeping bugs (but failed, i dozed off when we are meeting a customer who was introducing his new products), and finally, i did something.
I can run a python script!
I failed for countless of time and i gave up testing it on web2py browser. So i created a simple python script… i realized a few points to note:
1. improper indentation (4 spaces ok!)
2. time is somehow important?
3. #!usr/bin/python at the top of the page
4. run in root
Here it is!
print "welcome to my test"
serialport=serial.Serial(“/dev/ttyAMA0”, 9600, timeout=0.5)
print “error opening port”
Save it in home/pi, open up terminal:
$ sudo su
# chmod a+x test1.py
welcome to my test
woooohoooo 😀 log in success!