wood burning stoves 2.0*
The moose likes Java Micro Edition and the fly likes Problem in openning serial port Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Problem in openning serial port" Watch "Problem in openning serial port" New topic
Author

Problem in openning serial port

Mostafa Ahmad
Greenhorn

Joined: Feb 22, 2011
Posts: 11
Hello
I used the following code to open serial port on nokia N70 mobile

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.CommConnection;
import javax.microedition.io.Connector;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.*;

/**
* @author mostafa
*/
public class Serializer extends MIDlet {
Connector con;
OutputStream os = null;
CommConnection cc = null;
InputStream is = null;
Alert alert;
int i=0;

public void startApp() {

try {
cc = (CommConnection) Connector.open("comm:com0;baudrate=19200");
i=1;
//int baudrate = cc.getBaudRate();


is = cc.openInputStream();
i=2;


os = cc.openOutputStream();
i=3;
int ch = 0;
while(ch!=10)
os.write('k');
i=4;
cc.close();
i=5;
os.close();
i=6;
}
catch (Exception ex) {
String s= ex.getMessage();
alert = new Alert("Problem");
alert.setString(s+""+"i="+i);
alert.setTimeout(alert.FOREVER);
Display.getDisplay(this).setCurrent(alert);

}

}
public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
}


And the output on the mobile screen was:
java.lang.ClassNotFoundException: com/symbian/midp/io/protocol/comm/Protocol
i=1
(which means it throwed the exception during this command: cc = (CommConnection) Connector.open("comm:com0;baudrate=19200");)

Can any one tell me what is wrong?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in openning serial port
 
Similar Threads
Serial port
midp 2 i/o question
IO Exception
Serial Port Profile baud rate problems
Infrared printing from Siemens C65