Hi @david42928. Thanks for taking the time to share this information! I've never been able to produce this "can't set com-state for ..." error message, but I see it reported here on the forum periodically.
I'd like to ask you for more information about some of these steps in hopes I can understand the specific conditions the error occurs under.
Does the computer still recognize the COM port of the Arduino board after you do that?
Do you remember where you downloaded the drivers from at the time you installed them?
Did you find that this specific version of Arduino IDE was required, or is it just the one you happened to install? I ask because 1.8.9 is fairly outdated (the latest version of the Arduino IDE 1.x series is 1.8.19)
Does the "ser_open(): can't set com-state for ".COM3"" error still occur if you try uploading without Serial Monitor open?
Hello all. I recently came across this issue as well on some chinesse NANO copies (with USB C and mini USB) and this is my take on it:
I did not need to the above as described by @david42928: steps 1,2,3,4,5,6,8; I only needed to use arduino version 1.8.19 and not Arduino IDE 2.2.1.
I can only upload a sketch with the serial monitor open, as described at step 7 and 9.
The boards used are 2 nano (bought on aliexpress) which have apparently CH340 driver, but the IC has NOTHING written on it, so it might not be the usual WCH340.
If you tell me how...i can send/post pictures.
With serial monitor closed the following error appears:
----On Arduino IDE 2.2.1:
avrdude: ser_open(): can't set com-state for "\.\COM14"
Failed uploading: uploading error: exit status 1
followed by pop-up: "Port monitor error: command 'open' failed: Invalid serial port. Could not connect to COM14 serial port." -->> this also shows up if you try to open the serial port on Arduino IDE 2.2.1.
----On Arduino 1.8.19
avrdude: ser_open(): can't set com-state for "\.\COM14"
An error occurred while uploading the sketch
I have an update:
I observed that step no.8 is true to some degree for me...in order to upload the sketch i open the serial monitor, but if is set to baud rate higher than 9600 it will not upload the sketch:
Exact steps i took to find out:
open serial monitor set to 115200
here something strange happens as the previous uploaded code runs and I receive information via serial with no problem, but in the output window I receive:
"Error while setting serial port parameters: 115,200 N 8 1"
After pressing upload i receive:
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:\Users\...\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM13
Using Programmer : arduino
Overriding Baud Rate : 57600
avrdude: ser_open(): can't set com-state for "\.\COM13"
avrdude done. Thank you.
An error occurred while uploading the sketch
Error while setting serial port parameters: 115,200 N 8 1"
4. Now just by changing the baud rate in the still opened serial monitor 1 receive:
"Error while setting serial port parameters: 74,880 N 8 1
Error while setting serial port parameters: 57,600 N 8 1
Error while setting serial port parameters: 38,400 N 8 1
Error while setting serial port parameters: 19,200 N 8 1"
(each line shows after each baud change)
So, I conclude that it has something to do with the 'fake' / unscriptioned CH340 driver present on the board.
If you are using Windows 11 try to use the Windows 10 CH340= driver 3.5.2019.1, this solve my problem. Uninstall the Window 11 driver dated 2023 and download the driver above and install it.
I had the same problem. I was able to upload a simple Blink example, but not my own program. And I thought there's no problem in my program, since I successfully tested it on other Arduino before. But actually, that was the problem. I had this in my program (for console logs):
void setup() {
Serial.begin(9600);
}
Then I read that different Arduinos use different baud rates. Originally I tested it on Arduino Mega, but this time I wanted to upload it to "unofficial" Arduino Nano (for which you have to use ATmega328P (Old Bootloader) option when uploading).
Since I didn't need debug logs in my program anymore, I removed these 'Serial' commands completely. Then it got uploaded without problems.