Thursday, May 22, 2014

Android Project Ideas For Minor Projects



1)  Design and implementation of automatic number plate recognition on android platform

ABSTRACT

Android platform has gained popularity in recent years in terms of market share and number of available applications. Android operating system is built on a modified Linux kernel with built-in services such as email, web browser, and map applications. In this paper, automatic number plate recognition (ANPR) was designed and implemented on Android mobile phone platform. First, the graphical user interface (GUI) for capturing image using built-in camera was developed to acquire car plate number in Malaysia. Second, the preprocessing of raw image was done using contrast enhancement, filtering, and straightening. Next, an optical character recognition (OCR) using neural network was utilized to extract texts and numbers. The proposed ANPR algorithm was implemented and simulated using Android SDK on a computer. The preliminary results showed that our system is able to recognize most of the plate characters by almost 88%. Future research includes optimizing the system for mobile phone implementation with limited CPU and memory resources, and geo-tagging of the image using GPS coordinates and online database for various mobile applications.

2)  Real-time video processing using native programming on Android platform


ABSTRACT

As the smartphone industry grows rapidly, smartphone applications need to be faster and real-time. For this purpose, most of the smartphone platforms run the program on the native language or compiler that can produce native code for hardware. However for the Android platform that based on the JAVA language, most of the software algorithm is running on JAVA that consumes more time to be compiled. In this paper the performance of native programming and high level programming using JAVA are compared with respect to video processing speed. Eight image processing methods are applied to each frame of the video captured from a smartphone that is running on an Android platform. The efficiencies of the two applications with difference programming language are compared by observing their frame processing rate. The experimental results show that out of the eight images processing methods, six methods that are executed using the native programming are faster than that of the JAVA programming with a total average ratio of 0.41. An application of the native programming for real-time object detection is also presented in this paper. The result shows that with native programming on Androidplatform, even a complicated object detection algorithm can be done in real-time.

3)  Design and implementation of automatic number plate recognition on android platform

ABSTRACT

Android platform has gained popularity in recent years in terms of market share and number of available applications. Android operating system is built on a modified Linux kernel with built-in services such as email, web browser, and map applications. In this paper, automatic number plate recognition (ANPR) was designed and implemented on Android mobile phone platform. First, the graphical user interface (GUI) for capturing image using built-in camera was developed to acquire car plate number in Malaysia. Second, the preprocessing of raw image was done using contrast enhancement, filtering, and straightening. Next, an optical character recognition (OCR) using neural network was utilized to extract texts and numbers. The proposed ANPR algorithm was implemented and simulated using Android SDK on a computer. The preliminary results showed that our system is able to recognize most of the plate characters by almost 88%. Future research includes optimizing the system for mobile phone implementation with limited CPU and memory resources, and geo-tagging of the image using GPS coordinates and online database for various mobile applications.

4)  Mitter — Bitter monitoring system using Android smartphone's

ABSTRACT

Employee monitoring system using android mobile is, essentially, software that allows Managers to monitor their Employee's office cell phone. All incoming and outgoing calls, texts and multimedia messages can be seen and interrupted by the Managers, who can also monitor where their Employee are (through GPS), access a history of where they've been and set up alerts if their Employee are going outside of approved geographical zones, are receiving texts from unapproved numbers or calls from banned persons. This system uses Android based mobile phones for the software to be run. The mobile device in the hand of the Employee should be an Android based device and the Managers may have any kind mobile devices, since they are going to receive alerts from the Employee in SMS format only. For convenience, the alerts are also stored in the centralized server like the details of incoming call, text and multimedia messages and the timely location update of their Employee. Managers may later login into the centralized server and view the details of their Employee's mobile usage. This system is really very helpful for the Managers to monitor their Employee through mobile phones. By using this system, we can avoid the unnecessary things happened for the Employee those who are having mobile phones by monitoring their mobile phone usage and also by tracking their current location through the GPS.

5)  Android city tour guide system based on Web service

ABSTRACT

