Wednesday, October 7, 2015

Publishing (BCC) Error - Role '/EPublishing/EPub-Super-Admin'

Follow bellow steps to solve the issue.

1. Clean the source code and build the code using favorite IDE. 2. Set the source code publishing data source. 
     This data source should be the similar data source name given in your application server.
     /config/atg/dynamo/service/jdbc/DirectJTDataSource_publishing.properties

     DirectJTDataSource_publishing.properties
     JNDIName=publishingDS
     $class=atg.nucleus.JNDIReference


3.  Run the publishing run assembler for your project.
      Ex :  /ATG-HOME/home/bin/runAssembler -server   /location-of-your-ear-deployment-path/your-publishing-ear-name.ear -layer  preview  -m DCS-UI.Versioned PubPortlet DafEar.Admin  DCS-UI.SiteAdmin.Versioned 

4. Configure data source in fake server.
    Fake servers can be used to directly connect with data bases and  import data.
    My Fake server name is my-fakexa
    My Fake server located at /ATG-HOME/home/servers/my-fakexa
    Brows the location /ATG-HOME/home/servers/my-fakexa/localconfig/atg/dynamo/service/jdbc

   Create property files called JTDataSource.properties and FakeXADataSource.properties with bellow content


    JTDataSource.properties
    $class=atg.service.jdbc.MonitoredDataSource
    dataSource=/atg/dynamo/service/jdbc/FakeXADataSource


    Now create FakeXADataSource.properties file with bellow content


   FakeXADataSource.properties

    $class=atg.service.jdbc.FakeXADataSource
    driver=oracle.jdbc.xa.client.OracleXADataSource
    URL=jdbc:oracle:thin:@localhost:1521:XE
    user=publishing-db-schema-username
    password=
publishing-db-schema-password

4. Change Directory to /ATG-HOME/BIZUI/install/data and find bellow XML files.
     portal.xml
     profile.xml
     viewmapping.xml

5. Import content of above XML file to publishing schema by referring to fake server
   /ATG-HOME/home/bin/startSQLRepository  -m BIZUI -s my-fakexa -repository /atg/portal
   /framework/PortalRepository -import    /ATG-HOME/BIZUI/install 
   /data/portal.xml


   /ATG-HOME/home/bin/startSQLRepository  -m BIZUI -s my-fakexa -repository /atg/portal
   /framework/PortalRepository -import    /ATG-HOME/BIZUI/install 
   /data/profile.xml

      /ATG-HOME/home/bin/startSQLRepository  -m BIZUI -s my-fakexa -repository /atg/portal
   /framework/PortalRepository -import    /ATG-HOME/BIZUI/install 
   /data/viewmapping.xml

6. Restart publishing server and try to logging to your BCC


end

Wednesday, May 27, 2015

LOG4J XML to keep dated file appender for multiple debug logs, error logs

Bellow log4j XML file will help you to keep multiple dated debug logs and error logs

Prerequisites :     1. Create Java Project in your IDE
                            2. Use  biz.minaret and Log4J java libraries
                            3. Create log4j.xml file with bellow XML
                            4. Keep log4j.xml file in your project build path
                            5. You have to create java code with loggers for 2 debug logs and error log.



How it works : Once you added log4j  libraries  in to  your  build  path it will automatically find log4j.xml or log4j.properties in your build path. It will create folders called log-update , log-delete and log-error  in your build path.

                      
log4j.xml                         

Download it from here : log4j.xml


Java code

public class LoggerTest{
    private static final Logger updateLog = Logger.getLogger("appUpdateLog");    
    private static final Logger deleteLog = Logger.getLogger("appDeleteLog");
    private static final Logger errorsLog = Logger.getLogger("appErrorsLog");

