2016년 5월 30일 월요일

Glassfish Installation in Debian

Before installation of the glassfish, make sure of java version. the Glassfish V3 need the JDK 1.7.0 and the Glassfish V4 need the JDK 1.8.0.

scwook@debian:~/Download# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

If you need to install the new Java, Please refer to following post



Glassfish V3 Installation

Glassfish V3 can be downloaded from the Oracle web page. Download the Linux/Unix/Mac Installer.


Run the file as superuser.

root@debian:/Downloads# bash ogs-3.1.2.2-unix.sh

When installation menu show up, click next.


Select the Typical Installation and click next.


Change the Installation Directory to /opt/glassfish3 and click next.


Click next.


Click next to start installation.


Set the administrator password and leave the default settings. click next.


Installation is completed. Click exit.


In order to test, try poining your browser to localhost or server ip address.

http://localhost:4848 or http://[Server IP Address]:4848

Glassfish V4 Installation

Download the Java EE 7 Full Platform form the glassfish wep site.



Extract the file and run the glassfish demon.

root@debian:~# unzip glassfish-4.1.1.zip -d /opt/
root@debian:~# cd /opt/glassfish4/bin/
root@debian:/opt/glassfish4/bin# ./asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

In order to test, try poining your browser to localhost or server ip address.

http://localhost:4848 or http://[Server IP Address]:4848

If need, the admin password can be modified by change-admin-password command.

root@debian:/opt/glassfish4/bin# ./asadmin change-admin-password

Enter admin user name [default: admin]>admin

Enter the admin password> [Just remain empty]
Enter the new admin password> [New Password] 
Enter the new admin password again> [New Password]

2016년 5월 25일 수요일

Java Installation in the Debain Jessie

Using update-alternatives command, you can add new Java version in the Jessie. First, check current Java version.

scwook@debian:~$ java -version
openjdk version "1.8.0_72-internal"
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)

Download new Java version form the web page and uncompressing.


http://www.oracle.com/technetwork/java/javase/downloads/index.html


root@debian:~/Download# tar xvf jdk-8u91-linux-x64.tar.gz -C /opt/

Register new Java with --install option

root@debian:~/Download# update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_91/bin/java 1
root@debian:~/Download# update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_91/bin/javac 1

Change Java version with --config option

root@debian:~/Download# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      auto mode
  1            /opt/jdk1.8.0_91/bin/java                        1         manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode
Press enter to keep the current choice[*], or type selection number: 1

Now you have new Java.

root@debian:~/Download# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

2016년 5월 24일 화요일

Raspberry Pi - PIR Motion Sensor test

PIR motion sensor used to detect whether a object which emits infrared radiation has moved in or out the sensor range. If the sensor detect a moving object, it make output signal. More infromation about the sensor can be found in the following web page. In order to test, the wiringPi must be installed.

http://www.dfrobot.com/wiki/index.php/PIR_Motion_Sensor_V1.0_SKU:SEN0171

The test circuit is shown as in figure.

Component

  • Raspberry Pi 2 Model B
  • PIR Motion Sensor (DFROBOT SEN0171)


In order to test, make a simple code which is pirTest.c

#include <stdio.h>
#include <wiringPi.h>

#define PIR 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(PIR, INPUT);

  int input = 0;

  for(;;)
  {
    if(digitalRead(PIR))
      printf("Motion Detected!\n");

    delay(100);
  }

  return 0;
}

Compile and run the program.

pi@raspberrypi ~$ gcc -o pirTest pirTest.c -lwiringPi
pi@raspberrypi ~$ sudo ./pirTest

When a moving object is detected, "Motion Detected" message will be printed.

2016년 5월 20일 금요일

Raspberry Pi - wiringPi Installation

One method to use GPIO Port of raspberry pi is using wiringPi. Basic information and guide is in wiringPi web site.

http://wiringpi.com/

wiringPi can be downloaded form git. So git must be installed first.

pi@raspberrypi ~$ sudo su -
root@raspberrypi:~# aptitude install git
root@raspberrypi:~# exit
pi@raspberrypi ~$ git clone git://git.drogon.net/wiringPi
Cloning into 'wiringPi'...
remote: Counting objects: 657, done.
remote: Compressing objects: 100% (599/599), done.
remote: Total 657 (delta 476), reused 95 (delta 58)
Receiving objects: 100% (657/657), 247.61 KiB | 94 KiB/s, done.
Resolving deltas: 100% (476/476), done.

Build from source code.

