Subject:
|
AW: lejos program terminating immediately
|
Newsgroups:
|
lugnet.robotics.rcx.java
|
Date:
|
Thu, 11 Aug 2005 08:59:25 GMT
|
Reply-To:
|
<jochen.hiller@top-logic=StopSpammers=.com>
|
Viewed:
|
6782 times
|
| |
| |
Hi Jason,
you have to loop within your main program, otherwise main() will be left.
E.g. use
while (true) {
Thread.sleep (1000);
}
or, use a button listener, and exit when some button has been pressed.
HTH, Jochen
> -----Ursprüngliche Nachricht-----
> Von: news-gateway@lugnet.com [mailto:news-gateway@lugnet.com]Im Auftrag
> von JasonQ
> Gesendet: Mittwoch, 10. August 2005 17:11
> An: lugnet.robotics.rcx.java@lugnet.com
> Betreff: lejos program terminating immediately
>
>
> Hi,
>
> I'm trying to use leJOS to display the current value of the
> rotation sensor I
> have hooked up to Sensor Port 1, but when I run the program, the
> RCX just beeps
> and ends the program immediately. Here's my code:
>
>
>
> import josx.platform.rcx.*;
>
> public class Rot_test
> {
> public static void main (String[] args) throws Exception
> {
> Sensor.S1.setTypeAndMode (SensorConstants.SENSOR_TYPE_ROT,
> SensorConstants.SENSOR_MODE_ANGLE);
> Sensor.S1.addSensorListener(new SensorListener() {
> public void stateChanged(Sensor aSource, int aOldValue, int
> aNewValue){
> LCD.clear();
> Integer i = new Integer(aNewValue);
> String s = i.toString();
> TextLCD.print(s);
> }
> });
> Sensor.S1.activate();
> }
> }
>
>
>
>
> I have a question about leJOS that may be related to this (and I
> think it may
> have to do with the problem I'm having). When a leJOS program is
> set up, and
> the program finishes executing all of the code in the main(String[] args)
> method, does the program just end?
>
> I think the problem with my code may be that I set up the
> listeners, but after
> the program finishes reading all of the code in the method, it
> just exits and
> never watches the rotation sensor.
>
>
>
> Does anyone know why I'm having this problem or what it is?
>
>
> Thanks,
>
> Jason
|
|
Message is in Reply To:
| | lejos program terminating immediately
|
| Hi, I'm trying to use leJOS to display the current value of the rotation sensor I have hooked up to Sensor Port 1, but when I run the program, the RCX just beeps and ends the program immediately. Here's my code: import josx.platform.rcx.*; public (...) (19 years ago, 10-Aug-05, to lugnet.robotics.rcx.java)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|