Skip to Main Content

Embedded Technologies

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

serial connection on ipaq

843849Sep 22 2005 — edited May 10 2007
Hi everyone,

I am having problems reading a bytestream from a measuring device via an rs-232 serial connection.

I am using the j9 CVM on my HP HX2110.
I've installed the serial driver from RXTX on my ipaq (with the windows mobile 2003 os) and am using sun's javax.comm.

Now i've got working code going.. and when I connect my pocket-pc to my laptop and send strings from the laptop there is a response..
Also - when i run the code from my program on my laptop - it can read data from the measuring device .. so I know the device works.

However, when I make the connection from my measuring device to the pocket-pc.. nothing happens, there is no response at all.

I have a theory that the problem is to do with the actual driver .. so i may need to delve into the driver code.. ( ulp! ) before i start though - I was wondering if anyone had any ideas about what the problem could be?
Or what they think is the best way to getting around the problem is?

Any suggestions/ comments would be so greatly appreciated!!

Thanks,
Marie


This is the code i'm testing with, which i actually found in this forum:
---------------------------------------------------------------------------------
import javax.comm.*;
import java.io.*;
import java.util.Enumeration;

public class Test {

private static CommPortIdentifier portId;
private static CommPortIdentifier somePortId;
private static SerialPort serialPort;
private static InputStream is;
private static BufferedReader cmd = (
new BufferedReader(new InputStreamReader(System.in)));
private static int buffer;


public static void main(String[] args) {
try
{
CommDriver driver = (CommDriver)Class.forName("rxtxSerial").newInstance();
driver.initialize();
} catch (Exception e) {
System.out.println( e.getMessage () );
}

Enumeration ports = CommPortIdentifier.getPortIdentifiers();

System.out.println( "Ports found :" );

while( ports.hasMoreElements() ) {
somePortId = (CommPortIdentifier) ports.nextElement();

System.out.println( somePortId.getName() + " used by "
+ somePortId.getCurrentOwner() );
System.out.println(somePortId.getName() + " type: "+
somePortId.getPortType());
if( somePortId.getName().equals("COM1:") ) {
portId = somePortId;
}
}

System.out.println( "End ports found" );

if(portId != null) {
try
{
System.out.println( "Opening " + portId.getName() + " ..." );
serialPort = (SerialPort) portId.open("Test", 2000);
is = serialPort.getInputStream();

while(true) {
System.out.print( "-" );
buffer = is.read();
System.out.print("read in something...");
System.out.print(buffer);
}
}
catch(Exception e) {
e.printStackTrace();
}
}

try {
cmd.readLine();
}
catch( IOException e) {
e.printStackTrace();
}
}
}
------------------------------------------------------------------------------------
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2007
Added on Sep 22 2005
4 comments
198 views