    public static void main(String[] str) {
    do{
            deleteLog.debug("Adding a delete log record....");
            Thread.sleep(1000);
            updateLog.debug("Adding an update log record....");            

            String stringTmp = null;
            try{
                 stringTmp.split("");
             }catch(Exception e){
                 errorsLog.error("
Adding an error log record with stack trace....",e);
             }

        }while(true);      
    }
}





Thanks

Saturday, May 23, 2015

Simplest JAX-WS Client

/*
Copyright (C) 2014 saminda konkaduwa
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail.
*/



Introduction

Easy JAX-WS SOAP client is a simplified web service client that reduces burden of creating painful web service client stubs that also eliminates use of external java libraries. You can invoke JAX-WS web services with faster, easier with few lines of java codes.

Advantages of Easy JAX-WS client

1. You can invoke web services using few lines of java codes with out creating
  massive and bulky client stubs.
2. Increase the speed of execution since there is no validation of web service
  requests with WSDL and no external libraries.
3. Simplified way to read complex responses.

Capabilities of Easy JAX-WS client

1. Can invoke HTTP based web service
2. Can invoke HTTPS based web service
3. Can incorporate HTTPS certificate files
4. Can incorporate with proxy host, ports, username, password
5. Can incorporate with application server level authentications

Steps to invoke JAX-WS web services using Easy JAX-WS client

1. Invoke the web service using your popular soap reader.
    Ex – SoapUI , Firefox SOA Client
2. View the structure of SOAP Request
3. View the WSDL file and read the SOAP action relevant to your Method
4. Build your SOAP Request using Easy JAX-WS client
5. Read the SOAP Response using Easy JAX-WS client

Lets tryout bellow examples 

1. HTTP based JAX-WS web service
2. HTTPS based JAX-WS web service
3. Incorporating proxy servers
4. Server authentications 

Simplest JSP Tree Viewer

Copyright (C) 2012  saminda konkaduwa, skonkaduwa@gmail.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.  If not, see .

Also add information on how to contact you by electronic and paper mail.

@author Saminda Konkaduwa , skonkaduwa@gmail.com
@version 1.0
@since 10/April/2012





Download Location

http://sourceforge.net/projects/jsptree-simple/


Introduction

This is a simple JSP tree viewer with minimum usage of Java Scripts.       
Nodes are generated using parent child relationships.
Each node may have list of children nodes.


How to deploy

Prerequisites

1. You should know what is Java web application and How to deploy Java Web application project in your web server.
2. You should know how to install latest Java, MySQL Server and Apache Tomcat Server in your operating system

Deploy and run the given WAR file

1. Install latest Java version, MySQL server version, Apache Tomcat Server version.
2. Download the source code from http://sourceforge.net/projects/jsptree-simple/
3. Run the SQL statements given by SQLFile.txt on your MySQL server.
4. Open the given simple-jsp-tree.war file located at WebContent folder using zip / rar utilities. ( Becaues you can edit the war file content after open it by zip )
5. Find the config.properties located at simple-jsp-tree.war/WEB-INF/classes/com/jsptree/tags/config.properties.
6. Change config.properties according to your MySQL database server connectivity.
7. Save the changes on config.properties and exit from zip / rar utilities.
8. Then deploy simple-jsp-tree.war in your Apache Tomcat Server.
9. Access the simple JSP tree from http://localhost:8080/simple-jsp-tree

For Oracle Users

For Oracle JDBC Connection, Please override config.properties entries as with your Oracle database connection as follows.

jdbc.driver=oracle.jdbc.xa.client.OracleXADataSource
jdbc.connection.url=jdbc:oracle:thin:@localhost:1521:xe       
jdbc.username=oracle_user                                   
jdbc.password=oracle@123                                   

( NOTE  : xe is my database name. Change it to your Oracle database name )
( NOTE : oracle_user is my Oracle user name. Change it to your oracle user name )
( NOTE : oracle@123 is my Oracle password. Change it to your oracle password )                       
                       
                       
To run from source code from Your Favorite IDE

1. Install latest Java version, MySQL server version, Apache Tomcat Server version and your favorite Java Development IDE. ( Ex- Eclipse, Netbean)
2. Download the source code from http://sourceforge.net/projects/jsptree-simple/
3. Open your favorite Java Development IDE. ( Ex- Eclipse, Netbean)
4. Create simple JSP project.
5. Go to the downloaded source code and extract in to separate folder.
6. Copy the content of src folder to java source location of your JSP project.
7. Go to the downloaded source code again and copy the content of WebContent folder to web content of your JSP project.
8. Run the project using your favorite web server.

For Oracle Users

For Oracle JDBC Connection, Please override config.properties entries as with your Oracle database connection as follows.

jdbc.driver=oracle.jdbc.xa.client.OracleXADataSource
jdbc.connection.url=jdbc:oracle:thin:@localhost:1521:xe       
jdbc.username=oracle_user                                   
jdbc.password=oracle@123                                   

( NOTE  : xe is my database name. Change it to your Oracle database name )
( NOTE : oracle_user is my Oracle user name. Change it to your oracle user name )
( NOTE : oracle@123 is my Oracle password. Change it to your oracle password )       


Thank you.   

Source Code Installation of Apache Web Server On Linux

In-order to get the true satisfaction, trill and software freedom from Linux , let's install Apache web server from source code on Linux Platform

These installation conducted with up-to date software packages and operating system as of 23rd May 2015. Any future changes to the installation process are not included.


Operating System used             - CentOS 6
Compatible Operating Systems - Fedora, RedHat Linux

Pre-installations and updates

1. Perform a full system update


