Skip to content

Commit

Permalink
Reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Apr 10, 2023
1 parent a059246 commit 477bca7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ascii_over_tcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ func NewASCIITCPTransporter(address string) ASCIITCPTransporter {

// Send sends data to server and ensures response has required length.
func (mb *ASCIITCPTransporter) Send(aduRequest []byte) (aduResponse []byte, err error) {
mb.TCPTransporter.mu.Lock()
defer mb.TCPTransporter.mu.Unlock()
mb.mu.Lock()
defer mb.mu.Unlock()

// Make sure port is connected
if err = mb.TCPTransporter.connect(); err != nil {
if err = mb.connect(); err != nil {
return
}
// Start the timer to close when idle
mb.TCPTransporter.lastActivity = time.Now()
mb.TCPTransporter.startCloseTimer()
mb.lastActivity = time.Now()
mb.startCloseTimer()
// Set write and read timeout
var timeout time.Time
if mb.Timeout > 0 {
Expand All @@ -65,7 +65,7 @@ func (mb *ASCIITCPTransporter) Send(aduRequest []byte) (aduResponse []byte, err
}

// Send the request
mb.TCPTransporter.logf("modbus: send %q\n", aduRequest)
mb.logf("modbus: send %q\n", aduRequest)
if _, err = mb.conn.Write(aduRequest); err != nil {
return
}
Expand All @@ -88,6 +88,6 @@ func (mb *ASCIITCPTransporter) Send(aduRequest []byte) (aduResponse []byte, err
}
}
aduResponse = data[:length]
mb.TCPTransporter.logf("modbus: recv %q\n", aduResponse)
mb.logf("modbus: recv %q\n", aduResponse)
return
}

0 comments on commit 477bca7

Please sign in to comment.