Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98b6376

Browse files
committed
fix: remove unused buffer slice and simplify data reading in serial port
1 parente63527a commit98b6376

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

‎serialport.go‎

Lines changed: 2 additions & 3 deletions
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
ifp.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
ifn>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)

[8]ページ先頭

©2009-2025 Movatter.jp