Fair enough...
Here is the python script recieving the commands:
import RPi.GPIO as GPIO
import serial
import os
from subprocess import *
GPIO.setmode(GPIO.BOARD)
print "Setup pin 22"
GPIO.setup(22, GPIO.OUT)
GPIO.output(22, False)
serialport = serial.Serial("/dev/ttyAMA0",115200);
serialport.write("^Power&\n");
cmd = "ip addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"
def run_cmd(cmd):
p = Popen(cmd, shell=True, stdout=PIPE)
output = p.communicate()[0]
return output
def ret_ip():
print "returning ip"
ipaddr = run_cmd(cmd)
serialport.write("^$wip");
serialport.write(ipaddr);
serialport.write("&\n");
while True:
response = serialport.readline(None);
response = response[0:2]
print "response = " + response
if response == "ip":
print "if triggered"
ipaddr = run_cmd(cmd)
serialport.write("^$wip");
serialport.write(ipaddr);
serialport.write("&\n");
if response == "SD":
serialport.write("Shutdown recieved\n");
os.system( "sudo shutdown -h now" )
if response =="RB":
serialport.write("reboot command rx")
os.system("sudo reboot");
if response == "VN":
os.system("vncserver :1 -geometry 1300x700 -depth 24")
if response == ("ST"):
serialport.write("^Power&\n");
this code returns this:
response =
when the line Serial1.println("ST");
is executed