   Login as root user
   Command : su
                      Enter password of root user and it gives you root shell
   Command : yum update


2. Install GNU C and C++ compilers

 
    Login as root user if not
    Command : yum install gcc*

3. Create a directory called LAMP in your preferred place.
 
     Command : mkdir LAMP

4. We are going to download all source codes into this location.
    Now change the present working directory to LAMP


    Command : cd LAMP

5. Download and extract apache web server source code from   

    http://httpd.apache.org/download.cgi

6. Extract it.

    Command : tar -xvzf httpd-2.4.12.tar.gz

7. Download and extract apache web server run time utilities from 
    https://apr.apache.org/download.cgi

   There are two libraries called APR and APR-Util.
   Extract them.


   Command : tar -xvzf apr-1.5.2.tar.gz
   Command : tar -xvzf apr-util-1.5.4.tar.gz


8. Move apr and apr-util folders in to srclib directory of apache server source code directory

   Command : mv apr-1.5.2 httpd-2.4.12/srclib/apr
   Command : mv apr-util-1.5.4 httpd-2.4.12/srclib/apr-util



9. Build the source code and install

     9.1. Login as root user if not
     9.2. Configure the source code, remember that --prefix= notation says the installation location


Command : ./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util

  It gave bellow build error due to dependency errors. "configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/". It may be different build error in your machine.You have to download dependent software and install it before you install apache. Some times dependent software may be depend on another new software. So you have to first find the dependency tree and then install all these dependencies.

Read the errors carefully and get the idea and search on the web

   9.3.1 Download pcre library source code and extract them to LAMP directory    
           
            Login as root user if not
            
            Extract source code
            Command : unzip pcre-8.37.zip
           
            Change current directory to your pcre-8.37
            Command : cd pcre-8.37
          

            Configure the source code
            Command : ./configure --prefix=/usr/local/pcre
           

            Build the source code
            Command : make

            Install it
            Command : make install

In my machine it gave bellow build error due to dependency issues "configure: error: mod_deflate has been requested but can not be built due to prerequisite failures"

Read the errors carefully and get the idea and search on the web

     9.3.2 Download zlib library source code and extract them to LAMP directory
          
             Login as root user if not

             Extract the source code
             Command : tar -xvzf zlib-1.2.8.tar.gz

             Change current directory to your zlib-1.2.8
             Command : cd zlib-1.2.8

             Configure the source code
             Command : ./configure --prefix=/usr/local/zlib

             Build the source code
             Command : make
            
             Install it
             Command : make install
  


10. Now reconfigure apache source code with mentioning newly installed dependencies

   Login as root user if not

