Wednesday, December 17, 2014

Raspberry pi running SSH, lxsession, and Motion


This screenshot shows RPi with SSH enabled, and connected via a Ubuntu laptop in a headless way. The RPi is running Motion with an old wedcam.

To connect to RPi using the laptop, do
sudo ssh -X pi@192...
And then use lxsession to open x window.

The screenshot shows the Pi window is merged with the Ubuntu window. The left bar is for Ubuntu. The bottom bar lists all the programs running in both Pi and Ubuntu. The bottom right shows the Pi's CPU usage, time, etc.

Note that Motion cannot be viewed in Chromium. I had to use Firefox to view it. The default port for it (unless the conf file is modified) is 8081. To start/stop/restart the service, do
sudo service motion start
sudo service motion stop
sudo service motion restart

Wednesday, October 22, 2014

Raspberry Pi B+ boot up and connect to laptop

Just received B+ and could not wait to power it up!

1. Put into the case

I also ordered a Vilros clear case for the B+ model from Amazon. I thought this should be a fairly easy process, but it turned out to take more than 25 min! I think the case is simply too tight, at least for the case and Pi I received. I tried various ways and realized that unless I pressed it really hard, it just would not fit. But I was afraid to break my Pi!

After trying some more time I was able to click the Pi into the case. What I did was to seat the HDMI side on the bottom case, and press really hard on the GPIO side, all the way down through the two slide-shaped bumps. Of course I could not press on the GPIO pins, so I had to press a little below the pins. It was uncomfortable, and excessive force had to be used. And I guess there is no way I can get the Pi out of the case in future unless I break the case.


2. Boot up

I ordered a micro SD card Kingston Digital 16 GB Class 4 microSDHC Flash Card with SD Adapter (SDC4/16GBET). I followed the procedure on this link to install the Raspbian Wheezy 2014-09-09 on the SD card using a Ubuntu laptop. After that, if I inserted the micro SD card into the laptop, it showed two devices, one "boot" with files such as bootcode.bin, cmdline.txt, *.elf, etc., and the other "3 GB Volume" which should be expandable using the Pi.

The micro SD card was then inserted to the Pi. Even if it "clicked", I could still pull it out. It seems there is nothing really locking it into the slot. But it does make good contact.

Then I connected the Pi to USB mouse, USB keyboard, Edimax nano-size USB WiFi adapter, and a DVI monitor using a HDMI-DVI cable. It booted up!

The setting up of WiFi was super easy in the desktop. I tested IDLE, Pi Store, Mathematica, Wolfram Language, web browser, installing vim, etc. It was very smooth.

I enabled ssh during the booting up. Then I could try the "headless" way, removing the connections of keyboard, mouse, and the monitor!

3. Connect to laptop

After enabling ssh on the Pi, I wrote down the IP address of the Pi, something like 192.168.0.???. I bundled the MAC and IP in the router so that I will always use the same IP address to access the Pi.

I removed the keyboard, mouse, and monitor from the Pi. In my Ubuntu laptop, I opened Xterm and typed:
sudo ssh -X pi@192.168.0.15
Then entered the password, and the connection was made. In the above, the "-X" is for allowing x windows.

To start the desktop, type
lxsession &

The Pi's window would then merge into the Ubuntu's desktop. All the software worked fine on the merged desktop, except that I found I could not get Scratch to open in this headless way.

To terminate the lxsession, type the following in the terminal running ssh:
lxsession-logout

Thursday, January 16, 2014

Ubuntu backup deja-dup

http://www.howtogeek.com/108869/how-to-back-up-ubuntu-the-easy-way-with-dj-dup/ 

Can recover the whole system, a selected file (right click Revert to Previous Version ...), and a deleted file (right click Restore Missing Files ...)

However some users complained about its unreliability
https://apps.ubuntu.com/cat/applications/deja-dup/

Sunday, January 12, 2014

Tools/procedures for generating high-quality PDF/EPS files with LaTex math

Without using pricey licensed softwares, you can generate high-quality PDF/EPS files with LaTex math expressions, as shown in the following. Other procedures may work as well, but the following have been tested and may save some time.

1. Drawing tools and procedures

To make your own figures with LaTex math, you may use LibreOffice Draw. To enable LaTex, in Tools --- Extension Manager..., add TexMaths (http://roland65.free.fr/texmaths).

You may also use Inkscape. For math expressions, use Extensions --- Render --- LaTex formula ...

Both LibreOffice Draw and Inkscape are free.

On the other hand, if you have MS Office, you may use Powerpoint to draw, with TexPoint ($30~$45) or IguanaTex (free) for math expressions.

After drawing, export or save as a PDF file and embed all fonts. Converting to other file formats may be not preserve all formats/information.


2. PDF tools and procedures

This PDF file should have all fonts embedded. To check, use:
pdffonts a.pdf

to make sure all fonts are embedded correctly.

To generate an EPS file with a bounding box or a PDF file with only the drawing area kept, do:
pdfcrop a.pdf b.pdf

This removes the white space around the drawing area in a.pdf and generates an output file b.pdf.

If EPS format is desirable, perform:
pdftops -eps b.pdf

This is generate b.eps with the bounding box.

If Adobe Acrobat Professional is available, you may also crop the pdf using it, and save as another PDF file or save as an EPS file.

3. Include the drawing file in LaTex document

The b.pdf file or b.eps file can be included in a LaTex document using e.g.:

\begin{figure}[h]
\begin{center}
\subfigure[]{\scalebox{.6}{\includegraphics{b1}}}
\subfigure[]{\scalebox{.6}{\includegraphics{b2}}}
\end{center}
\end{figure}


If no file extension is specified, PDFLaTex will look for b1.pdf, b2.pdf, etc., and LaTex will look for b1.eps, b2.eps, etc.


If LaTex --> dvi2ps --> ps2pdf procedure is to be followed, make sure the option
-Ppdf 
is used for dvips, and the options
-dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress 
are used for ps2pdf.

If PDFLaTex or the like is to be used used, set the following option:
updmap --setoption pdftexDownloadBase14 true 


The produced PDF file should have all fonts embedded and high-quality figures. You may use pdffonts to verify.