How do I suspend the application to wait for response from BluetoothSerialPort

I worked on that for too many days without much progress, so hopefully for more help.  For this application, I started with one of the examples BluetoothSerialPort programs.  I've added a couple more screens so that I can display different information and send data via bluetooth connection. I built a Board that has a bluetooth module and a microproccessor to talk to a car via a network BOX.  I am able to send to and receive messages from the network at this point.  Currently, I try to get a RealTimeData screen to send messages CAN and then analyze the messages returned from the CAN. I'm sure there are much better ways to do this, but I'm new on this.

Current issue: get the program to pause in order to wait for a response from the from the network.

public void updateData(){
        String _dataString;
    if(_port != null){
    _data.delete(0, _data.length());
    sendCANMessage("7DF","8",false,"02","01","05","00","00","00","00","00");

    //pause(2000);
    Dialog.alert("before _data.toString()");

    _dataString = _data.toString();
    int indexOfRx = _dataString.indexOf("RX ");
    coolentTemp =
               Integer.parseInt(_dataString.substring(indexOfRx+43,indexOfRx+45),16);
    coolentTemp = (((coolentTemp-40)*9)/5)+32;//subtract 40 then convert to F.

    efCoolentTemp.setText(coolentTemp + " F");
}

public void pause(int ms) {
        try {
        Thread.sleep(ms);
        } catch (InterruptedException ie){
            //do something
        }
    }

The break (2000) (which is commented out in the code example above) does not work.  So far I was able to make it work by the Dialog.alert in there, because it seems to stop the function so that the data can be returned.  The break is so long because I manually hit the Send button while I test.  If I use the alert dialog boxes I can get to work analysis.  When I use the pause() function, it seems to stop running, but in the wrong place.  He pauses before the sendCANMessage function.

Any ideas?  Examples of code would be very useful.  I use Eclipse w / plugin. I'd be happy to send the exported project if anyone is willing to look at.

Hi and welcome to the forums.

How do you run that?  You should not run the activity like this on the thread of events, but I suspect that since you can issue a Dialog.alert, you actually do.

Also, since we do not know what sendCANMessage (.) did, it's a little difficult, of course what happens.  But I would certainly start by ensuring that you are not running on the thread of events.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for

  • Dropped my iphone 6 in water, just the apple logo appears

    I dropped my iphone in the water two days back... I tried to turn off immediately, things would turn itself after a few seconds... I let it run out of battery, and finally he was out... I let it dry... Tried to remove the water forms all grooves... I

  • < textarea > display line with new car

    I am creating a page aspx with a text box and a button. The text box is created like this: If the text is longer than 30 characters long, the text will scroll but remain in a line and the user cannot see all of the text that he hit. I would like that

  • Select the audio recording device

    I have inspiron 1501 (a new replacement), with 32-bit amd anthlon, windows vista OS. My micro phone volume was very low, the person on the voice chat could not hear it. I tried to make it work properly, by mistake, I disabled the device for registrat

  • ACS - ASA authorization and accounting

    Hello I have a few questions about the authorization and accounting on the ASA via an ACS server When I activate the command 'aaa authorization command' users of SSH commands I get locked on console then I have to configure the console, telnet and al

  • Windows XP Pro does not connect to a 6500 printer (ethernet only)

    I have the printer doesn't work for Windows 7, Ubuntu 10 and Mint 10 but after you run the HP Wizard on the XP machine, it will not see printer. I tried to connect via printer IP and host name using the tip box. I can ping the address of the printer