Categories
Command Line HowTo Linux Ubuntu

ERROR: Failed to build gem native extension.

While attempting to install a package from gem, I encountered this issue:

sudo gem install dashing
Building native extensions.  This could take a while...
ERROR:  Error installing dashing:
	ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
	from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
	from extconf.rb:2:in `
' Gem files will remain installed in /var/lib/gems/1.9.1/gems/eventmachine-1.2.3 for inspection. Results logged to /var/lib/gems/1.9.1/gems/eventmachine-1.2.3/ext/gem_make.out

Simply to solve this you just need to install ruby-dev packages on ubuntu:

sudo apt-get install ruby-dev
Categories
HowTo Programming

Microchip MPLAB X – Link Error: region is full / section overlaps section

While trying to compile some code on MPLAB X I came across this link error, stating that my #pragma config bits were full or sections of them were overlapping other sections.

/Applications/microchip/xc16/v1.11/bin/bin/../bin/elf-ld: Link Error: region FOSC is full (dist/default/production/can_to_serial.production.elf section __FOSC)
/Applications/microchip/xc16/v1.11/bin/bin/../bin/elf-ld: Link Error: region FWDT is full (dist/default/production/can_to_serial.production.elf section __FWDT)
/Applications/microchip/xc16/v1.11/bin/bin/../bin/elf-ld: Link Error: region FBORPOR is full (dist/default/production/can_to_serial.production.elf section __FBORPOR)
/Applications/microchip/xc16/v1.11/bin/bin/../bin/elf-ld: Link Error: section .config_MCLRE%10 [f80004   -> f80005  ] overlaps section __FWDT [f80004   -> f80005  ]
/Applications/microchip/xc16/v1.11/bin/bin/../bin/elf-ld: Link Error: section .config_WDT%11 [f80002   -> f80003  ] overlaps section __FOSC [f80002   -> f80003  ]
/Applications/microchip/xc16/v1.11/bin/bin/../bin/elf-ld: Link terminated due to previous error(s).
make[2]: *** [dist/default/production/can_to_serial.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

After some time scratching my head I realised the issue was that configuration bits were being set twice. Simply I had to remove them. I also moved all configuration bits to a separate header which is only included in the main c source file to avoid future issues.

Code causing the error:

main.c
#include 
#include 
#include 

// FOSC
#pragma config FPR = XT_PLL4            // Primary Oscillator Mode (XT w/PLL 4x)
#pragma config FOS = PRI                // Oscillator Source (Primary Oscillator)
#pragma config FCKSMEN = CSW_FSCM_OFF   // Clock Switching and Monitor (Sw Disabled, Mon Disabled)

// FWDT
#pragma config FWPSB = WDTPSB_16        // WDT Prescaler B (1:16)
#pragma config FWPSA = WDTPSA_512       // WDT Prescaler A (1:512)
#pragma config WDT = WDT_OFF            // Watchdog Timer (Disabled)

// FBORPOR
#pragma config FPWRT = PWRT_64          // POR Timer Value (64ms)
#pragma config BODENV = BORV20          // Brown Out Voltage (Reserved)
#pragma config BOREN = PBOR_ON          // PBOR Enable (Enabled)
#pragma config LPOL = PWMxL_ACT_HI      // Low-side PWM Output Polarity (Active High)
#pragma config HPOL = PWMxH_ACT_HI      // High-side PWM Output Polarity (Active High)
#pragma config PWMPIN = RST_IOPIN       // PWM Output Pin Reset (Control with PORT/TRIS regs)
#pragma config MCLRE = MCLR_DIS         // Master Clear Enable (Disabled)

// FGS
#pragma config GWRP = GWRP_OFF          // General Code Segment Write Protect (Disabled)
#pragma config GCP = CODE_PROT_OFF      // General Segment Code Protection (Disabled)

// FICD
#pragma config ICS = ICS_PGD            // Comm Channel Select (Use PGC/EMUC and PGD/EMUD)

// Configuration settings
_FOSC(CSW_FSCM_OFF & FRC_PLL16); // Fosc=16x7.5MHz, Fcy=30MHz
_FWDT(WDT_OFF);                  // Watchdog timer off
_FBORPOR(MCLR_DIS);              // Disable reset pin

int main(){
// ... code continues here

Altered code:

main.c
#include 
#include 
#include "config.h"
#include 

int main(){
// ... code continues here
config.h
// FOSC
#pragma config FPR = XT_PLL4            // Primary Oscillator Mode (XT w/PLL 4x)
#pragma config FOS = PRI                // Oscillator Source (Primary Oscillator)
#pragma config FCKSMEN = CSW_FSCM_OFF   // Clock Switching and Monitor (Sw Disabled, Mon Disabled)

// FWDT
#pragma config FWPSB = WDTPSB_16        // WDT Prescaler B (1:16)
#pragma config FWPSA = WDTPSA_512       // WDT Prescaler A (1:512)
#pragma config WDT = WDT_OFF            // Watchdog Timer (Disabled)

// FBORPOR
#pragma config FPWRT = PWRT_64          // POR Timer Value (64ms)
#pragma config BODENV = BORV20          // Brown Out Voltage (Reserved)
#pragma config BOREN = PBOR_ON          // PBOR Enable (Enabled)
#pragma config LPOL = PWMxL_ACT_HI      // Low-side PWM Output Polarity (Active High)
#pragma config HPOL = PWMxH_ACT_HI      // High-side PWM Output Polarity (Active High)
#pragma config PWMPIN = RST_IOPIN       // PWM Output Pin Reset (Control with PORT/TRIS regs)
#pragma config MCLRE = MCLR_DIS         // Master Clear Enable (Disabled)

// FGS
#pragma config GWRP = GWRP_OFF          // General Code Segment Write Protect (Disabled)
#pragma config GCP = CODE_PROT_OFF      // General Segment Code Protection (Disabled)

// FICD
#pragma config ICS = ICS_PGD            // Comm Channel Select (Use PGC/EMUC and PGD/EMUD)
Categories
HowTo Linux Raspberry Pi Ubuntu

Unknown encoder ‘libx264’

If you encounter a problem similar to the following, where you’re missing the libx264 codec try this solution.

avconv -r 10 -i image%06d.jpg -r 10 -vcodec libx264 -crf 20 -g 15 timelapse1.mp4

avconv version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
built on Apr 2 2013 17:02:16 with gcc 4.7.2
Input #0, image2, from 'image%06d.jpg':
Duration: 00:02:21.20, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 2592x1944, 10 fps, 10 tbr, 10 tbn, 10 tbc
Unknown encoder 'libx264'

In order to acquire libx264, on Debian based distros (Ubuntu, Mint, Raspbian) install the following package:

 sudo apt-get install libavcodec-extra-53
Categories
Command Line HowTo Linux Ubuntu

what(): Serial Port failed to open: open: Permission denied

what():  Serial Port failed to open: open: Permission denied

Trying to get access to your serial port without the need for running whatever program as sudo or root? You’re probably not in the dialout group, if that’s the case, here’s the fix:

First, check you aren’t in the group:

groups alex

This will list all the groups the user is in, here the user is called ‘alex’, just substitute that for your own username. If the output doesn’t contain the dialout group, keep going. If it does, you might have another issue which this isn’t likely to solve.

sudo gpasswd --add alex dialout

This command will add the user ‘alex’ to the ‘dialout’ group. Once that’s done you’ll need to logout and back in again for the effects to take place.

Categories
Fedora HowTo Linux Ubuntu

Team Fortress 2 Segmentation Fault – Steam for Linux

After getting invited to join the Steam Beta for Linux, (after weeks of using the bypass) I decided to get playing some TF2. After the long install and download I booted it up. The Value splash screen with the tap-guy loads and the menu begins to load, but once it has finished, the game closed and returned to my desktop.

So I tried again, but this time ran steam through terminal in order to get some error messages. The following is what I found to occur when the game crashed:

response: CrashID=bp-ca59d62f-9c2b-47e4-8cd9-9d0b02121212
/home/alex/Steam/SteamApps/username/Team Fortress 2/hl2.sh: line 72: 4811 Segmentation fault ${GAME_DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"
Game removed: AppID 440 "Team Fortress 2", ProcID 4811
saving roaming config store to 'sharedconfig.vdf'
roaming config store 2 saved successfully

To fix it, there’s a pretty simple solution. This is to add the option “-nojoy” to the launch options of the game:

  1. Right click Team Fortress 2 in the Library pane of Steam.
  2. Click “Properties”.
  3. Click “Set Launch Options”
  4. Add the following: -nojoy
  5. Hit OK and launch the game, everything should be working!

If you’re running Fedora, some folk have found another solution to this fix, if the previous doesn’t work:

sudo setsebool -P allow_execheap 1

Where it seems SELinux isn’t allowing the game to start for whatever reasons.

 

Categories
Android Featured HowTo

How To Take Screenshots in Jelly Bean (Android 4.1.x)

To take a screenshot in Android 4.1.x (Jelly Bean) the same button combination from Ice Cream Sandwich (ICS) works:

Hold Volume Down & Power buttons for roughly a second.

You should know when the screenshot has been taken, the screen will flash white and a translation effect of the screen will take place. The screenshot should be saved in a folder /Pictures/Screenshots on your phones internal SD card, it’ll show up in the Gallery app under a “Screenshots” folder.

Taking a screenshot will also causes a notification (similar to in ICS), which display slightly different to those found in ICS,  they now show a cropped preview of the screenshot you’ve just taken.

 

This process works in Cyanongenmod 10, running on my Samsung Galaxy S (I9000) and should translate to all other phones and ROM’s. If it doesn’t be sure to leave a comment below.

 

 

Categories
Command Line HowTo Linux Ubuntu

HowTo: Restore Your Default .bashrc File in Ubuntu

If you’ve managed to find yourself deleting, overwriting or generally messing up your profiles .bashrc file there’s a really easy way to fix it. A default version of the file can be found under “/etc/skel/.bashrc”, simply coping that over your profiles one (found in your home directory) will restore it to default. Make sure to also source the file if you want to continue using it under that terminal or close and re-open the terminal.

I managed to have a blank bashrc after upgrading Ubuntu with a separate /home partition, while deleting all the old config files I must have also removed this.

The following commands should do this for you, be sure to make a back up of your current .bashrc file too, just to be safe.

cp ~/.bashrc ~/.bashrc.bkup
cp /etc/skel/.bashrc ~/
source .bashrc

You should be now back to a default terminal experience and continue to customise it how you like!

Categories
HowTo Linux Ubuntu

mlbviewer 2012 Installation guide for Ubuntu (MLB.TV on Linux)

Download mlbviewer:

Go and grab the latest version from the sourceforge page below:

http://sourceforge.net/projects/mlbviewer/

Unrar:

tar -zxvf mlbviewer2012.tar.gz

It doesn’t require any installation but you will need a few extras and the easiest way to install them is shown below:

Download PyXML:

PyXML is an XML processing tool for python which this project uses, sometimes it can be tricky to install python modules so we’ll be using setuptools which you can get from the link below.

If you’re unsure of what version you need, open terminal and type “python”, this will show the version of python you’re running. Mine was 2.7.4 so I downloaded “setuptools-0.6c11-py2.7.egg” I would imagine yours would be similar.

http://pypi.python.org/pypi/setuptools#cygwin-mac-os-x-linux-other

Once you have it, run it (replacing the version you downloaded for the one here):

sudo sh setuptools-0.6c11-py2.7.egg

Now to install PyXML it’s as simple as running:

sudo easy_install pyxml

That’s it, you’re done.

Optional – Install MPLAYER2:

MPLAYER2 offers at lot of advantages over MPLAYER however we’re most interested in it because it offers better streaming support and handle stream rate switches (important if you enable adaptive streaming in nexdef mode).

sudo add-apt-repository ppa:motumedia/mplayer-daily
sudo apt-get update
sudo apt-get install mplayer2

(Thanks to – Web Upd8)

Optional – Install mlbhls (for nextdef | HD):

Instructions as per in REQUIREMENTS-2012.txt in the mlbviewer package.

You’ll also need some extra packages which aren’t stated:

sudo apt-get install libconfig-dev libcurl4-gnutls-dev
svn co https://mlbtv-hls-nexdef.googlecode.com/svn/branches/experimental mlbhls
cd mlbhls
make
sudo cp mlbhls /usr/bin

Once that’s done, you should be able to get the higher bitrate streams too!

Using mlbplayer:

Setup:

The first time you run mlbviewer it will generate a config file which you’ll need to enter your Premium MLB.TV account details in, running mlbviewer will tell you where this file is located:

python mlbviewer.py

Go edit the file and enter your email as the “user” and your password after “pass”.

Now re-run mlbviewer and it should start up!

python mlbviewer.py

Sit back and enjoy!

Categories
Command Line HowTo Linux Ubuntu

fatal error: libconfig.h: No such file or directory | Ubuntu 12.04

If you’re getting the following error:

fatal error: libconfig.h: No such file or directory

Then you’re probably missing the libconfig-dev package from your system. Simply run the following command and it’ll fix it:

sudo apt-get install libconfig-dev
Categories
Arch Linux Fedora HowTo Linux Ubuntu

Heat Management in Linux

When you first switch from Windows or OSX to Linux, one of the things you’ll probably first notice (especially if you’re using a laptop) is that it can run considerably hotter than the alternatives. There are a few things you can do to remedy this, however. The following software packages help you keep track of and cool down your laptop/netbook, how much will depend per machine but my HP Pavilion dm1 goes from around 60-70degrees without these tools installed to around 50-60degrees and the same goes for my older Acer Travelmate which dropped from 70-80degrees to 60-70degrees. Hopefully this information will help you shave off 10degrees from your laptop, making it cooler, easier to use and hopefully extending its life a little too!

lm-sensors

First thing that you’re going to want to do is be able to see what the temperature readings of the components (that have temperature sensors) inside your computer/laptop. This can be done by installing lm-sensors:

sudo apt-get install lm-sensors

Now you’ll want to run the script which probes all the possible sensors in your laptop:

sudo sensors-detect

You’ll be asked if you want to scan for sensors and what not, follow the on-screen instructions, mostly just pressing enter, if YES is written in capitals this is the default answer and it will scan. After several times it’ll ask you if you want to save the changes, make sure you do and then you’re done.

Now you can see the temperature the sensors are reading by using the following command:

sensors
cpufreq

cpufreq is a utility which scales the frequency of the CPU, either by monitoring the systems status (if it needs more, it’ll get more) or by user controlled settings. This essentially underclocks the CPU while it isn’t in use, reducing power usage and thus heat.

Installation:

sudo apt-get install cpufreq

The best choice would be to set cpufreq to on-demand (default) or to power-saving. Alternatively, if you’re using a laptop or netbook let jupiter take care of it for you:

jupiter

Jupiter is a light weight power and hardware control applet for Linux. It is designed to improve battery life of a portable Linux computer by integrating with the operating system and changing parameters of the computer based on battery or powered connection.

Additionally, Jupiter provides quick access to some of the commonly needed hardware controls like screen output and resolution, WIFI, and bluetooth.

If you use Linux on a portable computer, let Jupiter take the effort out of going mobile.

By using this to intelligently control the CPU frequency when on battery and AC along with the tuning to the kernel and hardware, it can make a huge difference to the temperature expelled by your laptop.

Ubuntu 11:10 installation instructions: here

Graphics Card Drivers

If you have a dedicated graphics card in your laptop, you’ll also be better off installing the proprietary graphics drivers provided by the hardware vendor. While the open source ones do an awesome job of getting the card to work, more often than not they don’t include any control over the frequency scaling and keep the card running at max, along with all those other little features the card has, they’ll probably all always be running.

Nvidia : Link
ATI/AMD : Link