Thursday, August 25, 2016

Check screensaver remotely in Linux Mint


  1. SSH in.
  2. export DISPLAY=:0 ; cinnamon-screensaver-command -q
  3. For more information: man cinnamon-screensaver-command .

Tuesday, August 23, 2016

Ideas for right click menu items


  • Join multi part .avi files together using avimerge.
  • Join split files. e.g. file.001, file.002, file.003
  • Upload to cloud storage.
  • Run an md5sum and check against saved md5sum lists so see if a duplicate is already in storage.
  • shred or srm
  • Make an .iso or .img
  • Move an .nzb file to the Sabnzbd watch directory.

Adding menu items to Nemo (Linux Mint file manager)

So, I'm running Linux Mint 18. Its default file manager is Nemo (Version 3.0.6)

I'm trying out right-click context menu options in Nemo.

STEP 1:
Create a test script in Perl. I've saved it as /home/sbb/bin/nemotest.pl, and chmod +x 'd it. Its sole purpose is to print out the given arguments.


1:  #!/usr/bin/perl  
2:    
3:  use strict;  
4:  use warnings;  
5:    
6:  while (my $e=shift) {  
7:   print "$e\n";  
8:  }  
9:  sleep 10;  

STEP 2:
Create an action script in ~/.local/share/name/actions . Call it test.nemo_action  (The file extension is important).

1:  [Nemo Action]  
2:  Name=Test  
3:  Comment=  
4:  Exec=gnome-terminal -x /bin/sh -c "/home/sbb/bin/nemotest.pl %U %F %P %p"  
5:  Selection=s  
6:  Extensions=any;  
7:  EscapeSpaces=true  

STEP 3:
Try it. Fire up Nemo, right-click on a file.


If all goes well, the result should be:


We can now see the output produced by each of the % variables in the .nemo_action file. Note that spaces in the file name are handled nicely.

STEP 5:
More reading.
Here's a link with some useful information.

I've tried multiple selections as well. Selection=m in the nemo_action file will make the menu item apply to multiple selections. In this case, the %U and %F substitutions will put multiple items on the command line.

Directories too. Extensions=dir; and you're right clicking with directories.

A handy note: Nemo reads the .nemo_action files on the fly, so you don't have to exit and restart Nemo each time you make a change to the files.

Another handy note: http://codeformatter.blogspot.com.au/ does the code formatting.

Tuesday, June 18, 2013

RTKLIB on the Raspberry Pi

I've got a workmate. He wants to build an autonomous, electric, rotary hoe. Anyway, he needs to locate  the hoe to within a few centimetres.

I'd been contemplating DGPS for a while as I've found GPS tracks are a bit wandery when logging tracks for OpenStreetMap. I thought it'd be a good capability to have, so I've stepped up to the task of tracking Robohoe.


Background Information

This is basically a link dump of what I've found so far:

RTKLIB : DGPS software
  This is the bees knees for cheap arse DGPS. It can take raw GPS input from 5 or 6 different types of GPS, as well as most variants of the RTCM GPS correction stream. It can combine two data streams, from a reference station and a rover, to produce a high-precision position for the rover, or it can take a single stream from a reference station and produce an RTCM output for other stations.

  It's also got a number of other super handy programs, that do things like convert RTKLIB output into a Google Earth KML file, serve serial input out to multiple processes via Unix sockets etc.

The RTKLIB manual is here.

LEA-4T : GPS hardware
  The U-Blox 'T' series of modules (the LEA-4T, LEA-5T, and NEO-6T) produce data suitable for input to RTKLIB. The link above is the cheapest source I've found for these. I've bought 5 so far, and they've all been OK. Interestingly, this guy sells them on EBay for about three times the price.

 The pinout for this module is (from here):
antenna - SMB male connector
2 4 6 8
1 3 5 7
bottom

1 antenna vcc
2 vcc
3 tx
4
5 rx
6 timepulse
7
8 gnd

Note that Antenna Vcc and Vcc are both 5V, and aren't connected on board, so 5V is needed on both pins. Tx and Rx are both serial at 3.3V levels.

EBay : GPS antenna
  Generic powered GPS antenna with SMB plug, ~$7.00. Works.

EBay : USB serial unit
  Generic FTDI USB serial dongle. Used for GPS configuration on a Windows machine. In final use, the module will send data to the Pi via the 3.3V serial port on the GPIO.

u-center : GPS configuration software
  This is a whizzy Windows application which can be used to configure the modules to output the correct messages for RTKLIB. It can also be used to have a peek at the contents of all the mysterious binary packets that come out of the module.

