- Ensure that you have properly installed the MATLAB Support Package for Arduino Hardware.
- Enter the following command into your MATLAB Command Window: "cd(arduinoio.IDERoot)"
- Open the Arudino IDE by executing the following command in the MATLAB Command Window: "!arduino.exe"
- Upload and run a "blink" example on your board. This pre-defined program can be accessed in the Arduino IDE via File > Examples > 01.Basics > Blink
Arduino Fails to Program with "avrdude: ser_open(): can't set com-state" Error
31 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 10 Jun. 2024
Bearbeitet: MathWorks Support Team
am 28 Aug. 2024
I have an Arduino Uno device and have attempted to attach it to one of my computer's COM Ports via a USB cable. I have downloaded the MATLAB Support Package for Arduino Hardware, and ensured that it is correctly accessed by my MATLAB installation via the following commands:
>> restoredefaultpath
>> rehash toolboxcache
Following this, I enter the "arduinosetup" command into my MATLAB Command Window, and follow the instructions described in the following MATLAB Documentation:
I have ensured that I am selecting both the correct board as well as the correct COM port. However, when I press "Program", I receive the following error message:
Failed to program the arduino board. Click the following link to see the error log. Contact Technical support if you need more help.
Clicking the link in that message provides me a TXT file with a fairly large stack trace. The most important lines, however, seem to be at the end. These read the following:
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\ProgramData\MATLAB\SupportPackages\R2023a\aIDE\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't set com-state for "\\.\COM5"
avrdude done. Thank you.
An error occurred while uploading the sketch
Upon receiving this error, I tried a few initial troubleshooting steps:
- Uninstalling and then reinstalling the MATLAB Support Package for Arduino Hardware.
- Connecting to a different COM port.
- Restarting both my system and my Arduino board.
Unfortunately, none of the above steps changed the resulting error message. How do I fix this and ensure that I am able to interact with my Arduino board via MATLAB?
Akzeptierte Antwort
MathWorks Support Team
am 28 Aug. 2024
Initial Hardware Testing
If you are using MATLAB R2024a or later
As of MATLAB R2024a, it appears that the Arduino IDE is no longer shipped with the MATLAB Support Package for Arduino Hardware. As such, you will need to download the Arduino IDE from their website, such as via the following URL:
After downloading this program, run it and complete step 4 of the list below, which has you run the "Blink" example.
If you are using MATLAB R2023b or Earlier
It is important to first test whether this issue arises from MATLAB itself or if it is an external issue, such as one deriving from the drivers or the board itself. Note that this step is essential as, if the issue does not lie with MATLAB, MathWorks is unable to assist with the issue past providing external resources and recommending that the customer contact Arduino support. To test this, make use of the following steps:
The Program Failed to Upload and Run - What's Next?
If the "blink" program fails to upload via the Arduino IDE, the issue likely lies outside of any product created by MathWorks. As such, our ability to provide support is limited.
A common cause for this issue is that Windows has inadvertently downloaded the incorrect drivers for the board. Because issues such as these lie with Arduino and Windows, we are limited in the actions that we can take. There are two recommendations to troubleshoot this issue, outlined below.
Manually check and install the appropriate drivers.
There is the possibility that the device is fully recognized by the computer. For instance, it may appear in the list of devices in the Arduino IDE under Tools > Port. However, this does not indicate whether the drivers are correct. To check this, and to install the appropriate drivers, the user should consult the following post on the Arduino support forum:
Contact Arduino Support
While MathWorks is likely unable to help with the issue beyond providing the above resource, Arduino Support may prove more useful. As such, it is recommended that those experiencing this issue contact Arduino via their Help Center. The following URL provides quick access to this resource:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!