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.



5
6
7
# File 'lib/rmodbus/debug.rb', line 5

def logger
  @logger
end

#raise_exception_on_mismatchObject

Returns the value of attribute raise_exception_on_mismatch.



5
6
7
# File 'lib/rmodbus/debug.rb', line 5

def raise_exception_on_mismatch
  @raise_exception_on_mismatch
end

#read_retriesObject

Returns the value of attribute read_retries.



5
6
7
# File 'lib/rmodbus/debug.rb', line 5

def read_retries
  @read_retries
end

#read_retry_timeoutObject

Returns the value of attribute read_retry_timeout.



5
6
7
# File 'lib/rmodbus/debug.rb', line 5

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



13
14
15
# File 'lib/rmodbus/debug.rb', line 13

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



22
23
24
# File 'lib/rmodbus/debug.rb', line 22

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