Geosciences Australia : DGPS correction data
   GA runs a network of reference stations around Australia, and you can get non real-time correction data from their FTP site. This will be handy for post-processing data from my static installation to derive a precise location. I can then use the static station for real-time DGPS.

RNXCMP : file conversion software
  The GA data is in an odd format called the Hatanaka format. This program converts it into a more usable form.


Up To Now

What I've done so far is:

  • By default, Raspbian on the Pi runs a debug console on the GPIO serial port. I've modified the install to not do this and leave the serial port free.
  • Made up an adaptor to power the module from the GPIO, and send and receive data to the GPIO serial port.
  • Installed and (mostly) compiled RTKLIB.
  • Configured the module using u-center on a Windows machine.
  • Installed the module on the Pi, and used str2str (part of the RTKLIB suite) to send the module's serial data over the network.
  • Used the Windows version of RTKLIB to receive the data stream, and convert the raw stream to a position.


Current Status

The current status is:
  • My static antenna is fixed to point under the Laserlite in the porch.
  • Raw data is being collected from the module using the static antenna (~48 hours so far)


The Future

Future plans include:
  • Work out conversion of the GA correction files.
  • Work out how to produce a precise position from the logged static antenna data, and the GA correction data.
  • Work out how to produce real time correction data from the static station and RTKLIB.


Monday, March 4, 2013

Silliness on a bike


A POCSAG -> email gateway

EDITED 26-Nov-2013: Minor bugfixes on commands, moved script to Google Drive, added more explanation.

I put this script together a while ago. It examines the output from Multimon-NG, and forwards selected POCSAG messages via email. Note that it uses SMTP via TLS, which may not work for your email provider. Gmail works fine.

First off, copy the script to the home directory of your Pi.

Then:

sudo apt-get install libnet-smtp-tls-perl libdatetime-perl
chmod +x pocsag_fwd.pl

Next, configure it. Lines 31-33 need to be updated to include your SMTP server and login details.
Also, the definition of the @stream variable (lines 11-26) need to be modified to include the POCSAG address ID's and email addresses you want. Hopefully the syntax and meaning of the fields will be self-explanatory. You might want to examine the output from multimon-ng for a while to find the addresses you're interested in.

To use it:

rtl_fm -N -o 4 -l 10 -A fast -r22050 -s88200 -C -D -f 148.7125M - |multimon-ng  -t raw -a POCSAG512 -f alpha /dev/stdin|./pocsag_fwd.pl

Putting rtl_fm and Multimon-NG together

Unix pipes are awesome.

To decode POCSAG on the Pi, this is all you need:


pi@raspberrypi ~ $ rtl_fm -N -o 4 -l 10 -A fast -r22050 -s88200 -C -D -f 148.7125M - |multimon-ng -t raw -a POCSAG512 -f alpha /dev/stdin
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 

Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
multimonNG  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA
            (C) 2012 by Elias Oenal
available demodulators: POCSAG512 POCSAG1200 POCSAG2400 EAS UFSK1200 CLIPFSK AFSK1200 AFSK2400 AFSK2400_2 AFSK2400_3 HAPN4800 FSK9600 DTMF ZVEI SCOPE
Enabled demodulators: POCSAG512
Found Elonics E4000 tuner
Oversampling input by: 3x.
Oversampling output by: 4x.
Buffer size: 7.74ms
Tuned to 148977100 Hz.
Sampling at 1058400 Hz.
Output at 22050 Hz.
Exact sample rate is: 1058400.010094 Hz
Tuner gain set to automatic.
POCSAG512-: Address:   12935  Function: 2
POCSAG512-: Numeric: 4-23U7]47978140-0[93-]]338.50.2.U7 [62795]0.659560U9- 660.6182836.7.-]560180482-]43683818 .569696926]281-04-201.6 920-01U1405 2647438.9169[81-0.85]277U410000
POCSAG512-: Blah blah blah - content redacted by me<NUL><NUL>
POCSAG512-: Address: 1720997  Function: 0
POCSAG512-: Numeric: U-U1  5 .4.3161395]..0. 2 270.9]3U.45428].5 925143 024U802960-97 228]U352280733.9-46 20-538  562-9740155.1 1]2950.9255.[ 5619502U1869-40915.[ 62868[ 1]-05.5 2]2950.924U85 059]358  2637. 2014U84-2.49502U1 2U5]0U 14-46100
POCSAG512-: Alpha: THIS IS A TEXT MESSAGE, IT WAS ANOTHER TEXT MESSAGE, BUT NOW IT INCRIMINATES NO PERSON<NUL>

And it's going. You can now construct a veritable daisy chain of processes to do all sorts of things with the output.