Sign in to follow this  
Followers 0
mrtweaver

ComMG and Arduino

8 posts in this topic

A coworker and i have been developing an application which communicates with and transfers data back and forth between an ardunio and a PC. For the most part it works fine. However at times it seems to drop the communications link. Not sure why. Here is what i see.

 

Currently the application is uncompiled so we run it from autoit itself. We did this till we get it completely debugged.

So when you run it and everything is working properly in the status window it will show COM1 and COM3 which is what it should show.

But when the link goes down the application crashes and closes. And when you go to reopen the application

It still shows COM1 and COM3 but after COM3 it shows -64 and then comes up with an error message about not being able to open a closed port.

Does any of this make any sense? If so what could be causing this?

In order to usually fix this you either need to reboot the PC or go into device manager disable COM3 then re-enable COM3

Thank you for taking the time to read this and respond.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

i can´t test (or have a look at) your script/arduino-sketch to retrace the described behavior, i have no information about your Operating System/Autoit-Version, your Hardware, 

All Information that i have is that you have to reboot your PC after an error...

What do you expect? 

Edited by AndyG

Share this post


Link to post
Share on other sites

Here is my script as it stands. I have been looking for the commg error codes but have not been having much success. As i have said here is what happens.

If I run this script from autoit console and every thing is working correctly when it comes to opening the com port it first does a console write and list the avail com ports. And it list them as COM1 : COM3

Now if i run this script in the console and the com3 is not working properly then when it writes to the console and list the com port it looks like COM1 ; COM3 -64

And autoit displays the message 'CAN NOT OPEN CLOSED PORT' and it crashes.

The two ways that i have found to fix this is either reboot the PC which of course takes to much time, or i go into device manager and i disable the re-enable COM3.

As I have said i dont know what that -64 means and dont know what the error means that says can not open closed port.

Sorry for the delay just have been busy doing more debugging and such.

camera test 5 ver 4.au3

Share this post


Link to post
Share on other sites

Hi,

31 minutes ago, mrtweaver said:

The two ways that i have found to fix this is either reboot the PC which of course takes to much time, or i go into device manager and i disable the re-enable COM3.

A simple script with  

#include <arduino.au3>

$port=3
$baud=19200

conecta($port, $baud)

does the job...

First i run arduino IDE to initialize driver and com-port( 3 in my case)...

When i connect my arduino (usually at port 3, see Arduino-IDE) and run the script, the port 3 is displayed in the console. Everything ok.

When i disconnect the arduino and run the script, the AutoIt-errormessage appears:

"---------------------------
autoit3
---------------------------
Can't perform this operation on a closed port port =  None channel number = 1
---------------------------

and in the console "-16" is displayed.
After reconnecting the arduino and run the script, everything works as expected...

Be sure to set the right port in the AutoIt-script! If a wrong port is set, you get the errormessage "Com3-16" (in your case Com3-64)!

 

Share this post


Link to post
Share on other sites

What is unique about this error is that everything will be working fine, the application written in autoit has already connected to the arduino it has been running and talking to one another. Life is happy.

Then all of a sudden the autoit application pops up with the usual Unexpected error has occured autoit will now close. So you press OK to close the application.

Then when you attempt to reopen the application that is when you get the -64 error.

So from what you are telling me something has shut down the port or has caused communcations to cease between the two devices (the PC and arduino) Kind of like unplugging the arduino. Is that what i am understanding?

I know from talking with out IT dept they checked the event viewer and services and such of the PC and there was no error, so to me that seems to indicate that if something did drop the connection if was the arduino. But alas have to find out what is causing things and why.

Share this post


Link to post
Share on other sites

Oh and you are right in that the arduino is on com3

Share this post


Link to post
Share on other sites
9 hours ago, mrtweaver said:

Oh and you are right in that the arduino is on com3

from your script:

Global $port = IniRead(@ScriptDir & "\settings.ini", "ARDUINO", "PORT", "1")

something went terribly wrong....

 

You should also check if $port is 3 or "3" (int or string).

Next i would try is Extras/Trace add Tracelines in Autoit...this shows you the line of the error. First of all you have to locate the cause of the error.

 

Share this post


Link to post
Share on other sites

Ok i needed to refresh this since the problem has cropped up again. The error is very random. Sometimes the application we have been writing which is shown above works fine for days or even weeks, and sometimes it is only hours. We have this application on 4 PC's and as stated the error just crops up and shows up for no known reason. When it does show up here are the symptoms:

It will shut down the script that is running. When you try to reopen the script it will come up with the error message 'Can not open closed port'. And if you are running the script from inside the editor, when it run the COMMMG one of the first things that it does is does a write to console of available ports. When it shows COM3 it has shown after it -64 I have been trying to recreate this error on my work bench. If on the work bench i just unplug the arduino the error code is -16, but here as i stated the error code is -64 and i have no idea exactly what this means.

So does anyone here on this site know exactly what the -64 commmg error means?

As was stated earlier we now know of two ways to clear this problem, the first is if you go into Control panel, go under device manager, and in device manager take COM3 disable it and then re-enable it. The second way is to unplug the USB wire between the PC and Arduino and then plug it back in. Either one of these will reset the error and will allow things to work again.

As to the previous posters idea, we did take and hard code the com port into each application just to see if that would work, the com port and speed and such are currently not variables, but the problem still persist and is very random.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0