← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Enable Eeschema ERC to Generate Errors for Unmatched Global Labels

 

On 08/27/2015 02:43 PM, Nick Østergaard wrote:
You have some indentation issues, please review the coding style
policy at, http://ci.kicad-pcb.org/job/kicad-doxygen/ws/Documentation/doxygen/html/md_Documentation_development_coding-style-policy.html
Sure, will correct the indentation issues.
The wxString line should probably also have a space in betweent he two
end parenthesis, but I am not sure.
And will add the space as you suggested.

--Joe
I have not reviewed the patch further than that, FWIW.

2015-08-27 7:37 GMT+02:00 Joseph Chen <joseph.chen59@xxxxxxxxx>:
I am submitting a patch file (attached as well)  that enables the eeschema
ERC to generate errors for any and all unmatched global labels.

This patch resolves the issue that I reported in [Bug 1487945].

I have tested the patch on Ubuntu 15.04 and it passed all my test cases

The patch is based off  KiCAD BZR 6129.

Please feel free to correct or enhance this patch any way you see fit.

--Joe

------------------------------------------- Patch Contents
--------------------------------------

diff --git a/eeschema/class_drc_erc_item.cpp
b/eeschema/class_drc_erc_item.cpp
index 8e35bfe..aefac14 100644
--- a/eeschema/class_drc_erc_item.cpp
+++ b/eeschema/class_drc_erc_item.cpp
@@ -52,6 +52,8 @@ wxString DRC_ITEM::GetErrorText() const
          return wxString( _("Mismatch between hierarchical labels and pins
sheets"));
      case ERCE_NOCONNECT_CONNECTED:
          return wxString( _("A no connect symbol is connected to more than 1
pin"));
+    case ERCE_GLOBLABEL:
+        return wxString( _("A global label not connected to any other
global label"));

      default:
          return wxString( wxT("Unkown.") );
diff --git a/eeschema/class_netlist_object.cpp
b/eeschema/class_netlist_object.cpp
index 169a28f..8c77cd1 100644
--- a/eeschema/class_netlist_object.cpp
+++ b/eeschema/class_netlist_object.cpp
@@ -228,6 +228,14 @@ bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT*
aNetItem )
              return true; //connected!
          }
      }
+    else if( ( at == NET_GLOBLABEL ) && ( bt == NET_GLOBLABEL ) )
+    {
+        const char *al = (const char *)(m_Label).mb_str();
+        const char *bl = (const char *)(aNetItem->m_Label).mb_str();
+
+       if( strcmp(al, bl) == 0 )
+       return true;
+    }

      return false; //these two are unconnected
  }
diff --git a/eeschema/dialogs/dialog_erc.cpp
b/eeschema/dialogs/dialog_erc.cpp
index 4dca4d5..c14aa70 100644
--- a/eeschema/dialogs/dialog_erc.cpp
+++ b/eeschema/dialogs/dialog_erc.cpp
@@ -499,7 +499,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
          case NET_LABEL:
          case NET_BUSLABELMEMBER:
          case NET_PINLABEL:
-        case NET_GLOBLABEL:
          case NET_GLOBBUSLABELMEMBER:
              break;

@@ -507,6 +506,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
          case NET_HIERBUSLABELMEMBER:
          case NET_SHEETLABEL:
          case NET_SHEETBUSLABELMEMBER:
+        case NET_GLOBLABEL:

              // ERC problems when pin sheets do not match hierarchical
labels.
              // Each pin sheet must match a hierarchical label
diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp
index e477610..e1a932a 100644
--- a/eeschema/erc.cpp
+++ b/eeschema/erc.cpp
@@ -251,18 +251,31 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef,
NETLIST_OBJECT* aNetItemTst,
          {
              msg.Printf( _( "Hierarchical label %s is not connected to a
sheet label." ),
                          GetChars( aNetItemRef->m_Label ) );
+        marker->SetData( ERCE_HIERACHICAL_LABEL,
+                 aNetItemRef->m_Start,
+                 msg,
+                 aNetItemRef->m_Start );
          }
+    else if( (aNetItemRef->m_Type == NET_GLOBLABEL) )
+    {
+            msg.Printf( _( "Global label %s is not connected to any other
global label." ),
+                        GetChars( aNetItemRef->m_Label ) );
+        marker->SetData( ERCE_GLOBLABEL,
+                 aNetItemRef->m_Start,
+                 msg,
+                 aNetItemRef->m_Start );
+    }
+
          else
          {
              msg.Printf( _( "Sheet label %s is not connected to a
hierarchical label." ),
                          GetChars( aNetItemRef->m_Label ) );
+        marker->SetData( ERCE_HIERACHICAL_LABEL,
+                 aNetItemRef->m_Start,
+                 msg,
+                 aNetItemRef->m_Start );
          }

-
-        marker->SetData( ERCE_HIERACHICAL_LABEL,
-                         aNetItemRef->m_Start,
-                         msg,
-                         aNetItemRef->m_Start );
          return;
      }

diff --git a/eeschema/erc.h b/eeschema/erc.h
index 1e01515..908c498 100644
--- a/eeschema/erc.h
+++ b/eeschema/erc.h
@@ -57,6 +57,7 @@ extern const wxString CommentERC_V[];
  #define ERCE_PIN_TO_PIN_ERROR     5    // pin connected to an other pin:
error level
  #define ERCE_HIERACHICAL_LABEL    6    // mismatch between hierarchical
labels and pins sheets
  #define ERCE_NOCONNECT_CONNECTED  7    // a no connect symbol is connected
to more than 1 pin
+#define ERCE_GLOBLABEL            8    // a global label not connected to
any other global label

  /* Minimal connection table */
  #define NPI    4  // Net with Pin isolated, this pin has type Not Connected
and must be left N.C.


_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp




References