Skip to content

Commit

Permalink
Fix bug in download
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Petersen committed Nov 10, 2021
1 parent c6f4f07 commit c616178
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sdo/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ func (download Download) initFrame() (frame canopen.Frame, err error) {
fdata[0] = setBit(fdata[0], 1)
// s = 1
fdata[0] = setBit(fdata[0], 0)

// n = number of unused bytes in frame.Data
fdata[0] |= (4 - uint8(n)) << 2
emptyBytes := 4 - n
if emptyBytes == 2 || emptyBytes == 3 {
fdata[0] = setBit(fdata[0], 3)
}
if emptyBytes == 1 || emptyBytes == 3 {
fdata[0] = setBit(fdata[0], 2)
}

// copy all download data into frame data
copy(fdata[3:], download.Data)
} else {
Expand Down

0 comments on commit c616178

Please sign in to comment.