The combination of the smart phone and the Internet service is the trend of the future information development and software applications. Mobile phones are the most commonly used communication tools. Using mobile phones to obtain information is not only quick, but also more convenient shortcut to improve people's lives. In the paper, we propose the software development architecture based on Web services. This framework introduces the three-layer architecture of Web development into mobile phone software development. Based on the three-layer architecture, the android based city tour guide system is developed. The android based city guide system can realize to query information for hotel, scenery, restaurant, traffic and so on. The android based city guide system has more practical significance.

6)  Offloading Android applications to the cloud without customizing Android

Spreading more than twice as fast as PCs, smartphones are quickly becoming the primary mean for Internet access. However, smartphones today are still constrained by limited computation resources such as CPU, memory and battery. In this paper, we present a framework that automatically offloads heavy back-end tasks of a regular standalone Android application to an Android virtual machine in the cloud. This framework can be deployed in the application layer without modifying the underlying Android platform. It also features three metrics that consider total response time, energy consumption and remaining battery life in deciding whether a task should be offloaded.

7)  Design of secure location and message sharing system for android platform

ABSTRACT

Present android-based location and message sharing system asks to input the personal information which fails to protect the privacy of information, has no centralized database which is causing the problem of data management and portability, and one main drawback is unable to have a secured two way communication between webserver and android based application. And this Android-based Location and Message Sharing System (ALMSS) is proposed for solving above mention problem. The proposed system uses Java programming language for android mobile user application, PHP programming language as webserver, MySQL as external database to store the data, JSON as intermediary between android platform and webserver and uses symmetric cryptography while communicating between android device and webserver which finally assures the protection of information.


Friday, April 25, 2014

IEEE Projects-Cryptography Based Projects

An Efficient Merkle-Tree-Based Authentication Scheme for Smart Grid

Smart grid has emerged as the next generation of power grid, due to its reliability, flexibility, and efficiency. However, smart grid faces some critical security challenges such as the message injection attack and the replay attack. If these challenges cannot be properly addressed, an adversary can maliciously launch the injected or replayed message attacks to degrade the performance of smart grid. To cope with these challenging issues, in this paper, we propose an efficient authentication scheme that employs the Merkle hash tree technique to secure smart gird communication. Specifically, the proposed authentication scheme considers the smart meters with computation-constrained resources and puts the minimum computation overhead on them. Detailed security analysis indicates its security strength, namely, resilience to the replay attack, the message injection attack, the message analysis attack, and the message modification attack. In addition, extensive performance evaluation demonstrates its efficiency in terms of computation complexity and communication overhead.

Smart Grid Mesh Network Security Using Dynamic Key Distribution With Merkle Tree 4-Way Handshaking

Distributed mesh sensor networks provide cost-effective communications for deployment in various smart grid domains, such as home area networks (HAN), neighborhood area networks (NAN), and substation/plant-generation local area networks. This paper introduces a dynamically updating key distribution strategy to enhance mesh network security against cyber attack. The scheme has been applied to two security protocols known as simultaneous authentication of equals (SAE) and efficient mesh security association (EMSA). Since both protocols utilize 4-way handshaking, we propose aMerkle-tree based handshaking scheme, which is capable of improving the resiliency of the network in a situation where an intruder carries a denial of service attack. Finally, by developing a denial of service attack model, we can then evaluate the security of the proposed schemes against cyber attack, as well as network performance in terms of delay and overhead.
An optimized adaptive algorithm for authentication of safety critical messages in VANET

Authentication is one of the essential frameworks to ensure safe and secure message dissemination in Vehicular Adhoc Networks (VANETs). But an optimized authentication algorithm with reduced computational overhead is still a challenge. In this paper, we propose a novel classification of safety critical messages and provide an adaptive algorithm for authentication in VANETs using the concept ofMerkle tree and Elliptic Curve Digital Signature Algorithm (ECDSA). Here, the Merkle tree is constructed to store the hashed values of public keys at the leaf nodes. This algorithm addresses Denial of Service (DoS) attack, man in the middle attack and phishing attack. Experimental results show that, the algorithm reduces the computational delay by 20 percent compared to existing schemes.
SAFE: A social based updatable filtering protocol with privacy-preserving in mobile social networks

