Hardware Reference
In-Depth Information
If you use Telnet with your Raspberry Pi on port 13666 you should get a connection. The server is now waiting for
a command. Be nice and issue the hello command to your LCDd server. You can see in Figure 4-20 where I have said
hello to my LCDd server and the server responds back with the version and the dimensions of the LCD.
Figure 4-20. Saying hello to your new friend
Displaying Text
It's quite simple to communicate with the LCDd server. I am now going to show you how to use Ruby to write a small
script that will display text on your LCD. This script will communicate with the LCDd server and send it a simple text
message. You can execute this script anywhere on the same subnet as the Raspberry Pi that is running the LCDd . It will
stay connected until you terminate the script. Once you run it, check the syslog on the Raspberry Pi for connection
messages that the new client generates. Take a look at the script in Listing 4-2; you can see my simple example to write
a text string to the LCD.
Listing 4-2. A Simple LCDd Client in Ruby
#!/usr/bin/ruby
# Description : A simple script to talk to the LCDd server
# Author : Brendan Horan
# Use the net telnet functions
require 'net/telnet'
# Trap ctrl-c nicely
trap("INT") { puts " Shutting down client."; exit}
# Create a new connection to the Pi
pilcd = Net::Telnet::new(
# Change this IP to your Pi's IP
"Host" => "192.168.0.199",
"Port" => 13666,
# We are not a real telnet client
"Telnetmode" => false,
 
Search WWH ::




Custom Search