Thursday, November 1, 2012

Chumby Links, and Tips

People are starting to ask me questions about the Chumby. I am not sure what to think, but rather than getting asked the same questions dozens of times, I thought I'd offer some answers ahead of time.

How did I load my software?


You can start up an SSHD on the Chumby. Go to the about device screen in setup and click on the pi symbol in the upper right corner. Using something like putty on windows, or ssh on linux/mac command line, you can connect as the root user. On my chumby, I connect by typing:

   ssh root@192.168.2.10

or
   ssh 192.168.2.10 -l root

By default there is no password. You can add one, but on reboot, the sshd turns off, and no one can connect. There are instructions for adding passwords on chumby tricks web site. Actually that page has lots of useful links.

I am an emacs user. It is a wonderful tool/IDE/editor. There is no emacs on the stock chumby. I used my laptop to enter the code, this provided me a place to backup the code, so now it is on both the Chumby and my PC. I then cut-n-pasted to a simple vi session on the chumby.

Of course Perl is already there, and all I needed to do was write some code it could interpret. Yes, interpret, but trust me, well written Perl is stinking fast. I've done some image processing using it, it is fast enough.

Where did I store my app?


There is a micro SD card in the Chumby. It can be removed, and I imagine you could load your code on there. You don't need to, you can use the read write file system /mnt/storage to put your code on. I made a sub directory and called it bin, to be standard with the rest of *nix. (If you want to learn about the philosophy behind Unix/Linux etc, the book The UNIX Programming Environment by Kernighan and Pike, read it study it, and you will be the best programmer ever).

How to start the app?


Every time the Chumby boots up, or any *nix system starts, it runs some fixed sequence. There are some scripts in /etc/init.d that has the scripts. I didn't use them, because that partition is read only. You can do a mount -o remount,rw / on that partition, and put in your script. 

I did it the old fashion way; using the command line. Unix is funny, if you start an app on the command line, and the terminal that that app was started from the app goes away also. There are things we can do to get around that. The nohup command is how we ignore the hangup signal when the terminal goes away. Just start the program prefixing the command line with "nohup" and end it with an ampersand "&", and the program will keep running until it gets a fatal error, or the computer reboots.

Another way to make an app keep running after the terminal goes away, involves fork and exec, and a disoconnect. The Stevens book Advanced Programming in the Unix Environment (another book you should be at least familiar with if you want to be a great programmer) has that answer.

Sending Mail 

Oh boy, how does mail work. The chumby acts as a client to a mail server. The mail server is usually called the "SMTP" (Simple Mail Transport Protocol) server. Your ISP probably has a SMTP server that you can use, or google users can use the Google one. The sendmail program on the chumby is the client program that talks to the SMTP server program. The SMTP server will help route your message to the appropriate next hop on the way to the mails destination.

SMTP servers have many options. Some require authentication, some don't. You will have to read all your server documentation to figure out what kind of authentication (if any) is needed. Sendmail can handle most, maybe not in the orientation you are thinking. Like sometimes you need the ssh port, other times it will leave everything visible.

There is some documentation about connecting to gmail at:

     http://forums.fengoffice.com/index.php?topic=190.10;wap2


If it isn't working, run the sendmail command using the strace. Something like:

   strace sendmail cozytom@gmail.com -f sender@example.com  -S smtp-server.tx.rr.com -au senderusername -ap senderpassword < mail.txt

The output will be pretty chatty, but you should be able to see any errors or find clues as to where it is quitting. 


There is probably more to consider, but that will get you started anyway.

 
 

No comments:

Post a Comment