Skip to content

Commit

Permalink
feature : remoteTSAP connectType (driver)can override by TCPClientWit…
Browse files Browse the repository at this point in the history
…hConnectType()
  • Loading branch information
Hongliukai committed Mar 13, 2024
1 parent fb5a72f commit f16e0ab
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tcpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,27 @@ func NewTCPClientHandler(address string, rack int, slot int) *TCPClientHandler {
h.setConnectionParameters(address, 0x0100, remoteTSAP)
return h
}

// NewTCPClientHandlerWithConnectType allocates a new TCPClientHandler with connection type.
func NewTCPClientHandlerWithConnectType(address string, rack int, slot int, connectType int) *TCPClientHandler {
h := &TCPClientHandler{}
h.Address = address
h.Timeout = tcpTimeout
h.IdleTimeout = tcpIdleTimeout
h.ConnectionType = connectType
remoteTSAP := uint16(h.ConnectionType)<<8 + (uint16(rack) * 0x20) + uint16(slot)
h.setConnectionParameters(address, 0x0100, remoteTSAP)
return h
}
//TCPClient creator for a TCP client with address, rack and slot, implement from interface client
func TCPClient(address string, rack int, slot int) Client {
handler := NewTCPClientHandler(address, rack, slot)
return NewClient(handler)
}
//TCPClientWithConnectType creator for a TCP client with address, rack, slot and connect type, implement from interface client
func TCPClientWithConnectType(address string, rack int, slot int, connectType int) Client {
handler := NewTCPClientHandlerWithConnectType(address, rack, slot, connectType)
return NewClient(handler)
}

// tcpPackager implements Packager interface.
type tcpPackager struct {
Expand Down

0 comments on commit f16e0ab

Please sign in to comment.