serial port - How to get a python script to listen for inputs from another script -


i have situation need 1 python script running in continuous loop, , need pass parameters script run when action occurs.

the second script triggered website using cgi, have working fine. continuous loop should take in parameters read out cgi script (and send info via serial port).

for specific problem can't have cgi script sending data via serial directly each time runs resets serial port.

i can't seem find information on kind of setup. there methods or libraries or better ways of approaching it?

i use socket connection. writing simple server takes 1 connection @ time

import socket s = socket.socket(socket.af_inet, socket.sock_stream) s.bind(("localhost", 9988)) s.listen(1)  while true:     conn, addr = s.accept()     data = conn.recv(1024)     conn.close()     my_function_that_handles_data(data) 

s.accept() blocking call. waits connection. read on connection. in case assuming length of parameters 1024 bytes. data received socket , wait connection.

the client this:

import socket s = socket.socket(socket.af_inet, socket.sock_stream) s.connect(("localhost", 9988)) s.sendall('my parameters want share server') s.close() 

the nice thing in future if client , server no longer running on same machine it's simple matter of changing "localhost" actual ip address or domain name going hit.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -