Hello, I’m actually not very experienced with coding but my friend who wrote this is out of town and i was hoping i could find a solution soon.
So the basic part of the issue is that this code has always been problematic. You can throw a dart at a board of computers and maybe 1 or 2 out of 10 will actually work. Up until last week my hp spectre could run the code and my friends hp pavilion could run it. But my computer did an update (20h1) and now it isn’t working. So i am basically screwed by Microsoft once again.
What im trying to do is use processing to control some esc’s on an arduino through firmata. xbox controller ->laptop ->Aduino->ESC->BLDC motor
This is the problem bit of code.
arduino = new Arduino(this, Arduino.list()[8], 57600); // finds arduino usb location
Whats happening is what happens when their is no Arduino attached. Regardless of the arduino, usb port, or polling rate i am getting a failed connection and no display of serial communication.
I.E. ArrayIndexOutOfBoundsException: 8
Could not run the sketch (Target VM failed to initialize).
This is a major frustration and i have attempted to use linux but I’m not very experienced and i couldn’t install processing on Ubuntu. I may have to do the unthinkable and get a used mac.
We have that piece of code and i know for sure that COM8 is the Arduino because it is identified in device manager and with the code you mentioned. The issue is that no matter what USB port i use and what Arduino i use with whichever cable the software has no communication with the Arduino. I’m fairly sure its either an incompatibility with the library or a driver incompatibility in windows because it works well on some computers but not others. I wouldn’t be surprised because the library was last updated in 2017.
It’s so frustrating. It seems not to work on any USB 2.0 port for some reason and will only function on laptops with USB 3.1 extensible hosts. that is, until my laptop did an update and now it wont work.
Because its so hit and miss i think my only option is to get a used mac or something. And i cant afford to reset my laptop back to windows 20h0 right now.
Also, i know their is no communication at all because the TX and RX leds aren’t responding.
Thanks, i appreciate your response. Its good to double-check things.
ANOTHER tid bit. i figured out with another firmata based software that the communication is possible it is just something messed up with processing. It seems like processing is unable to fetch the Arduino even with it specified. IE it is proceeding’s issue with a driver on windows.
Try @glv’s suggestion and print the list of serial ports. If the Arduino port is not present then you have confirmed that Processing is not ‘seeing’ the port and possibly you have a driver issue. For example, if the Arduino is a clone it may not be using the FTDI Serial-USB chip but perhaps the CH340 and the Windows update may have removed the old driver…
I’m not using Firmata but I have no problems in Processing connecting to various Arduinos that I use e.g. Nano, Uno and ATmega varieties all work.
As i said, i have used that piece of code and it does identify 3 com ports, specifically COM-8 is the Arduino and even after selecting it still fails to connect. I am also using two genuine Arduino Uno’s. It is such a conundrum because the software knows their is a come device but cannot connect.
I will try to find some older Arduino drivers and use them. The really frustrating is that other firmata based software’s can connect to the Arduino. I tried to use windows remote Arduino service which could connect and initialize the motors. i am also having no issues installing the code on the Arduino. there are no issues writing to it.
The issue is that somewhere along the line processing cant write to the Arduino.
Thanks fro the response, i appreciate it.
These issues are seriously testing my patience and stress.
I know how you feel! Maybe you should write a very simple sketch on the Arduino and one in Processing to send some simple ASCII text strings from Processing to the Arduino. You can’t run the Arduino Serial monitor to show what it’s receiving because the port will already be in use but if you use Serial.println() in the Arduino sketch to echo what it’s receiving back to the Processing IDE you will be able to read them in Processing’s console.
This should establish if Processing is communicating correctly with the Arduino. I always start off simple and build things up in stages!
You’re right of course. I was assuming all COM ports were present but the OP needs to find the actual index for his “COM8”. That was why I suggested he follow your original advice and print out the Serial.list() to the console.
You wouldn’t believe the hours I’ve spent over the years looking for some ‘complex bug’ only to find it was something simple staring me in the face the whole time.
Here is all the code! thanks so much, you guys are awsome!!! and this is the robot im trying to get working. We are a small robotics team in port townsend working on ocean reclamation with it. I was being kinda coy because i wasn’t sure what kind of reception i would get.
I still think you should use the simple test code that @glv provided earlier to make doubly sure the COM port is what you think it is. The original error you posted “ArrayIndexOutOfBoundsException: 8” would indicate that you are using the wrong array index. If you know that your Arduino is definitely COM8 then run the test sketch and you will be able to read the index value [x] for the “COM8” entry in the Serial ports list.
Are you using the same computer and plugged into the same USB port? If not, the COM port assigned to the Arduino could be different. Can you please open Windows Device Manager control panel, expand the Ports (COM & LPT) entry, take a screenshot and post it here so we can see. BTW you don’t need to host the image just copy and paste it in your reply
DUDE I COULD FREAKING GIVE YOU A HUG. This worked, I have no idea why this slight syntax change fixed it but i love you man. I have been ripping my hair out for a while with why this wasn’t working. I cannot say thanks enough.
I would be interested to know why the change from
this, (arduino = new Arduino(this, Arduino.list()[8], 57600)
to this (arduino = new Arduino(this, “COM8”, 57600)
fixed the issue, especially given that it worked on some computers but not others?