Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RFID Problem  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys i have a problem in my RFID kit program actually i can able to read
the device while after opening & closing the software originally given by the vendor.
can anybody help me to do my program as stand aone:

here my code is :

import java.util.*;
import javax.comm.*;

class opensesay implements Runnable,SerialPortEventListener {

static CommPortIdentifier portId;
static Enumeration portList;
static SerialPortEvent event;

InputStream inputStream;

SerialPort serialPort;
Thread readThread;

public static void main(String[] args) {

portList = CommPortIdentifier.getPortIdentifiers();


portId = CommPortIdentifier.getPortIdentifier("COM1");

opensesay reader = new opensesay();

catch (NoSuchPortException nspe)
System.out.println("No port named COM1 found");
catch (UnsupportedCommOperationException ucoe)
System.out.println("Could not enable receive threshold.");


public opensesay() throws UnsupportedCommOperationException {

try {

serialPort = (SerialPort)"opensesayApp", 2000);

} catch (PortInUseException e) {}
try {


System.out.println("Port '" + serialPort.getName() + "' settings:");
System.out.println("\tInput Buffer Size: " + serialPort.getInputBufferSize());
System.out.println("\tReceive Framing Enabled? " + serialPort.isReceiveFramingEnabled());
System.out.println("\tReceive Framing Byte: " + serialPort.getReceiveFramingByte());
System.out.println("\tReceive Threshold Enabled? " + serialPort.isReceiveThresholdEnabled());
System.out.println("\tReceive Threshold: " + serialPort.getReceiveThreshold());
System.out.println("\tReceive Timeout Enabled? " + serialPort.isReceiveTimeoutEnabled());
System.out.println("\tReceive Timeout: " + serialPort.getReceiveTimeout());
inputStream = serialPort.getInputStream();

} catch (IOException e) {

try {


} catch (TooManyListenersException e) { }


try {


} catch (UnsupportedCommOperationException e) {}

readThread = new Thread(this);



public void run() {

try {


} catch (InterruptedException e) {}


public void serialEvent(SerialPortEvent event) {

switch(event.getEventType()) {

case SerialPortEvent.BI:

case SerialPortEvent.OE:

case SerialPortEvent.FE:

case SerialPortEvent.PE:

case SerialPortEvent.CD:

case SerialPortEvent.CTS:

case SerialPortEvent.DSR:

case SerialPortEvent.RI:

case SerialPortEvent.OUTPUT_BUFFER_EMPTY:


case SerialPortEvent.DATA_AVAILABLE:

byte [] readBuffer = new byte[4096];
//int [] s = new int [4096];

try {
while (inputStream.available() > 0) {
//System.out.println("Available bytes: " + inputStream.available());
int numBytes =;
//for(int i = 0;i<4096;i++) s[i] = readBuffer[i];
//System.out.println("Number of bytes read: " + numBytes);
System.out.println("\"" + new String(readBuffer).trim() + "\"");
//for(int i = 0;i<4096;i++)System.out.print("\"" + s[i]+ "\"");
} catch (IOException e) {}



help me to trap this problem out.

thanks in advance
Joel McNary
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Green Java:

Welcome to JavaRanch! While we at JavaRanch are glad to help you out, there's a few things that you could to do to help us help you. First, please read the Java Ranch Naming Policy and then change your display name to comply. (We are looking for a real-sounding first and last name.)

Second, What exactly is the problem you are having? A cursory glance doesn't show any specific problems, and many of us here do not have time for more than a cursory glance. If you can be as specific in you question as possible, that would help. (See How To Ask Questions The Smart Way

Third, please use [CODE] and [/CODE] tags along with formatting when posting code. It makes it easier to read.

[ April 12, 2005: Message edited by: Joel McNary ]
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!