Dec 10, 2014

Current time in terminal - debian

Create a file 'now' and copy paste the following into it.

#!/bin/bash
date '+%A %D %X'

then save it and give executable permission to that file.
chmod +x ./now

Now copy that file to any of the system path. (echo $PATH gives the system paths)
cp ./now /usr/local/bin

that is it, next open a new terminal and type now and press enter. It will give the current time
Thursday 12/11/14 16:28:08

With a bit formatting we can have this printed in different colors.

#!/bin/bash
now=$(date '+%A %D %X')
red='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${red}$now${NC}"


Nov 29, 2014

Solve rubik's cube

Here is my demo,.


Solve the rubik's cube..
 * F' U L' U' - to make a white cross

White in bottom and other colors are opposite
  * R' 2D R D - brings white right then
  * R' D' R - do this if white is already right
  * D' R' D R

Middle layer: (top middles without yellow)
  * Top mid to right:
     U R U' R' U' F' U F
  * Top mid to left
     U' L' U L U F U' F'

Top Layer:
Ignore the corners and look at the center
* To create a cross:
  *  F R U R' U' F' which creates a  bar
  * try above until it creates a bar
  * then keep the bar horizondal
  * try the same above algorithm until you getcross

* Line up atleast two
  * Either line on side and back, or lines front and back
  * R U R' U R 2U R' U
  * Find out one that is lined up. It doesn't need to be oriented
  * Keep that in top right
  * U R U' L' U R' U' L - try until proper positions.
  * R' D' R D

Nov 26, 2014

Programming arduino uno with avr pocket programmer

Make the setup as shown in figure.
Image credits to https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader
  1. Select 'Power Target' in 'AVR Pocket Programmer'.
  2. git clone https://github.com/arunkumarv31/rtos
  3. cd compile 
  4. Edit Makefile. Comment avrdude line with option arduino and uncomment line with option usbtiny in burn section.
  5. make
  6. sudo make burn
  7. sudo (or be root) is mandatory. Because linux may not show error as permission denied, instead it will show initialization failed, rc=-1. 
If you have your own code and hex file. Burn the hex with this command -
  • sudo avrdude -F -V -c usbtiny -p atmega328p -D -b 115200 -U flash:w:main.hex 
This same procedure can be used with other boards.
For Arduino mega2560 sudo avrdude -F -V -c usbtiny -p atmega2560 -D -b 115200 -U flash:w:main.hex 
Edit inc/common.h and Makefile in rtos if you are using my codes.

Jul 7, 2014

upload bootloader to mega2560 using Uno

Run arduino ide (arduino 1.5.7 is required. won't work with older versions of software )
Connect the uno board to USB.
Open arduino ISP from examples.
Compile it and upload to uno board. (Board:Uno, Programmer Arduino as ISP)

Now make the following connections with the mega board. It is basically interfacing boards through SPI (MOSI, MISO, SCK) and SS(UNO) to RESET (MEGA2560)

UNO       MEGA2560
10 --------> 53
11 --------> 51
12 --------> 50
13 --------> 52

+5V --------> +5V
GND -------> GND

Select Board: Mega2560
Processor: 2560
Programmer: Arduino as ISP and then Tools > burn bootloader.Thsi time don't click upload.

Now connect mega2560 to PC and open a blink program. Compile and upload the program.

May 2, 2014

Install debian iso with usb

Creating a startup disk is simple in linux. No third party apps like start-up disk creator or unetbootin is required. Linux base command dd is enough.
That is it. A base kernel will get installed. While installing provide an internet connection so that it will automatically fetch required packages online. The installation will check for available connections ( Ethernet/WiFi ) while installing.

I think this works with almost all main linux distros

Ref: https://wiki.archlinux.org/index.php/Putting_installation_media_on_a_USB_key

Mar 20, 2014

Some tech reminiscence

Was formatting my PC and I got some old docs.
Btech final year project report: Secure Wireless Communication System
and
DESD ( CDAC ) seminar report: PageRank

Jan 21, 2014

An RTOS from the ground up

Just developed an RTOS from the ground up. It is still in the primitive stage but has got all the requirements of an RTOS. I used gcc toolchain to compile the sources and an Atmega328P (AVR) microcontroller to test it.

Source code is made available in my github. https://github.com/arunkumarv31/rtos

I have four infinite functions and the RTOS scheduler select the tasks to run and switches among them.
We can create tasks like this

createTask ( &function_1, "fun_one", 1, 200 );
 

createTask ( &function_2, "fun_two", 2, 200 );
.

.
createTask ( &function_n, "fun_three", n, 200 );


where the first parameter is the address of the function / task, the second parameter is its name. This name is used as the task identifier to change the attributes of a task, the third parameter is the priority of the task and the last parameter is the stack space required for the task.

A user function / task can be something like this. usually it will be an infinite loop.

void function_2 ( void )
{
  while (1)
  {
      changePriority ( "fun_one", 3 );
      changePriority ( "fun_two", 5 );
      changePriority ( "fun_three", 2 );
      changePriority ( "fun_four", 4 );
     
      printf ( "function_2\n" );
  }
}


The scheduler follows "fixed priority pre-emptive scheduling". And it always executes the highest priority task. So to give multitasking effect, i.e to preempt the current task and to execute other tasks we need to change the priority of the other tasks  in the current task with changePriority( "fun_one", 2 ) method.

If two or more tasks has the same priority which is the highest priority then ithe scheduler will execute the task first created.

changeStatus ( "fun_three", WAIT ) is used to change the status of a task. Here I have three status RUN, TERMINATE and WAIT.

deleteTask ( "fun_two" ) will delete the task and it will no longer be available to execute.

Jan 13, 2014

Saving SP in atmega328p

Context switching is one of the core component of parallel processing. I was trying to implement one such. Storing the SP to data space is something noteworthy.

For Web Developer

  open -a "Google Chrome" --args --disable-web-security