I have Raspberry PI 3 Model B board.
Where i am using BASH, Python. How do i write the following code in B4J for Raspberry board and replace the Python code.
How to B4J the following Python code for RPI?
Where i am using BASH, Python. How do i write the following code in B4J for Raspberry board and replace the Python code.
B4X:
###### On boot - setup following and run my Python #######
$ cat /etc/rc.local
#!/bin/sh -e
# Test if rc.local even executing?
echo 'hello world works?' > /tmp/test
# Setup the GPIP
echo "18" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio18/direction
echo "1" > /sys/class/gpio/gpio18/value
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
echo "1" > /sys/class/gpio/gpio4/value
# Python infinite loop run
# with ERROR handler
/home/pi/pypy.py > /var/log/pypy.py.log 2>&1 &
exit 0
How to B4J the following Python code for RPI?
B4X:
$ chmod +x /home/pi/pypy.py
$ cat /home/pi/pypy.py
#!/usr/bin/python
import urllib2
import os
import time
from time import sleep
while True:
time.sleep(2)
try:
contents = urllib2.urlopen("https://www.b4x.com/commands").read()
if contents in ('reboot', 'reboots'):
os.system('echo "0" > /sys/class/gpio/gpio4/value')
os.system('echo "0" > /sys/class/gpio/gpio18/value')
sleep(0.5)
os.system('echo "1" > /sys/class/gpio/gpio4/value')
os.system('echo "1" > /sys/class/gpio/gpio18/value')
except:
print "ERROR - so what continue?"
#
# - Run infinite
#