Re: How to persist text on the screen when the client exits?
Niel Smith <[email protected]> Wed, 2 Jan 2013 21:01:17 +0200
| Newsgroups | gmane.comp.sysutils.lcdproc |
|---|---|
| Message-ID | <CA+=4hTsVT4zDRhAJwxwuz5Z=hRZhZHcb2dS=Rxx8NRUhVNsBnw@mail.gmail.com> |
Hi Richard, I've attached a VERY quick and dirty "proxy" script / hack that might help. It keeps a persistent connection to a remote server (such as lcdproc), and passes data from one active client client (at a given moment) to the remote server. Start it as a background process, or add code to your script to fork a "proxy" process once when you are not able to connect to it. (Then again, a duplicate process will just die harmlessly) Just update the host & port settings to reflect your lcdproc settings. Only 1-way comms is implemented. Regards, Niel On 2 January 2013 01:59, Richard Neill <[email protected]> wrote: > Dear Eric, > > Thanks for your quick reply. > > I'm afraid that my simplified bash script > may have added confusion - I do know about the -t option for the client. > Also, I'd rather not respawn python every time - but in this case it's OK > (the performance hit, while wasteful, is not actually an issue). The > machine I'm monitoring is actually an ADSL router - it's job is just to run > multilink ppp, and is rather overspecd, > > So, I'm attaching my script, which may make things a bit clearer. This is > launched from cron with "@reboot". > > Anyway, it works fine, except that the screen is blank about half the time. > > What I really want is to treat the LCD display like a simple character > device, into which I can echo text. I appreciate the sophistication of the > lcdproc architecture, with support for buttons, menus etc, but in this > particular use-case, I don't need it. > > Best wishes, > > Richard > > > > On 01/01/13 23:44, Eric Pooch wrote: > >> You need to re-imagine your client rather than the change the server. >> Your client is spawning 4 processes every 2 seconds. This doesn't >> seem like a good idea. >> >> As a temporary fix, the -t option for lcdproc_client.py will keep >> the connection open for the time you specify. I would change your >> final sleep command to account for this. >> >> --Eric >> >> On Jan 1, 2013, at 3:27 PM, Richard Neill wrote: >> >> Dear All, >>> >>> I've just joined this list, so please excuse me if I ask an obvious >>> question. >>> >>> I'm trying to get a server status monitor system working, >>> monitoring a set of parameters of my choice (the lcdproc defaults >>> aren't suitable for me here) >>> >>> So, I have LCDd running (with a 20x2 picolcd), and found the text >>> client here: http://lcdproc-client.**sourceforge.net/<http://lcdproc-client.sourceforge.net/> >>> >>> I have a bash-script that sends strings to the client every few >>> seconds, and they display on the LCD as expected. A simplified >>> example: >>> >>> while : ; do hostname | lcdproc_client.py -f - sleep 1 date | >>> lcdproc_client.py -f - sleep 1 done >>> >>> >>> This displays the hostname and the date, alternately, as I expect. >>> >>> BUT, between these, every time the python script exits, the system >>> keeps going back to either the LCDd default screen, or to blank >>> (the value of ServerScreen). >>> >>> How can I get LCDd to just leave the text on screen as it was, >>> until I explicitly overwrite it? >>> >>> Thanks very much, >>> >>> Richard >>> >>> >>> P.S. Might I suggest that a "--text" option to lcdproc i.e. "write >>> this line to screen, and exit" would be really useful in the >>> default distribution. >>> >>> >>> ______________________________**_________________ LCDproc mailing >>> list [email protected] >>> http://lists.omnipotent.net/**mailman/listinfo/lcdproc<http://lists.omnipotent.net/mailman/listinfo/lcdproc> >>> >> >> >> > > _______________________________________________ > LCDproc mailing list > [email protected] > http://lists.omnipotent.net/mailman/listinfo/lcdproc > > _______________________________________________ LCDproc mailing list [email protected] http://lists.omnipotent.net/mailman/listinfo/lcdproc
q&d_proxy.py
(application/octet-stream, 636 B)
#!/usr/bin/env python
# Quick and dirty "Proxy" - Python 3
import socket
s_addr = ('127.0.0.1',50000)
c_addr = ('127.0.0.1',50001)
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
c.connect(c_addr)
c.send('Hello World!'.encode())
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(s_addr)
s.listen(5)
print("Listening", s_addr)
while 1:
client, address = s.accept()
print("Connected", address)
while 1:
data = client.recv(1024)
if not data:
client.close()
break
print("Read:",data.decode())
c.send(data)
client.close()
print("Disconnected", address)