Mobile Social Networks (MSN), as an emerging social networking platform, facilitates social interaction and information sharing among users in the proximity. Spam filtering protocols are extremely important to reduce communication and storage overhead when many spam packets without specific destinations are diffused in MSNs. In this paper, we propose an effective social based updatable filtering protocol (SAFE) with privacy preservation in MSNs. Specifically, we firstly construct a filter Hash treebased on the properties of Merkle tree. Then, we exploit social relationships, and select those users with more than a specific number of common attributes with the filter creator. The selected users are able to store filters in order to block spams or relay regular packets. Furthermore, we develop a cryptographic filtering scheme without disclosing the creator's private information or interests. In addition, we propose a filter update mechanism to allow users to update their distributed filters in time. The security analysis demonstrates that the SAFE can protect user's private information from filter's disclosure to other users and resist filter forgery attack. Through extensive trace-driven simulations, we show that the SAFE is effective and efficient to filter spam packets in terms of delivery ratio, average delay, and communication overhead.
An efficient authenticated data structure for dynamic data set based on B+ tree

In cloud storage system, the client stores large volume of data at remote directories which is out of the client's control and may be malicious. In such setting, the ability to efficiently check the integrity of remotely stored data is an important security property. In this paper, we focus on a simple and very important form of remote data authentication problem, where we authenticate membership queries over a dynamic set of n data elements that is stored at untrusted directories. Some existing verification methods for membership queries, such as Merkle Hash Tree (MHT), Skip List and RSA Tree are overviewed first. These methods all achieve the goal for verification, but their data structures are not agile enough for data update. They may have high time complexity or cause reconstruction of the whole data structure frequently when update operation is preceded. So we turn to B+ tree data structure and make it work with RSA accumulator to form a new verification scheme, which implements the verification and incurs low computational costs for membership query of dynamic data set.
OCCASIO: An operable concept for confidential and secure identity outsourcing


