Pages: [1]   Go Down
Author Topic: Serial monitor: bug in Arduino 1.0.1  (Read 1805 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Italy
Offline Offline
Brattain Member
*****
Karma: 333
Posts: 22973
Logic is my way
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think there's a bug in the serial monitor.
If you try a simple sketch like this:
Code:
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:
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.
Logged


Catania
Offline Offline
Sr. Member
****
Karma: 0
Posts: 346
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same for me under Windows 7
Logged

Monselice PD Italy
Offline Offline
Faraday Member
**
Karma: 28
Posts: 5515
фон Крыса
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same for me under Windows 7
+1
Same for me under Windows xp sp1, sp2 and Windows 7
Logged

Se corri veloce come un fulmine, ti schianterai come un tuono.

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No problem for me, on OS X.
Logged

0
Offline Offline
Edison Member
*
Karma: 24
Posts: 2316
Have you mooed today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No problem also for me, on Linux Debian.
Logged

0
Offline Offline
Shannon Member
****
Karma: 132
Posts: 10502
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the rror is here, SerialMonitor.java:
Code:
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:
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!


Logged

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

Global Moderator
Italy
Offline Offline
Brattain Member
*****
Karma: 333
Posts: 22973
Logic is my way
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Global Moderator
Milano, Italy
Offline Offline
Edison Member
*****
Karma: 23
Posts: 1180
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.

Logged

F

0
Offline Offline
Shannon Member
****
Karma: 132
Posts: 10502
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

0
Online Online
Faraday Member
**
Karma: 47
Posts: 5982
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks
Logged

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

Global Moderator
Italy
Offline Offline
Brattain Member
*****
Karma: 333
Posts: 22973
Logic is my way
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK. I'll follow the ticket.
Logged


Pages: [1]   Go Up
Jump to: