Friday, 17 February 2017

Raspberry Pi problem with default gateway being lost when rebooting.

On my raspberry pi, I was having a problem where the default gateway was being lost every time that I rebooted it. I was able to temporarily fix the problem by using the following command:

sudo route add default gw 192.168.100.1

However when power was lost or I rebooted then I would be back to having network connection problems, which is an issue when trying to automate something.

The solution that I found was to edit the /etc/dhcpcd.conf file using the following command:

sudo nano /etc/dhcpcd.conf

Then at the bottom of the file I added the following line:

static routers=192.168.100.1

Note that if you have the same problem, your IP address might need to be different. If you enter the command ifconfig, you should get an output similar to the following:



You need to look at the section for the network you are expecting to connect to. wlan0 is provided from the built in wifi hardware which comes on the newer raspberry pis. eth0 is the ethernet connection (wired). lo is the localhost which won't be the one that you need. I was connecting with eth0, so I looked under this section at the inet addr parameter, and I tool this number and changed the last digit to a 1, which is how I got my default gateway.


The file /etc/network/interfaces did not seem to make a difference to anything. Now the only command specifically for the eth0 connection is the following:

iface eth0 inet dhcp

There are a couple of other things that I had tried with no luck.

I tried writing a shell script to add the default gateway, and then tried to use crontab to run this at reboot using the @reboot command. This did not work for some reason. Running the shell script alone was fine but it was not possible for crontab to do this. I also tried adding in a 60 second pause in the crontab before the script was ran, but this also did not work.

I also tried making modifications to the /etc/network/interfaces file, which also did not help.

I tried the following commands together as a pair:

post-up route add default gw 192.168.100.1 eth0
pre-down route del default gw 192.168.100.1 eth0

This did nothing of course. Neither did adding a line with the gateway parameter.

gateway 192.168.100.1

So all in all I'm not sure exactly where the problem came from, just I now know the /etc/network/interfaces file is the wrong place to try and fix this, and instead it needs to be changed in /etc/dhcpcd.conf

Thursday, 26 January 2017

TeXStudio, Mendeley, biblatex and biber backend problems with undefined citations

I had a problem with citation in TeXstudio when I was trying to cite an entry from Mendeley, where the \cite{citationkey} command was showing an error that the month field was incorrect. I was using biblatex as this allowed me to have the citations in the format that I wanted, but I had to use the bibtex backend, as using the biber backend gave me a lot of errors.

Some googling showed that biber is more accepting of different date formats, and that bibtex wasn't able to process the dates as exported from Mendeley.

The command I had used to select the biber backend was as follows:

\usepackage[style=authoryear,backend=biber,bibencoding=ascii,date=year]{biblatex}

However this didn't work and all of my citations gave the following message:


LaTeX Warning: Citationref:[citeationkey]' on page 1 undefined on [filename] line 21.`

The problem here ended up being the version of the biber executeable installted by MiKTeX. Firstly, I updated MiKTeX by using the following link:

Start > All Programs > MiKTeX > Update (Admin)

I had to run this a few times, as the first run would only allow me to remove obsolete packages, and not install or update anything else. Once I had ran this a couple of times, I then also ran the non admin version.

Now doing Build & View in TeXstudio was giving errors about packages being missing, so I used the MiKTeX Package Manager to install the missing packages. This is located in

Start > All Programs > MiKTeX > Package Manager (Admin)

Here, I tried installing the package that was marked as missing, but there were always more packages. So instead, I sorted by the "Installed on" field, by clicking the name of the column, and then selected all of the entries that had an empty field (i.e. had not been installed). Then I right clicked and did "Install" and then waited.

Once completed, I was still having problems in TeXstudio. The warning looked like the following:

WARN - Warning: Found biblatex control file version 2.6, expected version 2.5

So I downloaded the file for the newest version of biber from Source Forge. The repository is here: https://sourceforge.net/projects/biblatex-biber/files/biblatex-biber/ and the link to the 32 bit binary for windows is here: https://sourceforge.net/projects/biblatex-biber/files/biblatex-biber/current/binaries/Windows/biber-MSWIN32.zip/download

I downloaded this and placed it in the MiKTeX binary directory which is located here:

C:\Program Files (x86)\MiKTeX 2.9\miktex\bin

(Note that I had tried just replacing the biber.exe file with the newer version, however on it's own this hadn't worked).

Also note that it is important to delete all of the .aux files from your file that you are working from. In my case I deleted all of the files except for the .tex file.

The last thing to do if you haven't already done so, is to update the TeXstudio settings for building the document. Firstly, go to the "Bibliography" menu item, and at the bottom select Type: Biblatex.

Then go into Options > Configure TeXstudio...

Select "Build", and in the "Meta Commands" panel, find the "Default Bibliograpyh Tool" entry, click the drop down arrow and set it to "txk:///biber".

Now you should be good to go!