Hardware Reference
In-Depth Information
features of Galileo is that it's running Linux. Let's now take a small dip into
the world of Linux on Galileo.
The first thing you need to do is connect to the Linux command line. Here, I'll
show you how to connect via Telnet over the network. You can also connect
directly via serial. See Appendix H for how to do that.
Connecting via Telnet
If your computer is connected to the same LAN (local area network) as the
Galileo, you can use Telnet to connect to Galileo's Linux command line
prompt through the network.
1. Using an Ethernet cable, connect your Galileo to the same network as
your computer.
2. With your Galileo powered up and connected to your computer via USB,
upload Example 3-5 to the board. This code will enable Telnet on the
board and pipe information about Galileo's network connection to the
serial monitor.
Example 3-5. Code to enable Telnet and Print IP
void setup () {
system ( "telnetd -l /bin/sh" ); //
}
void loop () {
system ( "ifconfig eth0 > /dev/ttyGS0" ); //
delay ( 5000 );
}
Execute the Linux command to enable Telnet.
Output information about the Ethernet connection to the Arduino
serial monitor.
Example 3-5 uses the system() function, which is unique to
Galileo. It's meant for running Linux commands within Arduino
code. This will be covered in more depth in Chapter 6 .
3. Open the serial monitor and get the IP address, indicated by inet addr
in the response. If you don't see inet addr , make sure your board is
connected to the router and try rebooting it and going through these
steps again.
 
Search WWH ::




Custom Search