From 654dbbb44bad956635348206a2ef8cc4e35585a7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 29 Oct 2018 18:56:26 +0100 Subject: [PATCH] Gerber UUID parameter calculation: refinements and more comments --- pcbnew/pcbplot.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index a4e8bea6a8..63dddf13df 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -278,9 +278,11 @@ static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMo /** A helper function to build a project GUID using format RFC4122 Version 1 or 4 * from the project name, because a kicad project has no specific GUID - * RFC4122 is used only for its synthax, because fields have no meaning for Gerber files + * RFC4122 is used mainly for its syntax, because fields have no meaning for Gerber files * and therefore the GUID generated has no meaning because it do not use any time and time stamp - * specific to the project. + * specific to the project, just a random pattern (random is here a pattern specific to a project). + * + * See en.wikipedia.org/wiki/Universally_unique_identifier */ static wxString makeProjectGUIDfromString( wxString& aText ) { @@ -289,9 +291,10 @@ static wxString makeProjectGUIDfromString( wxString& aText ) // with // x = hexDigit lower/upper case // and - // M = '1' or '4' (UID versiom 1 or 4) (we use 1) + // M = '1' or '4' (UUID version: 1 (basic) or 4 (random)) (we use 4: UUID random) // and - // N = '8' or '9' or 'A|a' or 'B|b' (RFC4122 tag) (we use 9) + // N = '8' or '9' or 'A|a' or 'B|b' : UUID variant 1: 2 MSB bits have meaning) (we use N = 9) + // N = 1000 or 1001 or 1010 or 1011 : 10xx means Variant 1 (Variant2: 110x and 111x are reserved) wxString guid; @@ -323,16 +326,16 @@ static wxString makeProjectGUIDfromString( wxString& aText ) guid << wxString::Format( "%2.2x", cc ); } - // Output the 4 next hex digits (UID version and 3 digits): - guid << "-1"; // first digit: UID version 1 + // Output the 4 next hex digits (UUID version and 3 digits): + guid << "-4"; // first digit: UUID version 4 (M = 4) { int cc = int( bname[chr_idx++] ) << 4 & 0xFF0; cc += int( bname[chr_idx] ) >> 4 & 0x0F; guid << wxString::Format( "%3.3x", cc ); } - // Output the 4 next hex digits (UID tag and 3 digits): - guid << "-9"; // first digit: UID tag 9 + // Output the 4 next hex digits (UUID variant and 3 digits): + guid << "-9"; // first digit: UUID variant 1 (N = 9) { int cc = (int( bname[chr_idx++] ) & 0x0F) << 8; cc += int( bname[chr_idx++] ) & 0xFF;