Friday, August 19, 2016

Raspberry Pi Development Server for Home



We all got development server at our work. But we all like to have a dev server for our cool stuff we do at home. It may be freelance or pure technical interests.
We know we can set it up, but how and the associated complexities keep us form really setting up a dev server for home.

So let's see how we can do this on a Raspberry-pi.

What you need

  • Raspberry-pi - that's the whole point, right :) 
  • A Micro USB charger - for the PI
  • An Ethernet cable - for initial connectivity. Later with a wifi dongle you can set-up a wifi connection. 
  • A microSD card (minimum 8GB, and cards up to 32GB seem to work fine)
These will also come in handy during the initial setup:
  • A USB keyboard
  • An HDMI cable and monitor



  1. Install Raspbian on PI.
  2. Install remote desktop software on PI (it's easy to connect to PI this way than using mouse/keyboard/monitor whole setup)
  3. setup ssh on PI
  4. Install a web server
  5. Setup access to your local server through internet. You can user NgRok for that.
  6. Install your preferred dev environment(java based/node.js based etc)
  7. Setup a project on Bit-bucket
  8. Setup access from PI to your Bit-bucket project
  9. Configure PI to pull latest code from the Bit-bucket.
  10. Now you are there push you code to Bit-bucket and build it on PI 


So that's all you need to do. If you already got experience on this, you can set it up easily.
Otherwise just see the detailed instructions on most of these steps on this blog post
How to Turn Your Raspberry Pi Into a Development Server .


Share Article : Raspberry Pi Development Server for Home
Share/Save/Bookmark

Wednesday, November 25, 2015

Make Raspberry Pi Serial port available over Ethernet


Make Raspberry Pi Serial port available over Ethernet

To do this on raspberry-pi first install socat.

Then run following commands.

  1. On the raspberry-pi  run following command to redirect tcp data on port 54321 to serial port ttyAMA0

sudo socat tcp-l:54321,reuseaddr,fork file:/dev/ttyAMA0, nonblock, raw, waitlock=/var/run/ttyAMA0.lock

  1. On other connecting(client) linux machine run following command to create a virtual serial port and direct it to tcp port of the raspberry-pi 54321 port.

sudo socat pty,link=/dev/ttyAMA0,waitslave tcp:10.42.0.3:54321

  1. Now when you write to virtual serial port on the linux pc it get to the actual serial port of raspberry-pi over ethernet connection. However this seems to be a blocking the port.
  2. Checked on pi4j read/write on same port and read hangs. So as a solution to this create another virtual serial port on raspberry pi and map it to actual serial port. Then read/write to it. It fixed the problem.

sudo socat PTY,link=/dev/ttyAMA0 PTY,link=/dev/ttyAMA1

Srinath Gamage has attached the following document:
Make Serial port available over Ethernet
Google Docs: Create and edit documents online.Logo for Google Docs

Share Article : Make Raspberry Pi Serial port available over Ethernet
Share/Save/Bookmark

Monday, November 23, 2015

Serial Communication Test on Raspberry-pi


Serial Communication Test on Raspberry-pi

  1. First we have to disable OS from using serial port

1.png

2.png

3.png

4.png

  1. Just for the testing; Connect TxRx pin 8 and 10 on pin header with a jumper(cable).

8-10.png

  1. Then write to Serial port with following python code.

#!/usr/bin/env python

import time

import serial

ser = serial.Serial(

            port='/dev/ttyAMA0',

            baudrate = 9600,

            parity=serial.PARITY_NONE,

            stopbits=serial.STOPBITS_ONE,

            bytesize=serial.EIGHTBITS,

            timeout=1

)

counter=0

while 1:

            print counter

            ser.write('Write counter: %d \n'%(counter))

            time.sleep(1)

            counter += 1

write.png

  1. Use following code to read it

#!/usr/bin/env python

import time

import serial

ser = serial.Serial(

                   port='/dev/ttyAMA0',

                   baudrate = 9600,

                   parity=serial.PARITY_NONE,

                   stopbits=serial.STOPBITS_ONE,

                   bytesize=serial.EIGHTBITS,

                   timeout=1

               )

counter=0

while 1:

  x=ser.readline()

  print x

read.png

Srinath Gamage has attached the following document:
Serial Communication Test on Raspberry-pi
Google Docs: Create and edit documents online.Logo for Google Docs

Share Article : Serial Communication Test on Raspberry-pi
Share/Save/Bookmark

Wednesday, November 11, 2015

Add current RSA keys for password less login


cat .ssh/id_rsa.pub | ssh remoteLoginUser@172.1.1.1  'cat >> .ssh/authorized_keys'

Share Article : Add current RSA keys for password less login
Share/Save/Bookmark