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 5d6c688
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/siemens/s7.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,10 @@ 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)
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 5d6c688

Please sign in to comment.