Module: ModBus::Debug

Included in:
Client, Client::Slave, RTUServer, RTUViaTCPServer, TCPServer
Defined in:
lib/rmodbus/debug.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/rmodbus/debug.rb', line 7

def logger
  @logger
end

#raise_exception_on_mismatchObject

Returns the value of attribute raise_exception_on_mismatch.



7
8
9
# File 'lib/rmodbus/debug.rb', line 7

def raise_exception_on_mismatch
  @raise_exception_on_mismatch
end

#read_retriesObject

Returns the value of attribute read_retries.



7
8
9
# File 'lib/rmodbus/debug.rb', line 7

def read_retries
  @read_retries
end

#read_retry_timeoutObject

Returns the value of attribute read_retry_timeout.



7
8
9
# File 'lib/rmodbus/debug.rb', line 7

def read_retry_timeout
  @read_retry_timeout
end

Instance Method Details

#log(msg) ⇒ Object (private)

Put log message on standard output

Parameters:

  • msg (String)

    message for log



16
17
18
# File 'lib/rmodbus/debug.rb', line 16

def log(msg)
  logger&.debug(msg)
end

#logging_bytes(msg) ⇒ String (private)

Convert string of byte to string for log

Examples:

logging_bytes("\x1\xa\x8") => "[01][0a][08]"

Parameters:

  • msg (String)

    input string

Returns:

  • (String)

    readable string of bytes



25
26
27
# File 'lib/rmodbus/debug.rb', line 25

def logging_bytes(msg)
  msg.unpack1("H*").gsub(/\X{2}/, "[\\0]")
end