Book Review: The Time Paradox

Today I finished reading the book “The Time Paradox” by Philip Zimbardo & John Boyd. I bought this book a couple of months back in train Station book shop when I wanted a book that can give a different perspective from other than what I currently have. With quick glance of the back cover I was impressed with this book. I did not know much about the authors until then and during half of my journey in the book I started watching some tedtalks of Philip Zimbardo and I also came to know about the Standford Prison Experiment.

Basically The authors are trying to explain the Time. Its not the ticking time but more a psychological time perspective of individuals and how that affects or improve their life. The time perspective of the people are classified in to

  • Past positive
  • Past Negative
  • Present Hedonistic
  • Present Fatalistic
  • Futuristic
  • Transcedental Futuristic

They derive these six perspective using ZTPI and TFPI Surveys and using these six perspective and the ratio of these perspective on individuals they explain in detail about the the cause and effect and much more. Each chapter contain quotes related to time and perspective from thinkers around the world and how they see world w.r.t Time. Finally they explain about the ideal time perspective and habits to achieve such view.

The Authors explain how a nation suceed or utterly fail just because of their time perspective. Overall it was a nice experience to read the whole book.

 

Makeself – DIY App Installer Linux

Making an application installer for Linux is much vague word as compared to Windows, this is because there exist a huge list of operating System. Even though you can narrow them down to a few distro based on derivatives you can never ensure if it will all work well unless you have tested it all yourself. When you pack your software you either settled down to on distro say Debian or Ubuntu or release multiple package for Redhat etc. Even then the nature of the software has become so complex that you need to learn a lot about the specifics of package management in detail to get it right. Like always it would be nice to have an universal solution.


I found makeself to be an interesting tool, surprisingly after I discovered it I realised there are many apps that were packaged using it. Now without much delay lets see how to use it.

apt-get install makeself

For this example I took the odoc project that I created sometime ago.

git clone https://github.com/codelectron/odoc

Now lets create a sandbox folder where we will create the binary app of our odoc .

cd odoc
mkdir sandbox
cp -a odoc sandbox
cp -a script sandbox

Now lets say what to do in the installer script.

cd sandbox
----------
vim postinstall.sh
#!/bin/bash
cp script/odoc /usr/local/bin
chmod 777 /usr/local/bin/odoc
cp -a odocs /usr/local/share 
----------
chmod 777 postinstall.sh
cd ..

Now we have defined what to do in the installer, our next step is to create it.


makeself sandbox odoc-install.run "ODOC" ./postinstall.sh

Now you can copy the odoc-install.run  to any Linux system and install it easily.

For more Information visit here or type make makeself in a terminal.

Virtual CAN Bus – Embedded Linux

When working in the Embedded field, one often encounters situation where the hardware will not be available and the software should be developed. Or let say the software development should happen independant of the hardware availability. There are many reasons why this happens but it defintely happens. Some use emulator to run the entire operating system, some use wrapper functions to cover the hardware calls and simulate rest of the code. There are many solutions depending on the problem. One of the problem what I recently encountered was with CAN bus. I was required to code an application which uses a CAN bus but without a real hardware which has a CAN bus in it. In this case you can use wrapper calls, or get a USB CAN dongle and use it instead. I was trying to find a different one. I often read  lkml.org and once I simply brushed through lines talking about virtual CAN. But that was quite sometime back so I vaguely searched and I got the solution.And Yes its virtual CAN or VCAN like “Yes VCAN” Lol.

In Linux CAN interface is handled using SocketCAN where a CAN bus is viewed as a Berkeley socket. A CAN interface can be configured just like an Ethernet interface. If you have a CAN interface in your board and if Linux detects it, then you can view it like this

/sbin/ifconfig -a

In case you dont have any hardware CAN, then you can create a virtual CAN interface and use it exactly like standard CAN interface.  This is how you create a virtual can. I tried these commands in a Debian LXDE Desktop which by default had CAN Driver installed as part of the kernel modules.

modprobe vcan  
ip link add dev can0 type vcan  
ip link set up can0

The modprobe command loads the kernel module by resolving dependency, the ip command is used to configure device, routes and policy of a network device. For CAN devices you can configure bitrate too but since Im using the virtual CAN these things dont matter much virtually.

Install CAN utilities as follows

apt-get install can-utils

Dump the CAN traffic using candump. This tool prints everything that comes out of CAN bus which it is listening to.

candump can0

Send some data using cansend

 cansend can0 5A1#11.22.33.44 

Interestingly since CAN is a network interface you can also use Wireshark to sniff the packets. If you want to simulate a stream of CAN packets then checkout canplayer.