Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
FIXED: Arduino serial monitor failed
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Erdie
Advocate
Advocate


Joined: 20 May 2004
Posts: 2625
Location: Heidelberg - Germany

PostPosted: Sun Feb 26, 2023 5:11 pm    Post subject: FIXED: Arduino serial monitor failed Reply with quote

Dear all,

when I triy to open the serial monitor within the Arduino IDE, the ardunio is reset and the console does not work. The log output shows the following:

Code:

Exception in thread "EventThread /dev/ttyUSB0" java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
   at processing.app.Serial.processSerialEvent(Serial.java:210)
   at processing.app.Serial.serialEvent(Serial.java:183)
   at jssc.SerialPort$LinuxEventThread.run(SerialPort.java:1299)


I am working with arduino nano and I even made a lot of projects with esp8266. In the past the serial monitor worked definatly. For testing I switched back to an old project with esp8266 and I get the same error when starting the monitor.

I guess this is a java vm issue, trying "eselect java-vm list" gives me:

Code:

eselect java-vm list
Available Java Virtual Machines:
  [1]   openjdk-bin-8  system-vm
  [2]   openjdk-bin-17  user-vm


In my opinion the baud rate cannot be the reason since my unchanged old project do not work either.

I tried both vms and get the error with both of them. Are there any ideas how to fix this?
_________________
Desktop AMD Ryzen 9 5900X 32GB RAM, Asus GF GTX 1060.
Notebook Tuxedo Pulse 15 Gen1 AMD Ryzen 7 4800H mit Radeon Vega 7
Raspberry Pi 1 + 2 + 3B+ + Zero W


Last edited by Erdie on Mon Feb 27, 2023 3:21 pm; edited 2 times in total
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1136
Location: Richmond Hill, Canada

PostPosted: Sun Feb 26, 2023 6:02 pm    Post subject: Reply with quote

Erdie,

I found a github issue seems to match your error message. The explanation is that Java 9 change the API for the flip() method from returning Buffer to ByteBuffer.

So my guess is that if you can use java8 it will probably work.
Back to top
View user's profile Send private message
Erdie
Advocate
Advocate


Joined: 20 May 2004
Posts: 2625
Location: Heidelberg - Germany

PostPosted: Sun Feb 26, 2023 7:03 pm    Post subject: Reply with quote

pingtoo wrote:

So my guess is that if you can use java8 it will probably work.


Unfortunately the error persits if I switch the java-vm like this:

Code:

eselect java-vm list
Available Java Virtual Machines:
  [1]   openjdk-bin-8  system-vm user-vm
  [2]   openjdk-bin-17


Or isn´t that option really "java8" ?
_________________
Desktop AMD Ryzen 9 5900X 32GB RAM, Asus GF GTX 1060.
Notebook Tuxedo Pulse 15 Gen1 AMD Ryzen 7 4800H mit Radeon Vega 7
Raspberry Pi 1 + 2 + 3B+ + Zero W
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1136
Location: Richmond Hill, Canada

PostPosted: Sun Feb 26, 2023 8:13 pm    Post subject: Reply with quote

Erdie,

Assume your "Arduino IDE" is based on dev-embedded/arduino.

I found additional two online articles that match the error message "java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer". [1], [2]

They all basically explain the same in the link I previously posted. It is caused by newer version of java compiler build for older 1.8 java target usage will have incompatibility issue.

[1] is from arduino forum which lead to a old arduino github issue suggest for Arch using a older version of arduino package will solve this problem. But in Gentoo I guess you don't have this option because it is a very old arduino version.

[2] is a detail explain of why newer version java compiler by default will create incompatible code for java 1.8 and offered a suggestion on how to using newer version java compiler to produce java 1.8 compatible code. However when I review Gentoo dev-embeded/arduino ebuild file, I found it is just taking githib anduino/Anduino project release and repackage to fit into Gentoo portage. In the ebuild I did not see there is compile stage. so It will not be easy to modify with [2] suggestion.

As suggestion in [1] it is recommend that use official Arduino IDE bundle to development your project. Otherwise you can try to rebuild dev-embedded/arduino after you switch to java 1.8 to see if the result build will work for you.

  1. Minimum java version
  2. ByteBuffer and the Dreaded NoSuchMethodError
Back to top
View user's profile Send private message
Erdie
Advocate
Advocate


Joined: 20 May 2004
Posts: 2625
Location: Heidelberg - Germany

PostPosted: Mon Feb 27, 2023 9:48 am    Post subject: Reply with quote

Thanks, I will try the last option (rebuild IDE after switching java version). BTW I also found multiple sources about java version issues and therefore my guess was exactly like that. Let me try to rebuild the IDE fist.
_________________
Desktop AMD Ryzen 9 5900X 32GB RAM, Asus GF GTX 1060.
Notebook Tuxedo Pulse 15 Gen1 AMD Ryzen 7 4800H mit Radeon Vega 7
Raspberry Pi 1 + 2 + 3B+ + Zero W
Back to top
View user's profile Send private message
Erdie
Advocate
Advocate


Joined: 20 May 2004
Posts: 2625
Location: Heidelberg - Germany

PostPosted: Mon Feb 27, 2023 3:20 pm    Post subject: Reply with quote

Setting system & user vm to openjdk-bin-17 and rebuilding dev-embedded/arduino did the job!

Thanks!
_________________
Desktop AMD Ryzen 9 5900X 32GB RAM, Asus GF GTX 1060.
Notebook Tuxedo Pulse 15 Gen1 AMD Ryzen 7 4800H mit Radeon Vega 7
Raspberry Pi 1 + 2 + 3B+ + Zero W
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum