Go Down

Topic: Help in debugging POR issue with serial monitor (Read 1 time) previous topic - next topic

memotick

I am debugging an issue and need some guidance.

The problem is that during POR my sketch behaves differently than for a regular reset.  If I try and use the serial monitor to debug, it constitutes a software reset and the issue goes away.  Is it possible to poll variables without resetting the board?

I have narrowed the problem by using digital.write commands to LEDs, but I need more visibility to narrow it down further.

Thanks,
memotick

MarkT

That's great, but we have almost no information to go on - posting your sketch would be a start!
[ I won't respond to messages, use the forum please ]

PeterH

The reset is triggered by one of the control lines, which the Arduino IDE toggles when it opens the pot. It's possible to open the port without doing that in which case you'll receive subsequent output but won't reset the board. You may be able to find a client that already does that (PuTTY?) but if you don't find one, it's relatively simple to write your own client that just reads from a serial port and spews everything it reads out on stdout.
I only provide help via the forum - please do not contact me for private consultancy.


PeterH


bump... I'm stuck please help  :~


Where have you looked for a suitable serial client that does not reset the Arduino when it connects?
I only provide help via the forum - please do not contact me for private consultancy.

memotick

#5
Oct 21, 2012, 06:04 am Last Edit: Oct 21, 2012, 06:08 am by memotick Reason: 1


bump... I'm stuck please help  :~


Where have you looked for a suitable serial client that does not reset the Arduino when it connects?


I looked at putty and a few others on the web, but haven't found anything that looks promising.  Any hints on how to write my own as you suggested?

PeterH


I looked at putty and a few others on the web, but haven't found anything that looks promising.


Have you actually tried any? PuTTY, for example, definitely enables you to access a serial port.

If you choose to write your own it would need a few lines of code to open the port, read from it and echo what you read to stdout, and the code would be broadly similar in VB, Java, C# etc. In C# it would look something like this:

Code: [Select]

            SerialPort _serialPort = new SerialPort("COM8", 9600, Parity.None, 8);
            _serialPort.Handshake = Handshake.None;

            try
            {
                _serialPort.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine("Open failed: " + e);
                return;
            }

            while (true)
            {
                try
                {
                    string sample = _serialPort.ReadLine();
                    Console.WriteLine(sample);
                }
                catch (TimeoutException) { }
            } // end while


I doubt you actually need to resort to writing your own client, but if you need to then the code would be pretty simple.
I only provide help via the forum - please do not contact me for private consultancy.

bperrybap

The issue you are running into is AutoReset. There are two different ways AutoReset can
be triggered.
One is using the DTR signal the other is using RTS.
If you have a board using DTR (which is most boards, including all the Official Arduino boards use), then
you are pretty much out of luck on disabling it in software as DTR is normally dropped by the operating system
driver when the serial port is opened by the application *before* the application gets control of the serial port.

If the board is using RTS instead, then this is not a problem and the application can open the serial port without
triggering auto-reset. The IDE and Avrdude have special code in them to trigger RTS so that is how
uploading still works when using RTS.
I prefer RTS over DTR as it allows uploading to use auto-reset but serial applications, terminal monitors
etc, can open the serial port for monitoring without triggering an auto reset.

Some Operating systems have options to configure/control the DTR behavior at serial port open/close,
but often it doesn't work correctly or at all.
Unix/linux/bsd has the stty hup options but not all of them fully support disabling DTR control.
Windows used to have an advanced serial port option
that allowed disabling the DTR signal processing on the serial port.

If the OS supports disabling DTR control on the serial open/close then
you can use it to allow opening the serial port without causing an auto-reset.

If not, you will need a hardware solution.

There are other 3rd party "arduino" boards out there like the Seeeduino that provide a switch/jumper to enable/disable
auto-reset. This is very nice as you can move the jumper/switch and disable auto-reset to prevent any software
from resetting the board no matter what the software tries to do or what signal is used (DTR vs RTS).

There are also some hardware kludges that involving adding a cap or resistor (depends on which board you have)
that can disable the auto-reset in hardware.
Google around for  Arduino disable auto reset,
and you will find information on how to do it.



--- bill

memotick

#8
Oct 21, 2012, 10:00 pm Last Edit: Dec 07, 2012, 09:19 pm by Coding Badly Reason: 1

Found the resistor trick - thanks!

pico


There are also some hardware kludges that involving adding a cap or resistor (depends on which board you have) that can disable the auto-reset in hardware.

Google around for  Arduino disable auto reset, and you will find information on how to do it.


Cutting the "reset-en" trace is probably the simplest (and reversible) way of disabling auto-reset. I'm not sure when this was introduced, but the current Uno and Mega both have this (nice) feature.
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

bperrybap



There are also some hardware kludges that involving adding a cap or resistor (depends on which board you have) that can disable the auto-reset in hardware.

Google around for  Arduino disable auto reset, and you will find information on how to do it.


Cutting the "reset-en" trace is probably the simplest (and reversible) way of disabling auto-reset. I'm not sure when this was introduced, but the current Uno and Mega both have this (nice) feature.

But to go back, it requires soldering again.
The chipkit solution is better. It has a 2 holes for a header with a trace between them. Cut the trace and solder
in a 2 pin male header. Now you can use a jumper to enable/disable auto-reset without any soldering.

The Seeeduino AVR based board includes an actual switch which is even better since it requires no
hardware modifications.

--- bill

Go Up