I wanted to display IP address using MAX7219 and SPI on the startup.
I followed instructions on web page Getting a Python script to run in the background (as a service) on boot. Script is loaded as required, but the process does not start. On the other hand, by starting script manually, everything is OK.
I suspect that problem might be in the fact that script starts before spidev is loaded. Or is there anything else wrong? Can you help me with this?
Here is also code in case you need it:
#!/usr/bin/env python
import max7219.led as led
import time
from subprocess import Popen, PIPE
def run_cmd(cmd):
p = Popen(cmd, shell=True, stdout=PIPE)
return(p.communicate()[0].rstrip())
addr = ' ' + run_cmd("ip addr show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1")
dots = [False]*(len(addr)-3)
pos=-1
for i in range(0,3):
pos = addr.find('.', pos+1)
dots[pos-i-1] = True
addr = addr.replace('.','')
device = led.sevensegment()
pos = 0
while True:
addrs=addr[-pos:]+addr[:-pos]
dotss=dots[-pos:]+dots[:-pos]
for i in range(0,8):
device.letter(deviceId=0,position=8-i,char=addr[i],dot=dots[i])
time.sleep(1)
pos=pos-1
if pos == -len(addr): pos=0