You must be logged in to reply.

Page 1 of 3 out of 25 messages.

COM1 Starts Spewing CPU register values

Posted 4yr ago
by mhardy | Junior | 590 exp
Posted 4yr ago
by mhardy | Junior | 590 exp
Anyone know how or why my serial port COM1 all of a sudden becomes some type of debug port and starts spewing out cpu register data like:

EXCEPTION 0x06:
cpsr=0x00010010
pc =0xa0486ff8
lr =0xa0486fec
sp =0x10004a70
r00 =0x10004a28
r01 =0x00000000
r02 =0x00000001
r03 =0x00001000
r04 =0xa09f623c
r05 =0xa0486fec
r06 =0xa0486ff8
r07 =0x00010010
r08 =0xa09ffdc4
r09 =0xa0024f98
r10 =0x00000000
r11 =0x00000000
r12 =0xa09f623c
Reply #1 — Posted 4yr ago
by Gus_ghielectroncs | Employee
Reply #1 — Posted 4yr ago
by Gus_ghielectroncs | Employee
This is a system crash report. What version are you running, on what device, and how can we reproduce this error? Any info would help us in nailing this down.
Reply #2 — Posted 4yr ago
by mhardy | Junior | 590 exp
Reply #2 — Posted 4yr ago
by mhardy | Junior | 590 exp
Ah...thanks Gus!

Tiny Booter 4.3.4.0
Tinyclr 4.3.6.0

Cobra II eco with serial port module hooked to socket 5.

Connect serial cable between module and computer serial port. Run TeraTerm or other on PC. Run the following code:

namespace MFConsoleApplication1 {
public class Program {
private static System.IO.Ports.SerialPort _modemSerialPort = null;
private static byte[] _writeBuf = null;
private static byte[] _readBuf = new byte[256];

public static void Main() {
try {
_modemSerialPort = new System.IO.Ports.SerialPort("COM1", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
_modemSerialPort.ReadTimeout = 5000;
_modemSerialPort.Open();

Microsoft.SPOT.Debug.Print(_modemSerialPort.PortName);
int cnt = -1;

while (true) {
if (_modemSerialPort.IsOpen) {
try {
_writeBuf = System.Text.Encoding.UTF8.GetBytes("Hello " + cnt.ToString() + "\r");
_modemSerialPort.Write(_writeBuf, 0, _writeBuf.Length);
} catch (Exception ey) {
Microsoft.SPOT.Debug.Print(ey.ToString()); //<-- Exception caught here
break;
}
}
cnt++;
}
} catch (Exception ez) {
Microsoft.SPOT.Debug.Print(ez.ToString());
}
}
}
}





Output of Microsoft.SPOT.Debug.Print(ey.ToString());
-----------------------------------------------------------
#### Exception System.Exception - CLR_E_WRONG_TYPE (1) ####
#### Message:
#### System.Text.UTF8Encoding::.ctor [IP: 0004] ####
#### System.Text.Encoding::get_UTF8 [IP: 0003] ####
#### MFConsoleApplication1.Program::Main [IP: 0047] ####
A first chance exception of type 'System.Exception' occurred in mscorlib.dll

Output of Stack Trace when inspecting Exception in Quick Watch
--------------------------------------------------------------
System.Text.UTF8Encoding::.ctor
System.Text.Encoding::get_UTF8
MFConsoleApplication1.Program::Main
Reply #3 — Posted 4yr ago
by mhardy | Junior | 590 exp
Reply #3 — Posted 4yr ago
by mhardy | Junior | 590 exp
andre.m,

Yes, it is part of the original post. The original post asked too many questions at once so I cut it down and set the subject to one element of the post that I am having a problem with.

Code tags?
Reply #4 — Posted 4yr ago
by mhardy | Junior | 590 exp
Reply #4 — Posted 4yr ago
by mhardy | Junior | 590 exp
Ah...Me no see at first the editing buttons, not sure if I did it correctly, but heres the code again.

using System;
using Microsoft.SPOT;

namespace MFConsoleApplication1 {
    public class Program {
        private static System.IO.Ports.SerialPort _modemSerialPort = null;
        private static byte[] _writeBuf = null;
        private static byte[] _readBuf = new byte[256];

