Pages: [1]   Go Down
Author Topic: Help in debugging POR issue with serial monitor  (Read 1037 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12455
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's great, but we have almost no information to go on - posting your sketch would be a start!
Logged

[ I won't respond to messages, use the forum please ]

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Full Member
***
Karma: 0
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bump... I'm stuck please help  smiley-confuse
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bump... I'm stuck please help  smiley-confuse

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

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Full Member
***
Karma: 0
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bump... I'm stuck please help  smiley-confuse

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?
« Last Edit: October 20, 2012, 11:08:14 pm by memotick » Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
            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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Found the resistor trick - thanks!
« Last Edit: December 07, 2012, 03:19:03 pm by Coding Badly » Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 830
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.)

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: