Go Down

Topic: Serial monitor: bug in Arduino 1.0.1 (Read 1 time) previous topic - next topic

leo72

I think there's a bug in the serial monitor.
If you try a simple sketch like this:
Code: [Select]
void setup()
{
  delay(2000); 
  Serial.begin(19200);
}

void loop()
{
  Serial.println("Hello");
  delay(1000);
}

If you open the serial monitor and you have a baud rate different than the speed that you set into the sketch (i.e. 9600 bps), trying to change the baud speed will generate a Java error:
Code: [Select]
Experimental:  JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1958)
at processing.app.SerialMonitor$6.actionPerformed(SerialMonitor.java:137)
at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1260)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:588)
at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:624)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:835)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:499)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
at java.awt.EventQueue.access$000(EventQueue.java:102)
at java.awt.EventQueue$3.run(EventQueue.java:662)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:676)
at java.awt.EventQueue$4.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

(message kept under Arch Linux)
This happens with Linux and Windows versions of Arduino IDE.

The same operation can be done without issues with Arduino 0022.

dalubar


ratto93


Same for me under Windows 7

+1
Same for me under Windows xp sp1, sp2 and Windows 7
Se corri veloce come un fulmine, ti schianterai come un tuono.

dxw00d


pitusso

No problem also for me, on Linux Debian.

lesto

the rror is here, SerialMonitor.java:
Code: [Select]

serialRates.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent event) {
       String wholeString = (String) serialRates.getSelectedItem();
       String rateString = wholeString.substring(0, wholeString.indexOf(' '));
       serialRate = Integer.parseInt(rateString);
       Preferences.set("serial.debug_rate", rateString);
       closeSerialPort();
       try {
         openSerialPort();
       } catch (SerialException e) {
         System.err.println(e);
       }
     }});


can you change it to

Code: [Select]
serialRates.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent event) {
System.out.println("serialRates: "+(String) serialRates.getSelectedItem());
       String wholeString = (String) serialRates.getSelectedItem();
       System.out.println("wholeString: "+wholeString);
       String rateString = wholeString.substring(0, wholeString.indexOf(' '));
       System.out.println("wholeString: "+rateString);
       serialRate = Integer.parseInt(rateString);
       Preferences.set("serial.debug_rate", rateString);
       closeSerialPort();
       try {
         openSerialPort();
       } catch (SerialException e) {
         System.err.println(e);
       }
     }});


and tell me what appen? i can't reproduce the error!


sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

leo72

I'm not able to recompile the IDE (no Java experience).

Federico Vanzati

If you want to recompile the Arduino IDE under Linux, it's quite easy and doesn't need Java experience. The steps you must follow are:

1) Download from Github the souce code of the Arduino IDE
2) Make sure that on your linux box "apache ant" is installed, if not install it.
3) Apply your modification to the code
4) When you are ready to compile the IDE open a shell, move to the dir ".../Arduino/build" and type:
Code: [Select]
ant; ant clean; ant build
5) The build process will start and after it finishes you can launch the IDE using the command "ant run" or moving to the directory that the build process has generated: ".../Arduino/build/linux/work" and launch the IDE as usually.

F

lesto

i want to let you know that EVERY arduino 1.0.1 is afflicted by this problem, and i've open an issue with the solution:

http://code.google.com/p/arduino/issues/detail?id=964&can=6&sort=-id
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Testato

- [Guida] IDE - http://goo.gl/ln6glr
- [Lib] ST7032i LCD I2C - http://goo.gl/GNojT6
- [Lib] PCF8574+HD44780 LCD I2C - http://goo.gl/r7CstH

leo72


Go Up