Prevent sending of extra zero bytes during DFU
This commit is contained in:
parent
dbfe8bb8c4
commit
a1e08ed862
12
dfu.go
12
dfu.go
@ -346,8 +346,16 @@ func (dfu *DFU) stepSeven() error {
|
|||||||
// While send is not done
|
// While send is not done
|
||||||
for !dfu.fwSendDone {
|
for !dfu.fwSendDone {
|
||||||
for i := 0; i < DFUPktRecvInterval; i++ {
|
for i := 0; i < DFUPktRecvInterval; i++ {
|
||||||
// Create byte slice with segment size
|
amtLeft := int(dfu.fwSize) - dfu.bytesSent
|
||||||
segment := make([]byte, DFUSegmentSize)
|
var segment []byte
|
||||||
|
// If amount left is less than segment size
|
||||||
|
if amtLeft < DFUSegmentSize {
|
||||||
|
// Create byte slice with amount left
|
||||||
|
segment = make([]byte, amtLeft)
|
||||||
|
} else {
|
||||||
|
// Create byte slice with segment size
|
||||||
|
segment = make([]byte, DFUSegmentSize)
|
||||||
|
}
|
||||||
// Write firmware image into slice
|
// Write firmware image into slice
|
||||||
n, err := dfu.fwImage.Read(segment)
|
n, err := dfu.fwImage.Read(segment)
|
||||||
// If EOF, send is done
|
// If EOF, send is done
|
||||||
|
Reference in New Issue
Block a user