Notices

Applications and Utilities Talk about apps and utilities for Windows Mobile and PPC

Reply
 
LinkBack Thread Tools
Old 05-24-05, 07:59 PM   #1 (permalink)
Aximsite Prospect
 
Join Date: Apr 2005
Location: Mexico
Posts: 14
Thanked 0 Times in 0 Posts
Question Problems with MIDlet Comm Conecctions on Axim x30

Hello! ! ! I have a problem with my MIDlet J2ME that uses the interfaz Comm Connections to communicate my Dell Axim x30 with the mobile robot Koala of www.k-team.com using a serial cable RS232 for GPS.

Exactly the problem that I have is that if I can open up and to listen the port COM1, I receive messages of the mobile robot Koala but I cannot send messages to the robot.

Characteristics of the MIDlet:

baudrate: 9600
bitsperchar: 8
stopbits: 2
parity: none

Thank you!!!


I use Netbeans Mobility Pack, the MIDlet is executed perfectly and receives messages using the emulator of J2ME Wireless Toolkit, but when executing it in my Dell Axim x30 it doesn't work equally.


Next I present them the code source:


import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.Vector;
import java.io.InputStream;
import java.io.OutputStream;


public class CommMIDlet extends MIDlet implements Runnable, CommandListener{

private Display display;
private Form f;
private TextField tf;
private StringItem si;
private ChoiceGroup cg;
private boolean isPaused;

private Command openCommand = new Command("Open", Command.ITEM, 1);
private Command sendCommand = new Command("Send", Command.ITEM, 1);

private Sender sender;

public CommMIDlet() {

display = Display.getDisplay(this);
f = new Form("Port Selection");
cg = new ChoiceGroup("Please select port",
Choice.EXCLUSIVE, availablePorts(), null);
f.append(cg);

f.addCommand(openCommand);
f.setCommandListener(this);




display.setCurrent(f);
}

public boolean isPaused() {
return isPaused;
}

public void startApp() {
isPaused = false;
}


public void pauseApp() {
isPaused = true;
}

public void destroyApp(boolean unconditional) {
}

private String[] availablePorts() {

Vector vect = new Vector();
String ports = System.getProperty("microedition.commports");
int start = 0;
int end = 0;
while ((end = ports.indexOf(',', start)) != -1) {
vect.addElement(ports.substring(start, end).trim());
start = end + 1;
ports = ports.substring(start);
}
vect.addElement(ports);
String[] retVal = new String[vect.size()];
for (int i = 0; i < retVal.length; i++) {
retVal[i] = (String) vect.elementAt(i);
}
return retVal;
}


public void commandAction(Command c, Displayable s) {
if (isPaused()) {
return;
}
if (c == openCommand) {
new Thread(this).start();
}
if (c == sendCommand) {
sender.send(tf.getString());
}
}

public void run() {

try {
f = new Form("COMM Client");
si = new StringItem("Received:" , " ");
tf = new TextField("Send:", "", 30, TextField.ANY);
f.append(si);
f.append(tf);
f.addCommand(sendCommand);
f.setCommandListener(this);
display.setCurrent(f);

String name = cg.getString(cg.getSelectedIndex());
CommConnection commConn = (CommConnection)Connector.open(
"comm:" + name + ";baudrate=9600;bitsperchar=8;stopbits=2;parity=no ne");
InputStream iStream = commConn.openInputStream();
OutputStream oStream = commConn.openOutputStream();

sender = new Sender(oStream);

int ch = 0;

while (true) {
StringBuffer buf = new StringBuffer();
ch = 0;
while (ch != '\r') {
ch = iStream.read();
buf.append((char) ch);
}
si.setText(buf.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}

}
edparker is offline   Reply With Quote
Sponsor Ads
Reply

Tags
axim, comm, conecctions, midlet, problems, x30

Sponsor Ads

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:37 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-09 LeckMedia, LLC