Wednesday, June 18, 2014

Getting Upstart to start services when an interface is up on Centos 6

Apparently upstart is not fully integrated to Centos 6.

For instance having a service like:

start on (net-device-up INTERFACE=lo)

will not work.

The solution which maintains compatibility with updates:

Create /sbin/ifup-local:

#!/bin/sh
initctl emit --no-wait net-device-up INTERFACE=$1

and make it executable.


Friday, April 18, 2014

Arduino ebay clone droubles...

So wanted to try these arduino clones from ebay and have some feedback.

The one I got has both male and female connectors for pins. I placed my ethernet shield on top of it and tried to power it up with no luck. Apparently the ICSP is up side down! The solution is to either cut the ICSP pins from the controller and the shield and  then wire manually to the shield or rotate the shield 180o and wire any additional pins from the controller to the shield. Pins as shown here from the shield should be wired to pins 12,VCC,13,11,RESET and GND in order for everything to work that is if you choose the former solution. I haven't tested which pins are required for the other solution. Keep in mind that if you simply rotate the shield (180o) you still may run into trouble because more pins are used by the (W5100) ethernet shield.

As a last reminder make sure not to use pins 4 and 10 as they are used by the shield as well.

The error you may get is a 0.0.0.0 address from Ethernet.LocalIP().

Sunday, January 19, 2014

ZTE H108NS & telnet

Some issues you may encounter when trying to telnet ZTE H108NS modem:

1. You cannot connect at all

In that case from the Web UI go to Access Management -> ACL and edit or create a rule for the LAN interface which allows telnet connections from your subnet.


2. Password is not accepted

The web ui password may differ from the console password but there is a way... Go to Maintainance -> Firmware and press the ROMFILE BACKUP button to download a copy of the configuration parameters. View the (xml) file with any text editor and locate the admin user entry under Account:


<account>
<entry0 br="" username="admin" web_passwd="yourwebuipasswd">console_passwd="telnetpasswdhere" display_mask="FF FF FF FF FF FF FF FF FF" />
  ....... more entries which hopefully are not the same in all modems but I doubt it ....... </entry0> </account>

The telnet password is stored in the console_passwd attribute.

Thursday, January 16, 2014

Compiling Grive on Centos with unsupported Boost/CMake version.

In the absence of a Google Drive client version for linux, I tried to compile grive (0.3.0-pre) which is an open source client using the Google APIs:

Install all dependencies first, try yum install gcc-c++ expat-devel json-c-devel libgcrypt-devel curl-devel

If the CMake version is old, get the appropriate version of CMake and do not install it:

#cd /usr/local/src
#wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2-Linux-i386.sh
#./cmake-2.8.10.2-Linux-i386.sh .
That's for i386, it seems for x64 you need to compile it from source. 

If the Boost version is older and cmake complains about it:

1. Download the appropriate version of boost (most current right now is 1.55) and extract it to /usr/local/src:

#tar -xvf boost_1_55_0.tar.bz2
#cd boost_1_55_0
#./bootstrap.sh --prefix=/usr/local/src/boost_1_55_0/lib/
#./b2  --build-dir=/usr/local/src/boost_1_55_0/lib/ --with-system --with-filesystem --with-program_options --with-test

2. Download and compile yajl. (./configure && make). Assuming that it's located at /usr/local/src/yajl

3. Back to the Grive directory. I should mention that I removed bgrive from CMakeLists.txt because I did not need it. You must add the following commands in CMakeLists.txt
INCLUDE_DIRECTORIES(/usr/local/src/boost_1_55_0)
INCLUDE_DIRECTORIES(/usr/local/src/yajl/build/yajl-2.0.5/include/)
link_directories(/usr/local/src/yajl/build/yajl-2.0.5/lib/)
link_directories(/usr/local/src/boost_1_55_0/stage/lib/)
Then run:
#../cmake-2.8.10.2-Linux-i386/bin/cmake -D BOOST_ROOT:FILEPATH="/usr/local/src/boost_1_55_0"  -D Boost_LIBRARY_DIRS:FILEPATH="/usr/local/src/boost_1_55_0/stage/lib" .
 (There is a dot as the very last argument).

Try to run make.

If you get any errors about ambiguous log entries, do the following:

Assuming you have vim, edit grive/src/main.cc and type as an editor command: %s/log::/gr::log::/

If you don't have vim what you need to do is to change all instances of log:: to gr::log::

Finally if you still get errors like "undefined reference to `gr::Json::Json(long const&)" make the trivial edits to libgrive/src/drive/State.cc as described here.

After thoughts:

To install to another binary compatible machine without rebuilding, you need to copy the compiled libraries and install the dependencies as well:  

Install depedencies: #yum install expat json-c libgcrypt curl

Copy all compiled libraries to /usr/local/lib[64]:

  1.  From /usr/local/src/boost_1_55_0/stage/lib/
    • All *.so.1.55.0
  2.  From /usr/local/src/yajl/build/yajl-2.0.5/lib/
    •  libyajl.so.2.0.5

Create symbolic links for all the libraries you've copies and use the library name without the appended version as the link name, eg:

#ln -s libboost_filesystem.so.1.55.0 libboost_filesystem.so

Copy the grive binary to /usr/local/bin or any convenient location

Finally run ldconfig /usr/local/lib[64]