pi@raspberrypi ~$ cd wiringPi
pi@raspberrypi ~/wiringPi$ ./build

Pin Layout can be checked by gpio readall command.



Rasbperry Pi - wiringPi 설치

Raspberry Pi에서 GPIO Port를 사용할 수 있는 방법 중 하나는 wiringPi를 이용하는 것이다. wiringPi에 대한 기본적인 사용 방법 및 wiringPi 홈페이지에서 확인할 수 있다.

http://wiringpi.com/

wiringPi는 소스 코드는 git에서 받을 수 있으며, 코드를 빌드 하는것으로 설치는 끝난다. git이 설치되어 있지 않다면 git을 먼저 설치한다.

pi@raspberrypi ~$ sudo su -
root@raspberrypi:~# aptitude install git
root@raspberrypi:~# exit
pi@raspberrypi ~$ git clone git://git.drogon.net/wiringPi
Cloning into 'wiringPi'...
remote: Counting objects: 657, done.
remote: Compressing objects: 100% (599/599), done.
remote: Total 657 (delta 476), reused 95 (delta 58)
Receiving objects: 100% (657/657), 247.61 KiB | 94 KiB/s, done.
Resolving deltas: 100% (476/476), done.

받은 코드를 빌드한다.

pi@raspberrypi ~$ cd wiringPi
pi@raspberrypi ~/wiringPi$ ./build

Pin Layout은 gpio readall 명령으로 확인 할 수 있다. wiringPi는 자체 Pin Map을 사용하는데 wPi로 표시된 부분은 wiringPi에서 사용하는 GPIO 핀 번호이다.

pi@raspberrypi ~$ gpio readall

다음은 Raspberry Pi Model B+ 기준의 Pin Map이다.








2016년 5월 19일 목요일

Raspberry Pi - PIR Motion Sensor 테스트

PIR Motion Sensor는 적외선으로 움직임을 감지하는 센서로 일정한 범위 내에 적외선을 방출하는 물체가 움직일 경우 이를 감지하여 출력 신호로 내보낸다. 센서에 대한 자세한 사양은 다음 웹페이지에서 확인할 수 있으며 테스트를 위해서는 wiringPi가 설치되어 있어야 한다.

http://www.dfrobot.com/wiki/index.php/PIR_Motion_Sensor_V1.0_SKU:SEN0171

테스트 회로는 그림과 같이 PIR Motion Sensor에 5V의 입력 전압을 연결하고 움직임이 감지되었을 때 나오는 출력 전압을 GPIO의 1번에 연결하였다.

회로 및 구성

  • Raspberry Pi 2 Model B
  • PIR Motion Sensor (입력 전압: 3.3 ~ 5V, 출력 전압: High 3V, Low 0V)




테스트를 위해 pir.c 코드를 다음과 같이 작성한다.

#include <stdio.h>
#include <wiringPi.h>

#define PIR 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(PIR, INPUT);

  int input = 0;

  for(;;)
  {
    if(digitalRead(PIR))
      printf("Motion Detected!\n");

    delay(100);
  }

  return 0;
}

코드를 컴파일 하고 실행 시킨다.

pi@raspberrypi ~$ gcc -o pir pir.c -lwiringPi
pi@raspberrypi ~$ sudo ./pir

Raspberry Pi - GPIO input test with Button

Let's turn on LED when a button is pushed. Before the test, wiringPi must be installed.

The test circuit is shown as in figure. one leg of button is connect to 5V output pin and another leg is connect to #1 pin of GPIO and 10k pull-down resistor is used to prevent floating state.  In order to monitor button state, LED is used.

※ Be careful!!. If LED is connected to reverse polarity, it will be broken. Long leg is positive(+) and short leg is negative(-).

Component
  • Raspberry Pi 2 Model B
  • Push Button
  • LED(Operating Voltage: 1.8V ~ 2.3V)
  • Resistor 250Ω, 10k 


In order to test, make a simple code which is buttonTest.c

#include <wiringPi.h>

#define LED 4
#define BUTTON 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);

  digitalWrite(LED, 0);
  int input = 0;

  for(;;)
  {
    if(digitalRead(BUTTON))
      digitalWrite(LED, 1);
    else
      digitalWrite(LED, 0); 

    delay(100);
  }

  return 0;
}

Compile and run the program.

pi@raspberrypi ~$ gcc -o buttonTest buttonTest.c -lwiringPi
pi@raspberrypi ~$ sudo ./buttonTest

When the button is pushed, LED will be turned on.