Skip to content

Commit 98b6376

Browse files
committed
fix: remove unused buffer slice and simplify data reading in serial port
1 parent e63527a commit 98b6376

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

serialport.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func (p *serport) reader() {
7777
serialBuffer := make([]byte, 1024)
7878
for {
7979
n, err := p.portIo.Read(serialBuffer)
80-
bufferPart := serialBuffer[:n]
8180

8281
//if we detect that port is closing, break out of this for{} loop.
8382
if p.isClosing {
@@ -90,8 +89,8 @@ func (p *serport) reader() {
9089
// read can return legitimate bytes as well as an error
9190
// so process the n bytes red, if n > 0
9291
if n > 0 && err == nil {
93-
log.Print("Read " + strconv.Itoa(n) + " bytes ch: " + string(bufferPart[:n]))
94-
p.bufferFlow.OnIncomingData(string(bufferPart[:n]))
92+
log.Print("Read " + strconv.Itoa(n) + " bytes ch: " + string(serialBuffer[:n]))
93+
p.bufferFlow.OnIncomingData(string(serialBuffer[:n]))
9594
}
9695

9796
// double check that we got characters in the buffer

0 commit comments

Comments
 (0)