   Change current directory to httpd-2.4.12
   Command : cd httpd-2.4.12
  
   Configure the source code
   Command : ./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util --with-pcre=/usr/local/pcre/bin/pcre-config --with-z=/usr/local/zlib/
  
   Build the source code
   Command : make

   Install it
   Command : make install


11. If there are no errors then you have successfully installed apache web server from the source code.

12. Now change your directory to apache server location.

   Command : cd /usr/local/apache/bin

13. Start apache web server by bellow command

 Login as root user if not
 Command : ./apachectl start

14. Open your web browser and browse bellow url to check web server is working fine

 Command : http://localhost:80

15. If it shows we page with "It works!", 
      Then you have successfully installed apache web server.

16. Stop apache web server by bellow command
 
  Login as root user if not 
  Command : ./apachectl stop

17. Restart apache web server by bellow command

   Login as root user if not 
   Command : ./apachectl restart



Thank you.. Next we install MySQL and PHP from source code.

Sunday, May 3, 2015

Chip programming with Linux 2 - Compilers, Development Environments, Programming Languages and Blinking LED Circuit.


Description    : Installing compilers, Integrated Development Environments, Generating and installing Hex file for Blinking LED circuit.















Compatibility : Linux kernel 2.4 or 2.6. ( Tested )
                           FreeBSD                        ( NOT Tested
                           Mac OSX 10.4                ( NOT Tested
                           Mac OSX 10.5                ( NOT Tested )
                           OS X Mavericks 10.9.2  ( Tested )


Prerequisites : You have to complete http://iam-saminda.blogspot.com/2015/03/chipset-programming-with-linux-1-pickit.html


1. Introduction

1.1 What is PIC micro controller. ?

PIC chips are manufactured by microchip. They are producing 8bit, 16bit, 32bit micro controller. These micro controllers consisted with all features like modern computers but limited capabilities. These micro controllers has inbuilt RAM, EEPROM, Inputs and Outputs, CPU, Clock and many more features. We can install hexadecimal instruction file in to PIC chip. Once it assembled in proper circuit then it will function according under external power supply.

1.2 Which PIC micro controller will match your requirement ?

PIC chips comes with 8 bit, 16 bit, 32 bit micro controllers. Each chip has numerous number of pins which are used to interconnected with circuit. These pins can be used as inputs as well as outputs. 32 bit micro controller is more capable than 16 bit and  8 bit. If you are going to deal high efficient systems then 32 bit controllers will be good choice. If you are going to deal with low power consumption applications then good to choose 8 bit controllers.

You have to read data sheet given by microchip  in order to understand capabilities of each PIC micro controller.
    

1.3 Programming concerns for PIC micro controllers.

Group of each input and output pins called PORTS. A PORT of 8 bit micro controller has 8 input and output pins. A PORT of 16 bit micro controller has 16 input and output pins. A PORT of 32 bit micro controller has 32 input and output pins.   

In each PIC micro controller consist with many PORTS. Each PORT is coupled with Registers. These Registers are called TRIS. TRIS will define the input output nature of each pin of given PORT. 8 bit micro controller has several 8 bit TRIS. Each 8 bit TRIS coupled with each 8 bit of PORT.

If TRIS bit set to logic 1, then relevant bit of PORT will set as INPUT. If TRIS bit set to logic 0, then relevant bit of PORT will set as OUTPUT. Actually PORT is the interface that interact with external circuit components as Logic input and Logic output.

When given PIC controller has multiple registers , then relevant notations will be  TRISB, PORTB, TRISD, PORTD.



 













1.4 Our experimental PIC Controller

We are going to use 8 bit PIC 16F877A


1.5 Programming Language

In this section we are emphazising only recommended language given by PIC chip designers. microchip offers Micro C which is based on ANSI C Language. microchip offers wide range of libraries to make interfacing with large number of electronic devices.

1.6. Available Compilers
In this section we are emphazising only recommended compilers given by PIC chip designers. microchip offers 3 range of C compilers. They are 8 bit compiler, 16 bit compiler and 32 bit compiler. We are going to use 8 bit XC8 compiler as we are going to use 8 bit micro controller.


1.6. Available Integrated Development Environments.
In this section we are emphazising only recommended IDE given by microchip
That is MPLAB IDE.


2. Installing MPLAB IDE and XC8 Compiler.

Step 2.1 : First download latest MPLAB IDE.
               File name will be similar to MPLABX-v2.35-linux-installer.tar

Step 2.2 : Extract it using bellow command
            tar -xvf MPLABX-v2.35-linux-installer.tar
            It will generate sh file similar to MPLABX-v2.35-linux-installer.sh

Step 2.3 : Give full execution permission by bellow command
                chmod 777 MPLABX-v2.35-linux-installer.sh
             
Step 2.4 : Logging as root user using bellow command and enter root password
             su

Step 2.5 : Now run MPLABX-v2.35-linux-installer.sh using bellow command
             ./MPLABX-v2.35-linux-installer.sh

Step 2.6 :Resolve any dependance issues if occurred like bellow.

[root@localhost Downloads]# ./MPLABX-v2.35-linux-installer.sh
64 Bit, check libraries
Check for 32 Bit libraries
These 32 bit libraries were not found and are needed for MPLAB X to run:
libc.so
libdl.so
libgcc_s.so
libm.so
libpthread.so
librt.so
libstdc++.so
libexpat.so
libX11.so
libXext.so



Step 2.7 : In my case i have to install above libraries using bellow commands.
            You have to find your dependencies by searching one by one.

            yum install pam.i686
            yum install compat-libstdc++-296.i686
            yum install libexpat.so.1
            yum install libXext.i686



Step 2.8 : Again re run above command.
            Then it will start installation process like bellow

[root@localhost Downloads]# ./MPLABX-v2.35-linux-installer.sh
64 Bit, check libraries
Check for 32 Bit libraries
Verifying archive integrity... All good.
Uncompressing MPLAB X v2.35 Installer..



Step 2.9 : Select Next , The accept License agreement , then select
              installation path and select both MPLAB IDE and MPLAB IPE.
                Then click Next  and allow it to add PATH variables.
                Next finish the installation process.


















Step 2.10 Now restart the computer to get affect updated udev rules.
                   You can find MPLAB IDE icon under your applications

Step 2.11: Now we have to download and install XC8 C compiler
                First download latest XC8 C compiler
                File name will similar to xc8-v1.34-full-install-linux-installer.run
               

Step 2.12 : Give full execution permission by bellow command
                     chmod 777 xc8-v1.34-full-install-linux-installer.run
             
Step 2.13 : Logging as root user using bellow command and enter root password
             su

Step 2.14 :  Now run the installation using bellow command
                  ./xc8-v1.34-full-install-linux-installer.run

Step 2.15 : Click next, then accept license agreement, then select Free license type, then select installation directory , then allow to add path variables settings for all users , then next and finish the installation as bellow manner.


























3. Create MPLAB Project for Blinking LED.

Step 3.1 : Start MPLAB IDE

Step 3.2 : File -> New Project


Step 3.3 : Select Category Microchip Embedded and Standalone Project














Step 3.4 : Select Device as PIC 16F877A











Step 3.5 : Select Next and Select PICKit2 programmer.
               Because we are going to use PICKit2 programmer.














Step 3.6 : Select Next and Select XC8 8bit compiler














Step 3.7 : Select Next and give a Project Name called "LEDBlinker" and finish.












Step 3.8 : Right click on source file -> New -> C Main File -> Give file name
                as LEDBlinker and click finish.














Step 3.9 : It will create C file.












Step 3.10 : Add bellow two lines top of the code as we are going to use 4 Mhz
                 crystal. You can see final code at the bottom.

#define _XTAL_FREQ 4000000
#include



Step 3.11: Add bellow configuration codes before main method
                 You can see final code at the bottom.

// BEGIN CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
//END CONFIG


Step 3.12: Next we have to set Input and Output TRIS in the main method
                 You can see final code at the bottom.


                 TRISB0 = 0; //RB0 as Output PIN

Step 3.13: Now time to see data sheet given by microchip
                
             See the data sheet given by microchip to find out Relevant PORT pin. 
             That is pin 33 called RB0. RB0 is the relevant pin for port of TRISB0.




Step 3.14 : Now we are going to Blink LED continuously until we provide
                 power supply. Add bellow codes after TRISB0 = 0;

                while (1) {
                  RB0 = 1; // LED ON
                  __delay_ms(1000); // 1 Second Delay
                  RB0 = 0; // LED OFF
                  __delay_ms(1000); // 1 Second Delay
                }


                So use infinite for loop or infinite while loop. In side the loop, we will set Logic 1 and 0 to RB0 with some delays. Then pin 33 will enable with Logic 1 and 0 time to time after assembled the circuit under power supply. Logic 1 means, enabling 5V between pin 33 and ground. Logic 0 means enabling 0V between pin 33 and ground.


Step 3.15 : You can use bellow complete code.


/*
 * File:   BlinkLED.c
 * Author: PicDeveloper
 *
 * Created on May 3, 2015, 1:35 PM
 */

#define _XTAL_FREQ 4000000

#include <xc.h>
#include <stdio.h>
#include <stdlib.h>

// BEGIN CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
//END CONFIG
/*
 *
 */
int main() {

    TRISB0 = 0; //RB0 as Output PIN
    while (1) {
        RB0 = 1; // LED ON
        __delay_ms(1000); // 1 Second Delay
        RB0 = 0; // LED OFF
        __delay_ms(1000); // 1 Second Delay
    }
    return 0;
}



Step 3.15 : Now clean and build the project to generate Hexadecimal file of above code.
                    Right click on project then Clean and Build


Step 3.16 : You can find the Hexadecimal file from bellow location.
                 DO NOT OPEN THIS HEX FILE USING ANY EDITOR. 
                 IT WILL ALTER AND WILL NOT WORK.
                                



/MPLABXProjects/LEDBlink.X/dist/default/production/LEDBlink.X.production.hex



4. Installing Hexadecimal file into micro controller.

Step 4.1 : Plug the PIC 16F877A chip to PIC Programmer

Step 4.2 : Plug the PIC Programmer to your computer


Step 4.3 : Logging as root user using bellow command and enter root password
                  su


Step 4.4 : Run the auto detection command
                  Command : pk2cmd -P
                   
                  Result : Auto-Detect: Found part PIC16F877A.
                                Operation Succeeded
 


Step 4.5 : Erase existing hexadecimal file if there is an existing file
                  Command : pk2cmd -P PIC16F877A -X -E

               Result : Erasing Device...
                                Operation Succeeded


Step 4.6 : Change current working directory to your MPLAB project build path
                  Command : cd  /MPLABXProjects/LEDBlink.X/dist/default/production/



 Step 4.7 : Find the hexadecimal file. It should be similar to LEDBlink.X.production.hex

                 DO NOT OPEN THIS HEX FILE USING ANY EDITOR. 
                 IT WILL ALTER AND WILL NOT WORK.

Step 4.8 : Now install hexadecimal file in to PIC 16F877A chip
                  Command : pk2cmd -P PIC16F877A -X -M -F A.X.production.hex

                  Result : PICkit 2 Program Report
                                4-5-2015, 17:27:12
                                Device Type: PIC16F877A

                                Program Succeeded.

                                Operation Succeeded



Step 4.9 : Now power off PIC programmer
                  Command : pk2cmd -P PIC16F877A
 
                  Result       :  Operation Succeeded
                  Now you can see power indicator LED is NOT working



5. Blinking LED with 16F877A chip

Step 5.1 : Required electronic items

                1. Breadboard
                2. Programmed PIC 16F87A chip
                3. 4 Mhz crystal
                4. 2 items of 20 PF capacitors
                5. 4.7 Kilo Ohm resister
                6. 3V LED bulb
                7. 100 Ohm resister
                8. Breadboard Jump wire packet.
                9. 5 V DC power supply.
                10. 7805 Regulator if you have more than 5V DC power supply.

Step 5.2 : Construct bellow circuit on breadboard

               



















Step 5.6 :Double check the circuit before you provide power supply.

Step 5.7 : Provide 5 V DC power supply. If you have more than 5 V DC power
                  supply then use 7805 regulator to get 5V DC regulated supply.

Step 5.8 : Check LED is blinking every second. You can add more LED with
                  considering TRIS and PORT. You have to read data sheet given by
                  microchip.


Thank you. We will do some server motor controlling in next post. 
 

Wednesday, April 22, 2015

File transfer between two Linux consoles

File transfer between two Linux consoles
--------------------------------------------------------------------------

Description : This will participate at least 2 Linux servers


Step 1 : First logging to the server console that file or directory located
                     
             If you directly logging to server , then provide username and password

             If you logging to server from your developer machine , then use bellow SSH command
                        ssh -l user_name ip_address_of_server_that_located_file
                        ssh -l testuser 169.35.26.45 

Step 2  : Provide password and logging to console

Step 3  : Change directory to file/directory located

              cd /data/backup

Step 4  : List files of given directory and verify your file/directory is available

              ls

              application_backup

Step 5  : Find out IP address, Username, Password and path of the second remote server. This is the location to copy above file or directory.

              IP              : 169.35.26.55
   
              Username : liveuser

              Password  : *******
 
              PATH        : cd /home/uat/backup/


Step 6 : Now copy the file/directory from first server ( 169.35.26.45  ) to second server ( 169.35.26.55 ) using bellow command
             

              scp -r application_backup liveuser@169.35.26.55:/home/uat/backup/


Step 7 : Provide password of second Linux server.



Sample console output from first Linux server





scp -r application_backup liveuser@169.35.26.55:/home/uat/backup/
Password:
application.xml      100% |**********************************************************************************************************|  2646       00:00   
jboss-app.xml        100% |**********************************************************************************************************|    61       00:00   
listClass.tag        100% |**********************************************************************************************************|  2144       00:00   
pagination.tag       100% |**********************************************************************************************************|  4466       00:00   
messageContainer.tag 100% |**********************************************************************************************************|  1880       00:00   
stringSizeClass.tag  100% |**********************************************************************************************************|  1993       00:00   
emailPageContainer.t 100% |**********************************************************************************************************|  6133       00:00   
yearList.tag         100% |**********************************************************************************************************|  6340       00:00   
popupPageContainer.t 100% |**********************************************************************************************************|  2819       00:00   
getMessage.tag       100% |**********************************************************************************************************|  3149       00:00   
pageContainer.tag    100% |**********************************************************************************************************| 14709       00:00   
 



 

Sunday, March 22, 2015

Chip programming with Linux 1 - PICkit version2 clone under Linux / Freebsd / Mac OS


Description    : Installing PICkit version2 clone for Linux / Mac.


            











Compatibility : Linux kernel 2.4 or 2.6. ( Tested )
                                   FreeBSD                        ( NOT Tested
                          Mac OSX 10.4                ( NOT Tested
                          Mac OSX 10.5                ( NOT Tested )
                          OS X Mavericks 10.9.2  ( Tested )

Steps :

1. Login as root

Command  : su
                  
2. PICkit version2 clone drivers for Linux / Mac

Commands : yum install gcc-c++
                     yum install libusb1-devel
                     yum install libusb-devel


3. Download PICkit version2 clone software for Linux / Mac

URL : Pickit2 Tool for Linux

4. Change directory to download location

Command : cd /home/developer64/Downloads/

5. Extract source code

Command : tar zxvf pk2cmdv1.20LinuxMacSource.tar.gz

6. Change directory to source code folder

Command : cd pk2cmdv1.20LinuxMacSource

7. Check your Linux kernel vernal version

Command : uname -r  

My Linux kernel version is 2.6.32-504.12.2.el6.x86_64


8. Build the source code

This software comes with source code. So you can view the source code and change according to your Operating System. It is written in C++ and you can improve the source code according your requirement.

 
Command for Linux Kernel version start with 2.6 : make linux  
  
Command for Linux Kernel version start with 2.4 : make linux-old

Command for FreeBSD                                         : make freebsd

Command for Mac OS 10.4                                   : make mac104

Command for Mac OS 10.5                                   : make mac105


9. Copy relevant files to /usr/local/bin


Command : cp pk2cmd /usr/local/bin
                   cp PK2DeviceFile.dat /usr/local/bin/
                   cp PK2V023200.hex /usr/local/bin/


10. Now check your software version

Command : pk2cmd -?V

Executable Version:    1.20.00
Device File Version:   1.55.00
OS Firmware Version:   PICkit 2 not found

 

Cheers we have successfully installed. Yet to configure it. It says  PICkit 2 not found as PICkit2 device not connected with my computer

           
11. Create Driver Manager Empty Rule File

Command : echo "" > /etc/udev/rules.d/99-pickit2.rules

12. Open the file
  
Command : gedit /etc/udev/rules.d/99-pickit2.rules

13. Add bellow rule content to /etc/udev/rules.d/99-pickit2.rules and save the file
  
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device",SYSFS{idVendor}=="04d8" , SYSFS{idProduct}=="0033", MODE="0666"


14. Now reload Linux Driver Manager Rules
  
Command : udevadm control --reload-rules

15. Now connect your PICkit2 USB device without PIC chipset

16. Check the device connectivity with your computer
  
Command : pk2cmd -?V

Result       :  Executable Version:    1.20.00
                    Device File Version:   1.55.00
                    OS Firmware Version:   2.32.00


                    Operation Succeeded

Cheers. It says Operation Succeeded

16. Mount your PIC Chipset in right direction on your device.

Refer bellow picture.

17. Now connect your PICkit2 USB device 













17. Run Auto detection command. This will identify PIC Chipset

Command : pk2cmd -P


Result       :  Auto-Detect: Found part PIC16F877A.

                    Operation Succeeded


My PIC chip is PIC16F877A



18. Erasing chipset

Command : pk2cmd -P PIC16F877A -X -E
 
Result       :  Erasing Device...

                    Operation Succeeded


19. Installing hexadecimal file in to chipset. 
      Hexadecimal file will include all execution steps of the firmware. 
      We will discuss how to write small program for LED display, Sensor  
      readings, Motor controllers and etc..

      We will be able to write firmware based on Micro C language Micro C IDE.
      Then we will convert it in to HEX file.


For the moment we will use existing HEX file PK2V023200.hex located in same place pk2cmdv1.20LinuxMacSource


Command : pk2cmd -P PIC16F877A -X -M -F PK2V023200.hex
 
Result       :  PICkit 2 Program Report
                    22-3-2015, 23:29:55
                    Device Type: PIC16F877A

                    Program Succeeded.

                    Operation Succeeded

Now it says, it wrote given Hex file in to chipset called PIC16F877A.


19. Verify Hex file against Chipset memory issues


Command : pk2cmd -P PIC16F877A -Y -F PK2V023200.hex
 
Result       :  PICkit 2 Verify Report
              22-3-2015, 23:44:49
              Device Type: PIC16F877A

              EEData Memory Errors

              Address   Good     Bad
              000000    0000EA   000000


It seems everything is OK.


20. Power ON Chipset


Command : pk2cmd -P PIC16F877A -T
 
Result       :  Operation Succeeded
Now you can see power indicator LED is working


21. Power OFF Chipset


Command : pk2cmd -P PIC16F877A
 
Result       :  Operation Succeeded
Now you can see power indicator LED is NOT working




In next post we will install Micro C IDE, C compilers dedicated to Micro C IDE. Then we will develop some hobby circuits such as LED controllers, Motor controllers, sensor readers and many more.

Thank you.