Node-red throw err

Error:

When trying to run Node-RED I encountered the following error: Essentially it’s missing the module “express”, as can be seen by the 5 line.

module.js:340
    throw err;
          ^
Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object. (/home/alex/Apps/node-red/node-red-0.9.1/red.js:19:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Fix:

In order to fix it, simply install the missing module using the following command.

npm install express

Note: If you’re getting several of these errors (express, nopt, when, uglify-js, clone, ws, etc) in a row after you’ve download and tried to run Node-RED, you might have missed the step to install all the packages:

npm install --production

Testing Failed: “Failed: error: SBT did not send a reply to our request, perhaps it was killed or failed to start”

Activator error “Failed: error: SBT did not send a reply to our request, perhaps it was killed or failed to start”.

This may be because SBT isn’t installed, SBT is a “simple build tool” for scala which isn’t packaged with the main binaries. You can download and install the latest SBT from the official page, installing it fixed the issue for me in Activator.

Linux Mint: “Could not download all repository indexes”

When running

sudo apt-get update

or attempting to update via the Update Manager in Linux Mint (13), I was fronted with the following error:

Failed to fetch http://packages.linuxmint.com/dists/deb ... tion-en_US Unable to connect to packages.linuxmint.com:http:
Failed to fetch http://packages.linuxmint.com/dists/deb ... slation-en Unable to connect to packages.linuxmint.com:http:
Failed to fetch http://packages.linuxmint.com/dists/deb ... tion-en_US Unable to connect to packages.linuxmint.com:http:
Failed to fetch http://packages.linuxmint.com/dists/deb ... slation-en Unable to connect to packages.linuxmint.com:http:
Failed to fetch http://packages.linuxmint.com/dists/deb ... tion-en_US Unable to connect to packages.linuxmint.com:http:
Failed to fetch http://packages.linuxmint.com/dists/deb ... slation-en Unable to connect to packages.linuxmint.com:http:
Some index files failed to download. They have been ignored, or old ones used instead.

This is caused by missing repositories which are either old, broken or currently down. In order to fix it, simply run:

sudo apt-get update fix-missing

If this option doesn’t work, try changing the repository mirrors with the following guide.

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)

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

VirtualBox (4.26) USB Issue: “unable to enumerate USB device on port n”

After a couple of hours trying to get a USB device (USB-to-Serial FTDI) working in VirtualBox with OSX host and Ubuntu 12.10 guest and receiving an error message similar to the follow:

usb 6-3: new full speed USB device number 24 using ohci_hcd
usb 6-3: device not accepting address 24, error -110
hub 6-0:1.0: unable to enumerate USB device on port 2

It turns out, the issue lies with VirtualBox, when the machine is given more than 1 processor it fails to properly mount any USB device. The only fix I have found to work is to simply reduce the number of processors back to 1. Once it’s returned the USB devices work simply by mounting them the usual way, from the VirtualBox menu > Devices > USB Devices >.

If anyone find a better solution, be sure to comment below.

Raspberry Pi – Web Server (lighttpd)

piweb

Over the weekend I’ve been playing around with the Raspberry Pi and lighttpd in order to get a little webserver running. lighttpd seemed to be a common choice, thanks to it’s simplicity and lightweightness (*possibly not a real word). There’s a plethora of examples of getting it up and running, which isn’t too difficult, most notably the one over at Penguin Tutor covers most everything. This gets you to the point where you have the webserver with mySql and php set up.

However, for me at least, this was only accessible from localhost, i.e I could only view the webserver on the Pi itself. After a few hours messing around, setting up a static ip on the router and making sure that port 80 was open on the router, and configuring lighttpd.conf, I realised that it was certainly a network issue. On further investigation, I discovered that iptables (the linux kernel firewall) was to blame. In order to get the server viewable from outside localhost, and also globally I needed to allow the port in iptables rules, which I did with the following command (ran on the Pi):

 sudo iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT

Now, this command isn’t set in stone, after a reboot it’ll disappear. In order to save the configuration, once it’s working, just run the following commands:

Save the iptables to firewall.conf and place it in /etc/

 sudo iptables-save > firewall.conf
sudo cp firewall.conf /etc/firewall.conf
sudo rm firewall.conf

Now create a file in /etc/network/if-up.d/ called iptables:

sudo nano /etc/network/if-up.d/iptables

And add this content, this will load the iptables config file you saved earlier on boot:

#!/bin/sh
iptables-restore < /etc/firewall.conf

Save and exit (Ctrl+X then press Y and hit return)

Next, make the file executable:

sudo chmod +x /etc/network/if-up.d/iptables

Now you're done, it should be safe to reboot and the iptables will be loaded.

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.

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.

 

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.