Arduino IDE 1.0.5 r2 (windows) serial monitor problem

Status
Not open for further replies.

StefanPetrick

Well-known member
I´ve recently the problem, that the IDE tells me sometimes "serial port COM x not found" when opening the serial monitor.

I never encountered a problem when upoading a program to the Teensy on the same port.

Sometimes the monitor works, sometimes not. It appears to be complete random.

Is this problem and any solution known?

Thanks,

Stefan
 
If your program crashes in a certain way, you can get this symptom. Running a known good example like blinky repeatedly can help diagnose.
 
With the IDE running under my linux distribution I have no problems with the same code.

Windows + an external serial monitor works constantly fine as well.

It is only the Windows Arduino IDE that appears to have problems from time to time.

Sometimes it helps to just reopen the serial monitor a couple of times while the sketch on the Teensy is still running and then it magically works...
 
Last edited:
Do you sent lots of things, quickly, to the monitor?

I don't think there is a hardware handshake. Maybe the receiver is getting out of sync with what's being sent?
 
Not really, it was arround 6 kB/s. The problem appears before the monitor opens. When it opens it never crashes. Most probably it is just the damn Arduino IDE, there are some other issues with it, too.

Probably it´s a just another sign to finally go for a serious development platform.
 
Funny the Arduino should have been around for so long, grown through so many new people coming onboard, releasing new products, if it isn't a "serious platform."
 
It is intended to allow beginners getting started quickly. For that it is fine.

But there are still many bugs alone in the editor, filemanagement, menus, ... The same ones in the win as in the linux version.

They are known since years but not fixed yet. No idea, why. Even commited bugFIXES take usually more than a year to be maybe implemented.

So in my eyes it is anything except a serious development environment.
 
Leaving apart the considerations about Arduino IDE, it looks to me an old and well documented bug of windows and nothing to do with Arduino!
Windows has never fixed this bug, it's years now, but rumors says that the incoming new windows will finally fix this.
Btw did you try the same thing with an Arduino UNO? It does the same thing? I spent hours to get serial working properly with Teensy 3.x and Leonardo on windows, without a
Code:
while (!Serial) {;}
in setup I was not able to see anything printed in Setup and inside libraries. Time ago I had serial stuck or disconnectings but I solved by completely reinstalling Java
 
No, I´ve no Uno by hand right now to try it.
The problem is not, that I don´t see anything in the serial monitor.
The problem is, that the monitor does not open and the IDE tells me in orange letters the the COM port not exists instead. Sometimes.
 
You could write a fault tolerant serial console in Windows. It would just need to be written to expect an exception when the link fails. Doing one in Python would be simple. That is, of course, if the failure could be detected when the link actually dies. Is that the issue here? Not the programmers who wrote the serial consoles, but the OS does not provide sufficient fault tolerance?
 
With other serial terminals it works always, so I can only guess. I suspect the underlaying Java or some OS issue.
I will not invest time to dig deeper into it, I´ll just use something else that works and focus on led effects instead.

Thanks for all suggestions!
 
Here is a Python 2.7 program that should do the trick:
Code:
import time

from multiprocessing import Process, Queue

def serialProcess(oQueue):
    import serial
    #import time

    oQueue.put("Starting serial process")

    running = False

    # connect
    while not running:
        try:
            import serial
            ser = serial.Serial('COM46', 9600, timeout=1)
            ser.setTimeout(1)
            running = True
        except Exception as x:
            oQueue.put(x)
            sleep(1)

    # read data
    reading = True

    timecount = 0
    while reading:

        if not ser.isOpen() or timecount > 5:
            reading = False
            ser.close()
            ser = None
            time.sleep(1)

            continue
            #break

        try:
            data = ser.readline()
            if len(data):
                timecount = 0
                oQueue.put(data[:-1])
            else:
                timecount += 1

        except Exception as x:
            oQueue.put(x)
            reading = False


def main():
    q = Queue()

    running = True

    while running:
        p = Process(target=serialProcess, args=(q,))
        p.daemon = True
        p.start()
        while p.is_alive():
            if not q.empty():
                print q.get()    

        print "connection died, trying again"
        time.sleep(1)


if __name__ == '__main__':
    main()

It is just console based. You run it by saving to a file and running "python <filename.py>".

It could do with some eliminating some prints in there, but it does tell you what is happening. I had to do a separate process because once the "import serial" happens and it opens a port it will not release the underlying "stuff" to allow the port to be connected to again. So I made it a separate process using the awesome "multiprocessing" module of Python. It lets you use thread type semantics to communicate to the process. Anyway, it does recover. The delays might cause some data to be lost, but there is not much I can do there. You can fiddle with the timeout and make the delays less if you want. So customize to meet your needs.
 
Also.. Bray's Terminal program. It has a tick-box check option for auto-reconnect.
This option does the following:
When the terminal window becomes inactive (loses focus due to mousing in a different window), Bray's Terminal closes the serial port.
When Bray's Terminal window becomes active (mouse clicks in its window) it reconnects the serial port.
There can be multiple Bray's Terminal windows concurrently.
Sometimes this isn't what you want, because data going into Bray's terminal when it does not have window focus, is lost. You can toggle the auto-reconnect on/off on the fly and deal with this.

Before I began using Atmel Studio with Visual Micro for Teensy 2, 3 (which does a better job of managing serial monitor(s), I often used the above.
 
I liked PuTTY, from...

http://www.chiark.greenend.org.uk/~sgtatham/putty/

... for a simple terminal program. You download an .exe, and just run it. No setup involved. (I.e. you don't have to "install" the software. Of course, with any serial comms, you have to specify baud rate, etc.)

Haven't used for a while... but it is still there. You can take that as good news or bad, as suits your nature!
 
Status
Not open for further replies.
Back
Top