This is part 5 in the series of my getting to know the Intel Galileo Board. I made a project that uses pager motor based bees which buzz louder based on how much email is in my inbox. This is a derivative of the SparkFun Enginursday project that uses an LED display to show an unread email count.
This section chronicles the work done on Linux core itself. The Galileo has an x86 processor, the Quark X1000 SoC, a 32-bit, single core, single threaded, Pentium ISA-compatible, max clock rate 400MHz CPU. Other folks have played around with installing other flavors of Linux, but I am using the official Image. The ability to use a more robust processor while still in the Arduino ecosystem is one of the major selling point of the Intel Galileo. This week is mostly piddling around in the Linux file system. The next installment demonstrates how to harness the power from an Arduino sketch.
Before You Start
The following post assumes some knowledge of *nix systems and elementary Python. Those with zero Linux knowledge, zero Python knowledge and zero Arduino knowledge might want to pick one to get comfortable with first. I’ve presumed Arduino knowledge thus far, and will assume some comprehension of the other two. I recommend the following to skill up:
Add these files to the SD card
Two files, the SparkFun mail checking python script and a test script that always returns the number 18, will aid in the trouble shooting. Put them on the SD card before getting started to save time.
Before placing the mail checking script on the SD card:
- swap in appropriate email credentials for the dummy text
- check that script successfully negotiates the mail connection and returns the correct value from a computer
- place the python file with the credentials on the SD card of the Intel Galileo board.
Options for Talking to the Linux Kernel
Given that there is no way to attach a keyboard, mouse or monitor to the Galileo board out of the box, another root to see inside the Intel Galileo’s brain has to be found. The cracks in the side of the mountain are:
I only have direct experience of the first two.
Use the special RS232 to minijack serial cable
Having the appropriate serial cables and a terminal emulator is the most bullet proof method of talking to the Galileo. It does not require the Arduino emulator to be running a specific sketch or even for that feature to be running at all.
For software, on the Mac I use either Cool Term or the screen utility. The hardware I needed:
I’ve uploaded my terminal settings. The port name will need to be changed depending on what USB to serial adapter driver you have installed.
After making the connection, if the Galileo is already booted, nothing will happen in the terminal window. Hit return and a login prompt will show up. The login name is root. There is no password.
For future use, once the connection is made, even without login, all of the debugging messages during start up and sketch upload come streaming out this line. Access to those messages alone justifies spending the money on an adapter.
Run WifiChecker. The code has the Arduino tell you its IP address via the Serial port. Open a Terminal program and establish a connection to the Intel Galileo Board by typing:
If you have SSH‘ed into something at that was assigned that address on your network before a RSA key warning will appear. The best course of action is to delete that IP address’s entry in your known_hosts file.
First things first
Once in, you are free to move about the system. I suggest changing the password, especially if leaving your Intel Galileo connected to a network.
Next look at the directory structure, not with ls (show me the files) but df (show me attached hardware).
#####CHECKING FILE SYSTEM
#display free disk space (df)
#change directories to the alias for the Arduino storage
#now that you are actually somewhere with files the
#ls command will work and show the test files from
#working with the SD library if there are any.
#####END CHECKING FILE SYSTEM
Congratulations, you’ve hacked your personal Gibson.
Check The Internet
The Python script won’t work if it can’t see the internet and the mail server. Make sure WifiChecker or some other WiFi enabling Arduino sketch is loaded. Then try some of the commands below.
#ping googles DNS Server to see if internet is working
ping 220.127.116.11 #googles DNS Server
#get a web page, if ping works, not all that necessary
telnet google.com 80
GET / HTTP/1.0
#check that the mail server responds
#is SSL possible on the mail server SSL port
telnet YOUR.MAIL.SERVER.COM 993 #IMAP SSL
#an alternate way to get IP address if didn't
#####END CHECKING INTERNET
Python 2.7.3 comes with the Galileo SD image. Checking the basic functions takes just a few commands.
# get the version
# launch python interpreter
#run the len() command as a simple test
len("I should return 18")
#leave python interpreter ^D will also work
#test the ability to run the test script
#will only work if you've actually copied
#the test scrip to the SD card.
#####END CHECKING PYTHON
Troubleshooting the pyMailCheck.py Script
The fully updated Python script should be on the SD card ready to run. Hopefully a simple call while inside the /media/realroot directory will run beautifully for you and no more will need to be done.
That isn’t what happened for me. Running the script resulted in a fatal socket error.
File "pyMailCheck.py", line 5, in <module> obj = imaplib.IMAP4_SSL('mail.MYSERVER.com', '993') # Connect to an IMAP4 sever over SSL, port 993</pre>
File "/usr/lib/python2.7/imaplib.py", line 1148, in __init__ IMAP4.__init__(self, host, port)
File "/usr/lib/python2.7/imaplib.py", line 163, in __init__ self.open(host, port)
File "/usr/lib/python2.7/imaplib.py", line 1160, in open self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 143, in __init__ self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake self._sslobj.do_handshake() socket.error: [Errno 104]
Connection reset by peer
The error implicated the second line of code, the fifth line of the file. The script had worked perfectly for me from my computer. My approach was to launch the Python interpreter on the Galileo board and test it line by line. Indeed, line two was the problem. My code uses a custom mail domain via Dreamhost. The SparkFun code was tested with a gmail server. Turns out this code works perfectly from the Galileo when the mail server is a gmail server, but not my mail server. Doh.
I suspect the suggestions on the Dreamhost wiki page about Certificate Domain Mismatch Error hold they key, but I’m not 100% confident. Since I’m using a disposable email address for a temporary project, my workaround in the short term is to do the VERY BAD NEVER REALLY DO THIS sending of the password in the clear which allows the Galileo to connect to my webserver just fine.
obj = imaplib.IMAP4('mail.YOURSERVER.com') # Connect to an IMAP4 server. Password CLEAR TEXT
More sadness, for me the Arduino code STILL didn’t properly read the numbers from a file after getting the Python script sorted out and confirmed functional.
The next task required troubleshooting code written to read the numbers in from a file. And that will have to wait until next week…. but so so so close…
In this series
- Part 1
- Part 2
- From Zero to Blink.
- Creating an SD card image and getting a sketch to persist on the Galileo
- UPDATE: Blink on an external LED
- Part 3
- Creating the bees and getting them to work on an Arduino UNO
- Part 4
- Setting up Wifi (very easy, library examples worked immediately)
- Getting the SD card read & write to work (a missing libraries/symlink problem)
- Part 5 (this post)
- Serial Communication to the Linux Core
- Troubleshooting Python on the Galileo
- Part 6
- Revising the example String to Int code (lack of Null Termination problems)
- Moving the motors over to the Galileo