Menu

Program not connecting to serial port

2023-06-25
2023-10-18
  • Juan Gonzalez

    Juan Gonzalez - 2023-06-25

    Hello. In parallel with the issues I am having with myfocuserpro2, and that you are already helping me to solve, I have lost the possibility of connecting to myrotator. I believe it might be because I have changed miniPC to a win11... I have updated winAPP and firmware to the latest version but windows says "COMport is n invalid state or parameter is wrong".
    I ca connect it properly in an old win8.1 pc, but within the new win11 minipc there is no way...
    Any clues?
    Thanks

     
  • brownrb

    brownrb - 2023-06-26

    Hi Juan

    1. Reinstall CH340G driver under Win11
      try
      http://www.wch-ic.com/products/CH340.html

    scroll down to bottom of page where the drivers are
    and click on
    CH341SER.EXE
    to download the drivers for Arduino Nano CH340G
    then run the exe to install the drivers

    1. If still not working
      delete existing arduino ide - use control panel
      install latest version 2.1.0

    2. If still not working
      Start Windows app
      Enable logging - Connection tab, Options Group, Log File checked
      Connect to the controller

    When it fails, close Windows app. Send me the logfile

    NOTE
    If you cannot remember where the log fle is stored -
    Start Windows app
    Use menu Settings, Log file, Reset Error Log File Path
    Restart windows app
    Enable logging - Connection tab, Options Group, Log File checked
    Connect to the controller
    When it fails, close Windows app. Send me the logfile

    regards
    Robert

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-06-26

    Hello Robert
    I have followed your steps and arduino can't send the firmware... I have tried to send the "blink" example code and it has worked, but not myrotator firmware 124
    Arduino IDE says
    avrdude: ser_open(): can't set com-state for "\.\COM4"
    Failed uploading: uploading error: exit status 1

    log file follows
    26/06/2023 17:23:14: ConnectBtn
    26/06/2023 17:23:14: ConnectBtn Connecting to Controller
    26/06/2023 17:23:14: ConnectBtn COM Port: COM3
    26/06/2023 17:23:14: ConnectBtn COM Port Speed: 9600
    26/06/2023 17:23:14: ConnectBtn Set readtimeout to 10000
    26/06/2023 17:23:14: ConnectBtn Open COM Port COM3
    26/06/2023 17:23:14: ConnectBtn IOexception Error:
    System.IO.IOException: Uno de los dispositivos conectados al sistema no funciona.

    en System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
    en System.IO.Ports.InternalResources.WinIOError()
    en System.IO.Ports.SerialStream.InitializeDCB(Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Boolean discardNull)
    en System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
    en System.IO.Ports.SerialPort.Open()
    en myRotator.MyRotator.ConnectBtn_Click(Object sender, EventArgs e)
    26/06/2023 17:23:23: DisconnectBtn
    26/06/2023 17:23:23: DisconnectBtn Rotator is not connected
    26/06/2023 17:23:23: Disableall:
    26/06/2023 17:23:23: Disableall: Disconnected
    26/06/2023 17:23:28: exit:
    26/06/2023 17:23:28: exit: exiting
    26/06/2023 18:48:55: Load Loading application
    26/06/2023 18:48:55: Load Find COM ports
    26/06/2023 18:48:55: Load No COM Ports found
    26/06/2023 18:48:55: Load Set COM Port Speed listbox
    26/06/2023 18:48:55: Load Initialise rotator settings
    26/06/2023 18:48:55: Load Disable controls
    26/06/2023 18:48:55: Disableall:
    26/06/2023 18:48:55: Disableall: Disconnected
    26/06/2023 18:48:55: Load Set focus to Connect tab
    26/06/2023 18:48:55: Load Application Loaded: READY
    26/06/2023 18:49:00: ConnectBtn
    26/06/2023 18:49:00: ConnectBtn Connecting to Controller
    26/06/2023 18:49:00: ConnectBtn COM Port: COM4
    26/06/2023 18:49:00: ConnectBtn COM Port Speed: 9600
    26/06/2023 18:49:00: ConnectBtn Set readtimeout to 10000
    26/06/2023 18:49:00: ConnectBtn Open COM Port COM4
    26/06/2023 18:49:00: ConnectBtn IOexception Error:
    System.IO.IOException: Uno de los dispositivos conectados al sistema no funciona.

    en System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
    en System.IO.Ports.InternalResources.WinIOError()
    en System.IO.Ports.SerialStream.set_DtrEnable(Boolean value)
    en System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
    en System.IO.Ports.SerialPort.Open()
    en myRotator.MyRotator.ConnectBtn_Click(Object sender, EventArgs e)
    26/06/2023 18:49:07: DisconnectBtn
    26/06/2023 18:49:07: DisconnectBtn Rotator is not connected
    26/06/2023 18:49:07: Disableall:
    26/06/2023 18:49:07: Disableall: Disconnected

     
  • brownrb

    brownrb - 2023-06-26

    Arduino IDE 2.1.0
    under Tools Processor it is set to Old Boot Loader?

    You have a serial port issue.

    In one part the log says
    26/06/2023 17:23:14: ConnectBtn COM Port: COM3
    26/06/2023 17:23:14: ConnectBtn COM Port Speed: 9600

    and in another it says
    26/06/2023 18:49:00: ConnectBtn COM Port: COM4
    26/06/2023 18:49:00: ConnectBtn COM Port Speed: 9600
    26/06/2023 18:49:00: ConnectBtn Set readtimeout to 10000
    26/06/2023 18:49:00: ConnectBtn Open COM Port COM4

    and in another it says
    26/06/2023 18:48:55: Load Loading application
    26/06/2023 18:48:55: Load Find COM ports
    26/06/2023 18:48:55: Load No COM Ports found

    So my question is what is connected to com3 and what is connected to com4

    And first
    Arduino IDE says
    avrdude: ser_open(): can't set com-state for ".\COM4"

    That is the Arduino IDE reporting a serial port error.

    Follow these steps exactly
    Connect the controller to the computer using a USB cable
    Start Arduino IDE with firmware 124.
    Compile and upload to the controller.
    Are there any warning or error messages?
    Was the upload successful?

    If the upload worked, then open the Serial Port window for the Arduino IDE (called serial monitor I think from memory - top right corner - if the mouse hovers over the text will say "Serial Monitor"
    In the bottomt window it says Output and Serial Monitor
    Just below there is a text field, In the text field type this
    :00#
    and do not press enter. Click on the Send button
    What was the response?

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-06-26

    hello. I only had the rotator connected first, i tried on com3. after that I tried on com4. the log might have recorded both attempts. Take into account that I successfully uploaded the blink program, so the port , cable etc was correct. I always check that old bootloader was selected.
    I cannot do the test you say as the program is not transferred....

     
  • brownrb

    brownrb - 2023-06-28

    Hi Juan
    Lets take a step backwards for a moment.

    1. the Arduino IDE that is installed on your system should be v2.1.0
    2. If you are using some other version please update.
    3. Connect the controller to the computer using a USB cable
    4. The firmware being uses should be v124. If not please download and extract the files
    5. Change directory into the firmware folder myRotator_124 and double click the file myRotator_124.ino which will then start Arduino IDE and load the firmware load.
    6. Make no changes
    7. Using the IDE, there is a little field underneath Tools-Help which sepcifies the board and com port being used. Attached image. If you click on this field it should display an option "Select Other Board and port" so click on that the next screenshot is displayed (arduino2.png)
    8. I have type in nan to the search field and Arduino has displayed Arduino Nano, and the com port3 to which the program has detected.
    9. I click on Arduino Nano and the board and click on the com port and my window looks like the next screen shot (arduino3.png) then click OK
    10. You should now note that the field in point 7 above, the board/comport field shows a USB sign and the text Arduino Nano (arduino4.png). Now we are ready to proceed.
    11. Test the firmware compilation - this is done by one of three ways - Hold down Cntrl Key and press R, using the menu Sketch - Verify/Compile, or click on the big Tick icon below the menu File. (arduino5.png)
    12. A message field appears at the bottom of the Arduino IDE screen. I need to know if the compile is successful or not. (arduino6.png). This screenshot shows a successful compile. It also shows what port the controller is connected to.
    13. If the button "Copy Error Messages" occurs, click on the button, then open Notepad and paste the error messages into the text file, then post the text file back to me,

    Possible causes of a compile fail are
    a missing library such as eeprom

    Possible causes of no serial port
    - no serial driver loaded
    - if other boards are detected, may point to a faulty arduino chip or a chip missisng a boot loaded, but these are rare.

    Regards
    Robert

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-06-28

    Thanks, Robert. I had done everything as you say... I think I might have found the problem, but still need your help.
    1. After failing again, I have tried to program a brand new arduino nano --> doesn't work
    2. I tried to upload the blink program --> failed (last time I believed I could do it... but not now. After so many attempts who knows :))
    3. I succesfully uploaded and run the program in a different computer with arduino 1.8
    4. Then I updated arduino to 2.1.0 in win8 and uploaded latest firmware-->ok
    5. Then I ran the myrotator program from win8--> ok
    6. But no luck trying to upload firmware from arduino 2.1.0 or execute myrotator under win 11. Now I am sure it is a compatibility problem in win 11
    7. The same (program from arduino 2.1.0 or execute myrotator) in win11 --> fail
    8. Then I ran the win11 program to execute programs in compatibility mode. I chose arduino 2.1.0 and IT WORKED. I succesfully uploaded the code.
    9. NOW I only need to know where the myrotator program is located in the disk, as the compatibility program does not identify it between the programs installed, and I have not been able to obtain the real location of the exe file... I believe running myrotator in compatibility mode will solve the problem.

    Cheers

    P.D: I might have found the program in a strange location
    C:\Users\Tornasol\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\myRotator
    it has extension appref-ms... Running the compatibility routine with it does NOT resolve the program... Is there an exe somewhere?

     

    Last edit: Juan Gonzalez 2023-06-28
  • brownrb

    brownrb - 2023-06-29

    It is not that simple now using Win11, as Microsoft makes changes to locations of one-click apps and thus they are harder to locate now.

    The app is targeted to Win11, 32/64 bit. The app is designed only to run on Win 11. It uses net framework 4.8 client. If that framework is not present, the app setup will ask it to be downloaded during install.

    It is not really compatible with win8, and I am very surprised that it actually runs on Win8, there is no manifest file. Win8 is not something I would recommend or suggest.

    But no luck trying to upload firmware from arduino 2.1.0 or execute myrotator under win 11.

    Why not?
    What were the error messages?

    It is best if it runs on Win11, as there is zero support for win8. I can help you on Win11, but you also need to give the necessary information being asked for,

    A copy of the error messages from Arduino IDE

    I would like a screenshot from the Win11 computer running Arduino 2.1.0,
    Move mouse over menu, Tools, click on tools. A drop down menu appears.
    Hold down CTRL and press PrintScrn key to capture the screen
    Start Paint
    Paste the screen shot into paint, save the file as PNG and then post it.

    Regards
    Robert

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-06-30

    Here is the error that yields when trying to upload the firmware from arduino 2.1.0 on win11 WITHOUT running the compatibility tool to fix it
    Attrached the two screenshots
    As running the compatibility tool Arduino 2.1.0 started to work properly, I though maybe the same thing could be done with myrotator win program...
    It is weird, though, that I didn't need this compatibility stuff to program myfocuser firmware in the same com port... It only complains with myrotator

     
  • brownrb

    brownrb - 2023-07-02

    Hi
    So that error has nothing to do with the firmware. It is a message that the Arduino IDE generates that says there is an error setting COM3. That message occurs not because of the firmware, it occurs because Arduino tried to open a serial port and could not.

    The image screenshot of Arduino Program IDE, menu Tools dropdown would have been more helpful.

    Regards
    Robert

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-07-18

    Hi again, I can't resign to use my rotator in my new windows11 system... I am sure now it has to be with the operating system and that is has nothing to do with the firmware, as I cannot send any program to an arduino nano connected to my win11 system. I have look for other people having the same problem but the only problem that shows up is not having installed the CH340 driver or choosing "old bootloader"...
    I was wondering if it is an option using a different version of arduino nano, as one with FDTI or something like this, so I can just program it and use it...

     
  • brownrb

    brownrb - 2023-07-19

    Hi
    As all the PDF's etc say. there is only support for
    Arduino Nano ATMega328 CH340G chip
    or
    genuine Arduino Uno

    All others are not supported.

    regards
    Robert

     
  • brownrb

    brownrb - 2023-10-14

    One click application notes: Removing a one-click app like myrotator becaise the uninstall does not appear in Control Panel.

    The example in the pdf is for mysqm+
    BUT
    You should be able to follow the guide, using myr... instead of mys......

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-10-15

    Thanks for the update, Robert.
    I had given up and put the rotator in a box, but I decided today to give it another try. I have uninstalled and reinstalled the windows app following your PDF, and It went ok, but still can't connect to the rotator (Error SerialPortInvalidState)
    As this has nothing to do with your code or program, because i get the same complain uploading the "blink" example program, I have been googling and found other people with the same problem
    https://forum.arduino.cc/t/avrdude-ser-open-cant-set-com-state-for-com3-failed-uploading-uploading-error-exit-status-1/1131626/5

    Someone sorted it out keeping the serial monitor open during the upload... and It worked for me too!(no idea why) After that, I saw that uninstalling the CH340 driver and leaving windows to install it again also might be of help... and It did! After doing that I no longer need to leavy the serial monitor open during upload. Arduino 1.8 works perfect, arduino 2.1 complains asn before BUT uploads it... so great news!
    The problem is myrotator app still can't connect to the arduino... Ascom driver can't neither. At thi point leaving the serial mon open was not of help... I wonder if all this can give you a clue about the problem, that only appears in win11.
    I feel I am a bit closer to having my rotator again in place!
    Cheers

     
  • brownrb

    brownrb - 2023-10-15

    Hi Juan

    The problem is myrotator app still can't connect to the arduino... Ascom driver can't neither. At thi point leaving the serial mon open was not of help... I wonder if all this can give you a clue about the problem, that only appears in win11.

    Serial monitor in Arduino must NOT be connected when using ASCOM driver or Windows app.

    Here is something you can try. With Arduino IDE
    Connect controller to USB
    In Arduino IDE, load the firmware file.
    Then
    Open serial port window in Arduino IDE
    Make sure speed is 9600
    Make sure No Line Ending
    In text entry bar, type
    :00#
    then click Send
    00 is the command tp get the current rotator angle.
    so you should see a response of
    $xx#
    where xx is the current rotator angle.

    If you get that, then next retry the Windows app as per below
    If you get nothing back, then there is an issue with com port (wrong one? wrong speed?)

    Windows App
    Close Arduino IDE - it must not be running to do this test

    Please enable the "Enable Logging" check box on the Connection Tab for Windows app v2_0_0_1
    then
    comport - same as the one used with Arduino IDE
    comspeed 9600
    click Connect button.

    This will create a log file.
    myRotatorLog-xxxxxx.txt
    where xxxxx is the date -time

    If connect fails, please send me the logfile

    Check that your firmware is v125_01

    Regards
    Robert

     

    Last edit: brownrb 2023-10-15
  • Juan Gonzalez

    Juan Gonzalez - 2023-10-15

    Hi Robert. Thanks again for your help
    I have tried the serial monitor communication and that seems to work. It answers $0#
    I have done it on arduino IDE 1.8 because 2.1 still says
    "Port monitor error: command 'open' failed: Invalid serial port. Could not connect to COM3 serial port." so I can't even write the serial command to send.
    It seems the code can be uploaded, though, but anyway, 1.8 doesn't complain so I have done everything on 1.8 and get the response from the board.

    Then I have run myrotator app and still can't connect. Speed and COM port are ok, but still the same. I send you attached the log file with a few attempts. I hope it can help.
    Thanks

     
  • brownrb

    brownrb - 2023-10-16

    Hi Juan
    That again points back to square 1. Somehow the OS seems to be blocking access to the Serial port. The fact that both ASCOM and Window apps are blocked points to this.

    I did a bit of searching and found that there are lots of problems running serial ports on the miniPC.

    You might try running the Hardware Troubleshooter
    https://www.youtube.com/watch?v=0fp5dkrmbNo
    It is the second part of the video, around 2m 6s

    If that fixes the problem then ok. But if not.

    START HERE

    Please the following I need
    ONE
    Please confirm these are your settings
    OS=Win11 Yes?
    Firmware=125_1 ?

    TWO
    Connect controller to computer via USB cable
    Start Device Manager
    Select Ports
    Take Screenshot (see my file1 attached)
    Double click on the Port
    Take Screenshot (see my file2 attached)

    Regards
    Robert

     

    Last edit: brownrb 2023-10-16
  • brownrb

    brownrb - 2023-10-16

    Hi Juan
    I have looked at the ASCOM driver and there are some things that can be improved. It might be that the v108 might fail when connecting.

    This is an updated ASCOM Driver.
    Please try this 109 release which has some changes related to making a connection to the Controller.

    If that works I can copy the same code into the Windows app

    regards
    Robert

     

    Last edit: brownrb 2023-10-16
  • Juan Gonzalez

    Juan Gonzalez - 2023-10-16

    Hi Robert
    ONE:
    Yes, Win11 64bits
    Yes 125.1

    TWO
    See attached

    THREE
    done

    FOUR
    error during installation of 2.0.0.2 (see log and screenshot attached)
    I install 2.0.0.1 instead with no problems

    Set options as you ask (see screenshot) This time is COM5
    same Error. Log attached

    Same behaviour in two different PC with windows 11

    I have unistalled previous ascom and installed 109 but the error persists.

    I hope all this will shed some light
    All the best

     
  • brownrb

    brownrb - 2023-10-17

    Hi
    TWO
    I dont see any screenshots, did u forget to attach them?

    Connect controller to computer via USB cable
    Start Device Manager
    Select Ports
    Take Screenshot (see my file1 attached)
    Double click on the Port
    Take Screenshot (see my file2 attached)

    FOUR
    error during installation of 2.0.0.2 (see log and screenshot attached)

    Again, forget to attatch?
    I need to know why 2.0.0.2 failed to install - what error message was displayed

    Another thing, in all cases before it was saying COM3 serial .
    But in this last partial log it says COM5. What heppened to change it to com5

    The fact that even Arduino IDE 2.1x fails to upload via the COM PORT, as well and ascom+windows app for myRotator very heavily suggests that the issue is with your win11 minipc.

    Regards
    Robert

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-10-17

    Hello
    I was attaching things one by one and maybe just kept the last one. Here they are.
    I have made the test in two different PCs, in one of them is COM3 and in the other COM5, tha's why the number might not be the same all the time, but the error was the same in both cases.

    The fact that even Arduino IDE 2.1x fails to upload via the COM PORT, as well and ascom+windows app for myRotator very heavily suggests that the issue is with your win11 minipc.

    Yes, and that's why I have made the test in a different PC with Win11, to make sure it is not something peculiar of a single PC. It seems is common to all win11... at least in my case. I have read there was a problem with CH340 driver, and once uninstalled and reinstalled that works again, because arduino 1.8 doesn't complain, and 2.1 complains, but in both cases the program is uploaded. Before this fix the program didn't upload (I had to do it from a win10 pc)
    So part of the problem has been sorted, but it seems not everything. I wonder why it works in your win11 pc... because you have tried it on win11, right?

     
  • brownrb

    brownrb - 2023-10-17

    Yes, I only use Win11, for a long time now, since it was released to developers.

    In trying to find the issue, we must agree on a common set of things, and only use those.
    When the test is restricted, we can find issues easier.

    I assume, when I am trying to help, because what I try to do is build a susyem here that
    matches the user. That means OS, IDE, Firmware rev number, Windows App rev number etc
    are the same, and not changed.

    In our case that means
    1 PC running Win11
    Arduino Nano
    Arduino IDE (either 1.8.19 or 2.1.1 - and not both). Pick 1 and stay with that one
    Windows app 2.0.0.2
    Firmware 125-1
    ASCOM Driver 109

    The worst thing that can happen is when "what if I try an older version etc). Very quickly there becomes a lot of files and versions and everything gets worse. The idea is to stick with the above list and if it does not work or install etc then those issues get fixed first. To restrict down to a common core reduces all these variations.

    I am concerned re the "minipc", did it come with any cd for OS etc? From what I have seen online is that one needs to run a setup to install the serial ports correctly.

    I apologize for my lack of information, your case seems to be extra difficult to resolve.

    When running the Windows app install 2002, it should have asked to intall framwork 4.8.1 from Microsoft. I need to see if it did.

    ONE
    Please run control panel, click uninstall. This brings up a list of installed apps etc
    I attatch mine. I am interested in the Part where is says Microsoft .Net Framework
    I wish to see what you have installed.

    TWO
    When the firmware file was unzipped, there is a Tests folder. Inside that folder is another called
    ClearEEPROM

    CLEAR NANO EEPROM MEMORY

    Connect the controller via USB cable,
    Navigate to ClearEEPROM.ino and double-click to load into Arduino IDE.
    Specify Nano, ATmega328P and Old Boot loader
    Compile and Upload to the controller.

    // ---------------------------------------------------------------------------------------------------

    This is a bit radical, but probably needs to be done now using Control Panel
    THREE
    Please uninstall the following
    Arduino IDE, all versions
    Windows App
    ASCOM Driver

    FOUR
    Delete these folders/files
    C:\Program Files (x86)\Arduino

    delete to remove any trace of serial driver CH340 - it creates this folder when installed, so delete it (may be in another location)?
    C:\WCH.CN

    FIVE
    Delete (your path and ID might be different)
    C:\Users\rob\AppData\Local\Arduino15

    SIX
    Delete all files in this folder
    C:\Program Files (x86)\Common Files\ASCOM\Rotator

    Make sure Controller is NOT CONNECTED

    Reboot PC

    Install Windows app 2_0_0_2
    If there is an error etc, then stop and let me know

    Install Arduino IDE 1.8.19 only
    Follow all the prompts, including "load serial port driver"

    After installed, run program and
    Check Tools Target as Nano and select comport
    Select Tools Processor ATmega328P - Old Boot Loader

    Connect controller with usb
    Arduino should find it. Click tools Port and select the correct port for the controller

    Reprogram controller with version 125_01

    Can I suggest that you send info to me using my g-m-a-i-l add.ress?
    Do you have Team Viewer loaded on your miniPC?

    Regards Robert

     
  • brownrb

    brownrb - 2023-10-18

    You might also be interested in this thread
    https://sourceforge.net/p/arduinoascomfocuserpro2diy/discussion/general/thread/fbfe7fbfe4/?limit=25#0995

    which has a similar experience.
    So there are some other things to do
    Change USB cable
    Keep USB cable length to minimum
    Use good quality USB cable.
    Check the operation of 12V
    turn 12v on, then connect controller to USB
    or
    connect controller to USB then turn on 12v

    The thread has numerous suggestions.
    Regards
    Robert

     
  • Juan Gonzalez

    Juan Gonzalez - 2023-10-18
     

    Last edit: Juan Gonzalez 2023-10-18

Log in to post a comment.