Search code examples
c#plcsiemens

How can I read the Data Block structure of S7-300 PLC from the SUBBLK.DBT file of the S7-Project with C#


                                                            ÿÿ Ø   ÷ü÷ü                                                  ªæ0«æ0«æ     ÿ              øî¿ÿ              ÈÝ              †¸ 0u    ÅÈ‹ :u      1u    27 2u    ÅÀ(Û ‚                                                                                                                                                                                                                                                                                                          ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ÿÿ 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ÿÿ n     u0 œu0                  ÿÿ                  ÿÿ                                                                               ÿ                     u: Zu:           d                                                                      u1u1    ÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 u2u2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ÿÿ ®
  
 J
U 
     
         
 F‚ 
0uœ 0uÿÿÿÿ         :uZ :ud 1u1u2u2u                                                                                                                                                                                                                                                                                                                                                        ÿÿ 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ÿÿ 1   
  STRUCT    
   SystemTast : STRUCT  // 
    Tast1 : BOOL ;  
    Tast2 : BOOL ;  
    Tast3 : BOOL ;  
    Tast4 : BOOL ;  
    Tast5 : BOOL ;  
    Tast6 : BOOL ;  
    Tast7 : BOOL ;  
    Tast8 : BOOL ;  
    Help : BOOL ;   
    ACK : BOOL ;    
    Tast : BOOL ;   
    Tast35 : BOOL ; 
    Tast36 : BOOL ; 
    Tast37 : BOOL ; 
    Tast38 : BOOL ; 
    Tast39 : BOOL ; 
    Tast40 : BOOL ; 
    Tast41 : BOOL ; 
    Tast42 : BOOL ; 
    Tast43 : BOOL ; 
    Tast44 : BOOL ; 
    Tast45 : BOOL ; 
    Tast9 : BOOL ;  
    Tast10 : BOOL ; 
    Tast11 : BOOL ; 
    Tast12 : BOOL ; 
    Tast13 : BOOL ; 
    Tast14 : BOOL ; 
    Tast15 : BOOL ; 
    Tast16 : BOOL ; 
    Tast17 : BOOL ; 
    Tast18 : BOOL ; 
    Tast19 : BOOL ; 
    Tast20 : BOOL ; 
    Tast21 : BOOL ; 
    Tast22 : BOOL ; 
    Tast23 : BOOL ; 
    Tast24 : BOOL ; 
    Tast25 : BOOL ; 
    Tast26 : BOOL ; 
    Tast27 : BOOL ; 
    Tast28 : BOOL ; 
    Tast29 : BOOL ; 
    Tast30 : BOOL ; 
    Tast31 : BOOL ; 
    Tast32 : BOOL ; 
    Tast33 : BOOL ; 
    Tast34 : BOOL ; 
   END_STRUCT ; 
   Res4 : INT ; // 
   Res5 : INT ; // 
   BildTyp : INT ;  // 
   BildNr : INT ;   // 
   reserviert1 : INT ;  // 
   EingabefeldNr : INT ;    // 
   reserviert2 : INT ;  // 
   StoerMld1 : WORD ;   // 
   StoerMld2 : WORD ;   // 
   StoerMld3 : WORD ;   // 
   StoerMld4 : WORD ;   // 
   StoerMld5 : WORD ;   // 
   StoerMld6 : WORD ;   // 
   StoerMld7 : WORD ;   // 
   StoerMld8 : WORD ;   // 
   StoerMld9 : WORD ;   // 
   StoerMld10 : WORD ;  // 
   Betr_Mld1 : WORD ;   // 
   Betr_Mld2 : WORD ;   // 
   Betr_Mld3 : WORD ;   // 
   Betr_Mld4 : WORD ;   // 
   Betr_Mld5 : WORD ;   // 
   Betr_Mld6 : WORD ;   // 
   Betr_Mld7 : WORD ;   // 
   Betr_Mld8 : WORD ;   // 
   Betr_Mld9 : WORD ;   //                                   
   Betr_Mld10 : WORD ;  // 
   Funk_Tast1 : WORD ;  // 
   Funk_Tast2 : WORD ;  
   res64 : WORD ;   
   res66 : WORD ;   
   res68 : WORD ;   
   LED_Abb1 : WORD ;    
   LED_Abb2 : WORD ;    
   res74 : WORD ;   
   res76 : WORD ;   
   res78 : WORD ;   
   Datenfach : STRUCT   //Datenfach Rezepturen
    K1 : WORD ; //Kennung 1
    K2 : WORD ; //Kennung 2
    K3 : WORD ; //Kennung 3
    res : WORD ;    //reserviert
    Lang : WORD ;   //Länge
   END_STRUCT ; 
   Simodrive : INT ;    //0=Kanal "a"; 1=Kanal "b"
  END_STRUCT ;                                                                                                                                                                                                                 ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ÿÿ d                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ÿÿ Î    ¿   (0                                                                                                                                                                                                                                                                                                                  ÿÿ    FB3,{åЇ·qÐ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ÿÿ ¨  
VAR_INPUT
  REQ : BOOL ;  //Send activation
  R : BOOL ;    //Perform reset
  LADDR : INT ; //Base address
  DB_NO : INT ; //DB number for send data
  DBB_NO : INT ;    //DBB number for send data
  LEN : INT ;   //Length of send data
END_VAR
VAR_OUTPUT
  DONE : BOOL ; //Request completed without error
  ERROR : BOOL ;    //Request completed with error
  STATUS : WORD ;   //Status message
END_VAR
VAR
  SFCERR : INT ;    //error returned by RD_LGADR & DPRD_DAT & DPWR_DAT
  State : BYTE ;    //Processing state
  StatusWord : WORD ;   //Internal version of STATUS
  FpR : BOOL ;  //Positive edge detect on R
  FpReq : BOOL ;    //Positive edge detect on REQ
  ResetInProgress : BOOL ;  //ResetInProgress
  SiLaddr : WORD ;  //DPRD_DAT / DPWR_DAT LADDR
  InRequest : INT ; //SI input request code
  InError : BOOL ;  //SI input error
  InSequence : INT ;    //SI input sequence
  OutRequest : INT ;    //SI output request code
  OutError : BOOL ; //SI output error
  OutSequence : INT ;   //SI output sequence
  DbbOffset : INT ; //Next DBB
  RemainingLength : INT ;   //Length remaining
  ModuleSize : INT ;    //Size of module 4/8
  CurrentLength : INT ; //Length of current segment
  LastSegmentLength : INT ; //Length of last segment output
  InBuffer : ARRAY  [0 .. 7 ] OF //SI input buffer
  BYTE ;    
  OutBuffer : ARRAY  [0 .. 7 ] OF //SI output buffer
  BYTE ;    
  AdrArea : BYTE ;  
  Rack : WORD ; 
  Slot : WORD ; 
  SubAddr : WORD ;  
  IsDP : BOOL ; 
END_VAR
VAR_TEMP
  PEAddr : ARRAY  [0 .. 9 ] OF //Don't move: referenced as P#L 0.0 WORD 8
  WORD ;    
  PECount : INT ;   
  PACount : INT ;   
  Temp : INT ;  
  Src : DWORD ; //source pointer
  Dst : DWORD ; //destination pointer                                                                                                                                                                                                                                                                                                                                                         ÿÿ |   ÷ü÷ü                                                                     ÿ              08ÿ              8<                                                                                                                                                                                                                                                                                                                                                                                                    ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ÿÿ 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ÿÿ P     ð d à            ð             ç       1.531 7!gvh01 -                                                                                                                                                                                                                                                                                                                                                                                                                                                    ÿÿ t   
 e                                                                                                                                                                                                                                                                                                                                                                                                                           ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ÿÿ 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ÿÿ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ÿÿ I  

enter image description hereHello I am trying to read out the Data Block structure of S7-300 PLC from the SUBBLK.DBT file of the S7-Project. When I open the file I see that the neccesary information is inclueded in the SUBBLK.DBT file, but I cannot understand, which structure belongs to which DB. Between the parts, that can be read easily, there are some parts that exists of null character and other unknown characters. Is there a way to evaluate the file correctly?


Solution

  • Update: A guy at the German PLC forum did something like this some 12 years ago. Here his github: https://github.com/dotnetprojects/DotNetSiemensPLCToolBoxLibrary