While federated identity management separates service provisioning from identity provisioning, the identity provider is usually operated at the home organization of the identities. We address the challenge of outsourcing the entire identity provider with its user database to an untrusted external provider in a secure and privacy-preserving way. With this type of outsourcing, the home organization is no longer required to operate high availability infrastructure for access management. Instead, the home organization only needs to frequently attest that the identity data in the outsourced database is still up to date, a task that is much less demanding than providing access decisions whenever a user wants to make use of a service. In this paper we present Occasio, a concept that permits secure outsourcing of identity and access management to untrusted external providers. Occasio builds on concepts of outsourcing databases and particularly on Merkle Hash Trees. We show that Occasio matches all security requirements for operation in an untrusted environment. Furthermore, we demonstrate that Occasio can be easily integrated into the SAML standard. We present results of a performance evaluation that shows that Occasio behaves well in terms of overhead. Finally, we show that with Occasio identity data of different home organizations can be `aggregated' without being linkable by someone other than the services that are granted to do so by the user.

IEEE Projects in Natural Language Processing -

1)       Sentence completion task using web-scale data

We propose a method to automatically answer SAT-style sentence completion questions using web-scale data. Web-scale da-ta have been used in many language studies and have been found to be a very useful resource for improving accuracy in sentence completion task. Our method employs assorted N-gram probability information for each candidate word. We also proposed back-off strategy was used to remove zero probabilities. We found that the accuracy of our proposed method improved by 52-87% over the current state-of-the-art.

2) Semantic graph based approach for text mining


A semantic network is a graphical notation, for representing knowledge in form of interconnected nodes and arcs. In this paper we propose a novel approach to construct a semantic graph from a text document. Our approach considers all the nouns of a document and builds a semantic graph, such that it represents entire document. We think that our graph captures many properties of the text documents and can be used for different application in the field of text mining and NLP, such as keyword extraction and to know the nature of the document. Our approach to construct a semantic graph is independent of any language. We performed an experimental analysis to validate our results to extract keywords of document and to derive nature of graph. We present the experimental result on construction of graph on FIRE data set and present its application for keyword extraction and commenting on the nature of document.

3) Text Simplification Tools: Using Machine Learning to Discover Features that Identify Difficult Text

Although providing understandable information is a critical component in healthcare, few tools exist to help clinicians identify difficult sections in text. We systematically examine sixteen features for predicting the difficulty of health texts using six different machine learning algorithms. Three represent new features not previously examined: medical concept density, specificity (calculated using word-level depth in MeSH); and ambiguity (calculated using the number of UMLS Metathesaurus concepts associated with a word). We examine these features for a binary prediction task on 118,000 simple and difficult sentences from a sentence-aligned corpus. Using all features, random forests is the most accurate with 84% accuracy. Model analysis of the six models and a complementary ablation study shows that the specificity and ambiguity features are the strongest predictors (24% combined impact on accuracy). Notably, a training size study showed that even with a 1% sample (1,062 sentences) an accuracy of 80% can be achieved.

Dhiya: A stemmer for morphological level analysis of Gujarati language

To understand a language, analysis has to be done at word level, sentence level, context level and discourse level. Morphological analysis comes at the base of all, as it is the first step to understand a given sentence. One of the tasks that can be done at morphological level is stemming. To identify the stem term of a given word is stemming. Stemming is one of the important activities which is not just related to Natural Language Processing domain, but is equally important in Information Retrieval domain. In this paper, authors suggest DHIYA a stemmer for Gujarati language. This stemmer is based on the morphology of Gujarati language. To develop the stemmer, inflections which appeared most in Gujarati text were identified. Based on it, the rule set was created. For training and evaluation of the stemmer's performance the EMILLE corpus is used. The accuracy of the stemmer is 92.41%.

Medical Document Classification Based on MeSH

One of the most challenging projects in information systems is extracting information from unstructured texts, including medical document classification. I am developing a classification algorithm that classifies a medical document by analyzing its content and categorizing it under predefined topics from the Medical Subject Headings (MeSH). I collected a corpus of 50 full-text journal articles (N=50) from MEDLINE, which were already indexed by experts based on MeSH. Using natural language processing(NLP), my algorithm classifies the collected articles under MeSH subject headings. I evaluated the algorithm's outcome by measuring its precision and recall of resulting subject headings from the algorithm, comparing results to the actual documents' subject headings. The algorithm classified the articles correctly under 45% to 60% of the actual subject headings and got 40% to 53% of the total subject headings correct. This holds promising solutions for the global health arena to index and classify medical documents expeditiously.

Korean-Thai Lexicon for Natural Language Processing

This paper presents Korean-Thai lexicon. This research aims to study and collect necessary features to construct the Korean-Thai lexicon for natural language processing (NLP) and speech processingresearches. The research method used for study was that of (1) creating Korean-Thai lexicon consisting of 7 parts : Korean words, Korean Revised Romanization, part of speech, sub part of speech, special characteristic, Thai meaning and description of meaning (2) Korean transcription. According to lack of useful tools for the Korean- Thai machine translation, therefore we have a proposal for creating Korean-Thai lexicon for machine translation. The Korean-Thai lexicon consists of 36,000 Korean words. As it would take a lot of time and effort to gather enough Korean words to cover all domains, Korean Revised Romanization was applied for some words such as terminology, names and places.

Analysis of stock market using text mining and natural language processing


Stock market has become one of the major components of economy not only in developed countries but also in third world developing countries. Making decision in stock market is not really easy because a lot of factors are involved with every choice we make. Therefore, a lot of analysis is required to make an optimal move on stock market which may involve price trend, market's nature, company's stability, different news and rumors about stocks etc. The objective of this study is to extract fundamental information from relevant news sources and use them to analyze or sometimes forecast the stock market from the common investor's viewpoint. We surveyed the existing business text mining researches and proposed a framework that uses our text parser and analyzer algorithm with an open source natural language processing tool to analyze (machine learning and text mining), retrieve (naturallanguage processing), forecast (compare with historic data) investment decisions from any text data source on stock market. For our research we used the data of Dhaka Stock Exchange (DSE), capital market of Bangladesh.

CyberMate Artificial Intelligent business help desk assistant with instance messaging services



Most of the existing Artificial Intelligent software agents are based on a single specific purpose whereas CyberMate is a multipurpose AI agent based on pattern recognition with Chatterbot approach to interact with remote users. The system introduces a new technology to automate customer care services by hosting business information and technical support to address inquiries by the end users. CyberMate allows remote end users to connect via Instant Messaging services and get requested information using English, Tamil, Sinhala language or any natural language. The system can act as a dedicated AI agent between client and the service hosting party that can provide information via instance messages. This is a much faster and familiar solution than hosting a Frequently Asked Questions (FAQ) page as a part of a business website and even the system can reduces the work load of the customer care service waiting queue, which leads to decrease the customer's dissatisfaction and make service accessible from any device which has Internet connectivity. The business information can be easily modeled into the CyberMate system using the newly introduced CyberMate Scripting Language (CSL) and its own development environment (CSL-IDE).

On novel chatterbot system by means of web information

Recently, the use of various chatterbots has been proposed to simulate conversation with human users. Several chatterbots can talk with users very well without a high-level contextual understanding. However, it may be difficult for chatterbots to reply to specific and interesting sentences because chatterbots lack intelligence. To solve this problem, we propose a novel chatterbot that can directly use Web information. We carried out computational experiments by applying the proposed chatterbot to “2channel” (2ch) and “Twitter”.

CHARLIE: An AIML-based chatterbot which works as an interface among INES and humans

INES (INtelligent Educational System) is a functional prototype of an online learning platform, which combines three essential capabilities related to e-learning activities. These capabilities are those concerning to a LMS (learning management system), a LCMS (learning content management system), and an ITS (intelligent tutoring system). To carry out all this functionalities, our system, as a whole, comprises a set different tools and technologies, as follows: semantic managing users (administrators, teachers, students...) and contents tools, an intelligent chatterbot able to communicate with students in natural language, an intelligent agent based on BDI (believes, desires, intentions) technology that acts as the brain of the system, an inference engine based on JESS (a rule engine for the Java platform) and ontologies (to modelled the user, his/her activities, and the learning contents) that contribute with the semantics of the system, etc. At the present paper we will focus on the chatterbot, CHARLIE (CHAtteR Learning Interface Entity), developed and used in the platform, which is an AIML-based (artificial intelligence markup language) bot. We will specifically address its performance and its contribution to INES.

Extending chatterbot system into multimodal interaction framework with embodied contextual understanding


This work aims to realize multimodal interaction with embodied contextual understanding based on the simple chatterbot system. A system framework is proposed to integrate the dialogue system into a 3D simulation platform, SIGVerse to attain multimodal interaction. The chatterbot AIML implementations are described in the achievement of the conversations with embodied contextual understanding in HRI simulations.

Thursday, April 3, 2014

How to connect Serial Port with JAVA

Serial Port Programming
In Java , we commonly use RxTx library for serial programming..
2 Important Things to do:
·         Add RxTx jar into our project..

·         Copy RxTx serial.dll,RxTxParallel into c:\program files\java\jre\bin
To start coding import gnu.io.*…..
Steps:   1) Get Port
               2) Open it & initialize
               3) Starting i/p & o/p stream
               4) Adding event listener to listen for incoming data..
               5) Read
               6) Write
               7) Close

1 ) Get Port
Jobs
Search or specify desired port
Check Usage status
Open and Reserve it

Class javax.comm.CommPortIdentifier

public static Enumeration getPortIdentifiers();
public static CommPortIdentifier getPortIdentifier(String portName);
public boolean isCurrentlyOwned();
public String getPortName();
public int getPortType();

PORT_SERIAL or PORT_PARALLEL
Program Code:
 public void searchPort()
{int i=0;
String []r=new String(5);
Enumeration e=CommPortIdentifier.getPortIdentifiers();
  while(e.hasMoreElements())
{
CommPortIdentifier cpi=(CommPortIdentifier)e.nextElement ();
If((cpi.getPortType()==CommPortIdentifier.PORT_SERIAL)&&(cpi.isCurrentlyOwned==false))
{
   r[i]= cpi.getName();
i++;
}
 return r;}
2)Open  Port
Jobs :

Open and reserve it

Class javax.comm.CommPortIdentifier

public CommPort open(
String appName,// Reservation Name
int timeout// block waiting for port open (MS)
);

Class javax.comm.CommPort



Program Code:
 public CommPort openCommPort(String portName, String apname, int TIMEOUT){
CommPort cp=null;
try{
cpi=(CommPortIdentifier)r.get(portName);}
catch(NoSuchPortException a)
{
}
  try{
//return object of type CommPort
Cp=cpi.open(“apName”,TIMEOUT);
Sp=(SerialPort)cp ;       //cast CommPort objt to Serial Port objt}
 catch(PortInUseException s)
{
}
 open() :                          *    Main method
·         Instructs the program to open port which is stored in CommPort object
·         Then the object casted as a Serial port object for accessing methods and variables specific to serial port class.

Intialize Parameters:
·        Either we can individually set..
·        Or set them using Serialport setParams method..



Jobs

Initialization

Baud-Rate, Data Bits, Stop Bits, Parity, flow control

Class CommPort

public abstract void setSerialPortParams(
int baudrate,
int databits, // DATABITS_8, DATABITS_7,
int stopbits,// STOPBITS_1, STOPBITS_1_5,
int parity// PARITY_NONE, PARITY_ODD,
);

public abstract void setFlowControlMode(

int flowcontrol// FLOWCONTROL_NONE,
// FLOWCONTROL_RTSCTS_IN,
// FLOWCONTROL_RTSCTS_OUT,

·         Baud rate  - transmission rate of signals..
·         Start bit     - logical 0 to indicate receiver to start scanning
·         Data bit     - actual data
·         Parity bit    - for error detection
·         Stop bit      - Clock cycle needed to complete transmission
Code:

sp.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,Seria   lPort.PARITY_NONE);     

3) Starting i/p & o/p stream
Jobs

Use InputStreaming and OutputStreaming of CommPort object to do I/O

Code:
      OutputStream out=sp.getOutputStream();
      InputStream in=sp.getInputStream();

The streams are initialized by returning the input output streams of open serial port.

4)Setting up Event Listeners to Read data

·        Once the port is open,serial port must know whenever there is a data to be read .
·        In event driven approach, when the event is hit,a special block of code will run
·        Class needs to implement serialevent listener..
·        The base class have a method called serialEvent(event)that should be overridden before event code will work.
·        Overriiden defines what happens when the event is hit.
·        addEventlistener(this)-is the event that is always checking for Serial Event.
Code:
sp.addEventListener(this);

5) Reading Data
Public void serialEvent(serialPortEvent evt)
{
If(evt.getEventType()==SerialPortEvent.DATA_AVAILABLE)
{
 try{ byte[] temp;
int  length;
while(length==in.available())
{
 temp=new  byte[]length;
in.read(temp,0,length);
buffer.add(temp);
}
}
6. Write data
  public void writeData(CommPort cp,byte[]data)
{
 try {
out.write(data);
out.flush();
}
}
 Program Code Eg:
Output out=sp.getOutputStream();
String s=”ABCD”
System.out.println(“Begin to write”);
Byte[]data=s.getBytes();
 for(int i=0;i<data.length;i++)
{
 out.write(data[i]);
out.flush();
}
7)Close Connection
 public void disconnect()
{ sp.removeEventListener();
sp.close();
in.close();out.close();}








 Serial Port Programming
In Java , we commonly use RxTx library for serial programming..
2 Important Things to do:
·         Add RxTx jar into our project..

·         Copy RxTx serial.dll,RxTxParallel into c:\program files\java\jre\bin
To start coding import gnu.io.*…..
Steps:   1) Get Port
               2) Open it & initialize
               3) Starting i/p & o/p stream
               4) Adding event listener to listen for incoming data..
               5) Read
               6) Write
               7) Close

1 ) Get Port
Jobs
Search or specify desired port
Check Usage status
Open and Reserve it

Class javax.comm.CommPortIdentifier

public static Enumeration getPortIdentifiers();
public static CommPortIdentifier getPortIdentifier(String portName);
public boolean isCurrentlyOwned();
public String getPortName();
public int getPortType();

PORT_SERIAL or PORT_PARALLEL
Program Code:
 public void searchPort()
{int i=0;
String []r=new String(5);
Enumeration e=CommPortIdentifier.getPortIdentifiers();
  while(e.hasMoreElements())
{
CommPortIdentifier cpi=(CommPortIdentifier)e.nextElement ();
If((cpi.getPortType()==CommPortIdentifier.PORT_SERIAL)&&(cpi.isCurrentlyOwned==false))
{
   r[i]= cpi.getName();
i++;
}
 return r;}
2)Open  Port
Jobs :

Open and reserve it

Class javax.comm.CommPortIdentifier

public CommPort open(
String appName,// Reservation Name
int timeout// block waiting for port open (MS)
);

Class javax.comm.CommPort



Program Code:
 public CommPort openCommPort(String portName, String apname, int TIMEOUT){
CommPort cp=null;
try{
cpi=(CommPortIdentifier)r.get(portName);}
catch(NoSuchPortException a)
{
}
  try{
//return object of type CommPort
Cp=cpi.open(“apName”,TIMEOUT);
Sp=(SerialPort)cp ;       //cast CommPort objt to Serial Port objt}
 catch(PortInUseException s)
{
}
 open() :                          *    Main method
·         Instructs the program to open port which is stored in CommPort object
·         Then the object casted as a Serial port object for accessing methods and variables specific to serial port class.

Intialize Parameters:
·        Either we can individually set..
·        Or set them using Serialport setParams method..



Jobs

Initialization

Baud-Rate, Data Bits, Stop Bits, Parity, flow control

Class CommPort

public abstract void setSerialPortParams(
int baudrate,
int databits, // DATABITS_8, DATABITS_7,
int stopbits,// STOPBITS_1, STOPBITS_1_5,
int parity// PARITY_NONE, PARITY_ODD,
);

public abstract void setFlowControlMode(

int flowcontrol// FLOWCONTROL_NONE,
// FLOWCONTROL_RTSCTS_IN,
// FLOWCONTROL_RTSCTS_OUT,

·         Baud rate  - transmission rate of signals..
·         Start bit     - logical 0 to indicate receiver to start scanning
·         Data bit     - actual data
·         Parity bit    - for error detection
·         Stop bit      - Clock cycle needed to complete transmission
Code:

sp.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,Seria   lPort.PARITY_NONE);     

3) Starting i/p & o/p stream
Jobs

Use InputStreaming and OutputStreaming of CommPort object to do I/O

Code:
      OutputStream out=sp.getOutputStream();
      InputStream in=sp.getInputStream();

The streams are initialized by returning the input output streams of open serial port.

4)Setting up Event Listeners to Read data

·        Once the port is open,serial port must know whenever there is a data to be read .
·        In event driven approach, when the event is hit,a special block of code will run
·        Class needs to implement serialevent listener..
·        The base class have a method called serialEvent(event)that should be overridden before event code will work.
·        Overriiden defines what happens when the event is hit.
·        addEventlistener(this)-is the event that is always checking for Serial Event.
Code:
sp.addEventListener(this);

5) Reading Data
Public void serialEvent(serialPortEvent evt)
{
If(evt.getEventType()==SerialPortEvent.DATA_AVAILABLE)
{
 try{ byte[] temp;
int  length;
while(length==in.available())
{
 temp=new  byte[]length;
in.read(temp,0,length);
buffer.add(temp);
}
}
6. Write data
  public void writeData(CommPort cp,byte[]data)
{
 try {
out.write(data);
out.flush();
}
}
 Program Code Eg:
Output out=sp.getOutputStream();
String s=”ABCD”
System.out.println(“Begin to write”);
Byte[]data=s.getBytes();
 for(int i=0;i<data.length;i++)
{
 out.write(data[i]);
out.flush();
}
7)Close Connection
 public void disconnect()
{ sp.removeEventListener();
sp.close();
in.close();out.close();}