Skip to content

Commit

Permalink
patch: getVersionNumber function
Browse files Browse the repository at this point in the history
to construct version number with major, minor, and patch from each individual bytes in Ausbg fields
  • Loading branch information
developStorm committed Apr 24, 2024
1 parent 0bf098e commit a1571dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/siemens/s7.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,13 @@ func parseModuleIDDataRecord(data []byte) (*moduleIDData, error) {

// Constructs the version number from a moduleIDData record.
func getVersionNumber(record *moduleIDData) string {
lastByteAusbg1 := record.Ausbg1 & 0xFF
return fmt.Sprintf("V%d.%d", lastByteAusbg1, record.Ausbg2)
// The major, minor, and patch versions are stored in the lower 8 bits of Ausbg1,
// the upper 8 bits of Ausbg2, and the lower 8 bits of Ausbg2, respectively.
major := record.Ausbg1 & 0xFF
minor := record.Ausbg2 >> 8
patch := record.Ausbg2 & 0xFF

return fmt.Sprintf("%d.%d.%d", major, minor, patch)
}

func parseModuleIdentificationRequest(logStruct *S7Log, s7Packet *S7Packet) error {
Expand Down

0 comments on commit a1571dc

Please sign in to comment.