I want to run python script continuouslly all the time. for that i add a line in sudo nano /etc/rc.local (before the exit 0 line) with
python /usr/bin/python /home/pi/udpsendblock.py &.
here udpsendblock.py contain
Code: Select all
import sys, struct
from socket import *
SIZE = 1024 # packet size
hostName = gethostbyname('0.0.0.0')
mySocket = socket( AF_INET, SOCK_DGRAM )
mySocket.bind((hostName,18728))
repeat = True
while repeat:
(data,addr) = mySocket.recvfrom(SIZE)
data = struct.unpack('d',data)
data=int(data[0])
file = open("output.txt", "w")
file.write(data)
file.close()
i get udp data and then i want to print udp data all the time when i send without manually run udpsendblock.py.
but it print only one time. how can i do this?