Panda II CAN "stuttering" only when on serial debug

Hi,

I am hoping someone can give me some pointers on an issue I am having with a Fez Panda II setup.

I have a Panda II communicating on both CAN buses. The module also has a separate mode that uses the Mass Storage to allow me to swap configs on the SD card.

While I am debugging, I have a resistor between COM1 Rx and 3.3v, but I do not have the MOD pin connected to GND. This allows me to debug over USB. In this mode, the CAN messages all go out with very good repeatability. All is good!

However, if I then connect the MOD pin to GND (as it would be in the final arrangement), I get a “stutter” in all my CAN messages about every 20s. e.g. my 60ms CAN frame suddenly goes 180ms before sending again. I do not actually have a serial connection, so I am not able to see any debug output.

I removed all debug.print commands, and the stuttering seemed to stretch to every 30s, but was still there very regularly.

I did notice that, when on USB debug, the CAN was not affected in the same way, but the following was printed out every 30s in the debug window (I believe it is something to do with garbage collection?)

GC: 3msec 37032 bytes used, 27348 bytes available
Type 0F (STRING ): 792 bytes
Type 11 (CLASS ): 2484 bytes
Type 12 (VALUETYPE ): 156 bytes
Type 13 (SZARRAY ): 3216 bytes
Type 15 (FREEBLOCK ): 27348 bytes
Type 17 (ASSEMBLY ): 15720 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 24 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 216 bytes
Type 1E (BINARY_BLOB_HEAD ): 8124 bytes
Type 1F (THREAD ): 1152 bytes
Type 20 (SUBTHREAD ): 144 bytes
Type 21 (STACK_FRAME ): 1680 bytes
Type 27 (FINALIZER_HEAD ): 240 bytes
Type 31 (IO_PORT ): 288 bytes
Type 33 (I2C_XACTION ): 48 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 2484 bytes

Is it possible that this debug output is trying to go out over the non-existent serial port every 30 seconds and glitching the CAN? If so, does anyone know how I can stop the output or switch debugging off completely?

Thanks for any suggestions on this, or any other thoughts about possible causes of the stuttering :slight_smile:

Cheers!

Nick

Welcome to the forum Nick

GC messages are totally normal. They tell you the GC is working; how often they appear is usually a direct result of how good or bad your code is at not causing objects to be created/dereferenced/destroyed.

To stop the GC messages, use:

Debug.EnableGCMessages(false);

and see if that helps.

Thanks for the welcome, and the swift reply!

Swift and spot on - that stopped the glitching!

Looks like my next job is to read up on what I need to do to stop the need for those GC messages in the first place. When testing I only have one CAN bus connected, so the other bus has error handlers as a result, so my suspicion is that the BusOff may be triggered and this means a reset…

Thanks again - much appreciated!

Nick