        public static void Main() {
            try {
                _modemSerialPort = new System.IO.Ports.SerialPort("COM1", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                _modemSerialPort.ReadTimeout = 5000;
                _modemSerialPort.Open();

                Microsoft.SPOT.Debug.Print(_modemSerialPort.PortName);
                int cnt = -1;

                while (true) {
                    if (_modemSerialPort.IsOpen) {
                        try {
                            _writeBuf = System.Text.Encoding.UTF8.GetBytes("Hello " + cnt.ToString() + "\r");
                            _modemSerialPort.Write(_writeBuf, 0, _writeBuf.Length);
                        } catch (Exception ey) {
                            Microsoft.SPOT.Debug.Print(ey.ToString()); //<-- Exception caught here
                            break;
                        }
                    }
                    cnt++;
                }
            } catch (Exception ez) {
                Microsoft.SPOT.Debug.Print(ez.ToString());
            }
        }
    }
}
Reply #5 — Posted 4yr ago
by Architect | Immortal | 176,996 exp
Reply #5 — Posted 4yr ago
by Architect | Immortal | 176,996 exp
@mhardy - Do you see anything suspicious in the output window prior to the exception information. During the deployment/loading stage?

I have tried the piece of code that throws the exception and it worked for me without any problem..
Reply #6 — Posted 4yr ago
by mhardy | Junior | 590 exp
Reply #6 — Posted 4yr ago
by mhardy | Junior | 590 exp
Architect -

Once I saw the GC stuff shown below...it might be related, but I only saw it once out of maybe 30 runs. Usually the last I see in the output is COM1, which my debug.print statement outputs. Essentially the device just locks up.. in lala land.

Right know the device is hung up but no crash info is being spewed over the serial port.
The crash info spewing is random to. Sometimes it happens, sometimes it does not.

Also, even though i have breakpoints set in the exception handlers, only once in awhile do they get hit.

The thing that is constant is that the device locks up.

GC: 1msec 286560 bytes used, 7053108 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 7053108 bytes

Type 17 (ASSEMBLY ): 21528 bytes

Type 1E (BINARY_BLOB_HEAD ): 264936 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction...


For reference here's the exception information:
Output of Microsoft.SPOT.Debug.Print(ey.ToString());
-----------------------------------------------------------
#### Exception System.Exception - CLR_E_WRONG_TYPE (1) ####
#### Message:
#### System.Text.UTF8Encoding::.ctor [IP: 0004] ####
#### System.Text.Encoding::get_UTF8 [IP: 0003] ####
#### MFConsoleApplication1.Program::Main [IP: 0047] ####
A first chance exception of type 'System.Exception' occurred in mscorlib.dll

Output of Stack Trace when inspecting Exception in Quick Watch
--------------------------------------------------------------
System.Text.UTF8Encoding::.ctor
System.Text.Encoding::get_UTF8
MFConsoleApplication1.Program::Main
Reply #7 — Posted 4yr ago
by Architect | Immortal | 176,996 exp
Reply #7 — Posted 4yr ago
by Architect | Immortal | 176,996 exp
@mhardy - I would also add a sleep to your while loop. Similar to how it is done in the documentation.

https://www.ghielectronics.com/docs/15/uart-serial
Reply #8 — Posted 4yr ago
by mhardy | Junior | 590 exp
Reply #8 — Posted 4yr ago
by mhardy | Junior | 590 exp
Architect,

I added it in and will let it run....have meeting right now.
Still very unnerving that such work around's are needed.

It should work with no thread.sleep(100),
would you not agree?
Reply #9 — Posted 4yr ago
by mhardy | Junior | 590 exp
Reply #9 — Posted 4yr ago
by mhardy | Junior | 590 exp
Architect,

I put the System.Threading.Thread.Sleep(100) in the code and still get the same error, exception, crash report, etc. Code is below:

using System;
using Microsoft.SPOT;

namespace MFConsoleApplication1 {
    public class Program {
        private static System.IO.Ports.SerialPort _modemSerialPort = null;
        private static byte[] _writeBuf = null;
        private static byte[] _readBuf = new byte[256];
        

        public static void Main() {
            string str = "";
            try {
                _modemSerialPort = new System.IO.Ports.SerialPort("COM1", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                _modemSerialPort.ReadTimeout = 5000;
                _modemSerialPort.Open();

                Microsoft.SPOT.Debug.Print(_modemSerialPort.PortName);
                int cnt = -1;

                while (true) {
                    if (_modemSerialPort.IsOpen) {
                        try {
                            try {
                                str = "Hello " + cnt.ToString() + "\r";
                                if (null == str) {
                                    str = "Hello              ";
                                        cnt = 0;
                                }
                                _writeBuf = System.Text.Encoding.UTF8.GetBytes(str);
                            } catch (Exception ez) {
                                Microsoft.SPOT.Debug.Print(ez.ToString());
                                break;
                            }
                            _modemSerialPort.Write(_writeBuf, 0, _writeBuf.Length);
                        } catch (Exception ey) {
                            Microsoft.SPOT.Debug.Print(ey.ToString());
                            break;
                        }
                    }
                    System.Threading.Thread.Sleep(100);
                    cnt++;
                }
            } catch (Exception ez) {
                Microsoft.SPOT.Debug.Print(ez.ToString());
            }
        }
    }
}

Page 1 of 3 out of 25 messages.

You must be logged in to reply.