dm_modbus_type Module

Modbus types and utility procedures.


Uses

  • module~~dm_modbus_type~~UsesGraph module~dm_modbus_type dm_modbus_type module~dm_error dm_error module~dm_modbus_type->module~dm_error module~dm_kind dm_kind module~dm_modbus_type->module~dm_kind module~dm_response dm_response module~dm_modbus_type->module~dm_response module~dm_string dm_string module~dm_modbus_type->module~dm_string module~dm_error->module~dm_kind module~dm_ascii dm_ascii module~dm_error->module~dm_ascii iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env module~dm_response->module~dm_error module~dm_response->module~dm_kind module~dm_id dm_id module~dm_response->module~dm_id module~dm_util dm_util module~dm_response->module~dm_util module~dm_string->module~dm_error module~dm_string->module~dm_kind module~dm_util->module~dm_error module~dm_util->module~dm_kind

Used by

  • module~~dm_modbus_type~~UsedByGraph module~dm_modbus_type dm_modbus_type module~dm_modbus dm_modbus module~dm_modbus->module~dm_modbus_type module~dmpack dmpack module~dmpack->module~dm_modbus_type module~dmpack->module~dm_modbus proc~dm_lua_api_register dm_lua_api_register proc~dm_lua_api_register->module~dm_modbus_type

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: MODBUS_ACCESS_NONE = 0

No access (invalid).

integer, public, parameter :: MODBUS_ACCESS_READ = 1

Read access.

integer, public, parameter :: MODBUS_ACCESS_WRITE = 2

Write access.

integer, public, parameter :: MODBUS_TYPE_NONE = 0

None (invalid).

integer, public, parameter :: MODBUS_TYPE_INT16 = 1

Signed 2-byte integer.

integer, public, parameter :: MODBUS_TYPE_INT32 = 2

Signed 2-byte integer.

integer, public, parameter :: MODBUS_TYPE_UINT16 = 3

Unsigned 2-byte integer.

integer, public, parameter :: MODBUS_TYPE_UINT32 = 4

Unsigned 4-byte integer.

integer, public, parameter :: MODBUS_TYPE_FLOAT = 5

4-byte float.

integer, public, parameter :: MODBUS_TYPE_LAST = 5

Never use this.

integer, public, parameter :: MODBUS_TYPE_DEFAULT = MODBUS_TYPE_INT16

Default number type.

integer, public, parameter :: MODBUS_ORDER_NONE = 0

None (integer or invalid).

integer, public, parameter :: MODBUS_ORDER_ABCD = 1

ABCD byte order.

integer, public, parameter :: MODBUS_ORDER_BADC = 2

BADC byte order.

integer, public, parameter :: MODBUS_ORDER_CDAB = 3

CDBA byte order.

integer, public, parameter :: MODBUS_ORDER_DCBA = 4

DCBA byte order.

integer, public, parameter :: MODBUS_ACCESS_NAME_LEN = 5

Max. access name length.

integer, public, parameter :: MODBUS_ORDER_NAME_LEN = 4

Max. byte order name length.

integer, public, parameter :: MODBUS_TYPE_NAME_LEN = 6

Max. number type name length.

integer, public, parameter :: MODBUS_REGISTER_NAME_LEN = RESPONSE_NAME_LEN
integer, public, parameter :: MODBUS_REGISTER_UNIT_LEN = RESPONSE_UNIT_LEN
character(len=*), public, parameter :: MODBUS_TYPE_NAMES(MODBUS_TYPE_NONE:MODBUS_TYPE_LAST) = [character(len=MODBUS_TYPE_NAME_LEN)::'none', 'int16', 'int32', 'uint16', 'uint32', 'float']

Modbus number type names.


Derived Types

type, public ::  modbus_register_type

Modbus register value type. Changes to this derived type must be regarded in module dm_lua. Only integer values can be written to a Modbus register. Any value read from a Modbus register must be stored separately from this derived type.

Components

Type Visibility Attributes Name Initial
character(len=MODBUS_REGISTER_NAME_LEN), public :: name = ' '

Register name.

character(len=MODBUS_REGISTER_UNIT_LEN), public :: unit = ' '

Register value unit.

integer, public :: access = MODBUS_ACCESS_NONE

Read or write access.

integer, public :: slave = 0

Slave id.

integer, public :: address = 0

Register address.

integer, public :: type = MODBUS_TYPE_INT16

Number type.

integer, public :: order = MODBUS_ORDER_NONE

Byte order of float.

integer, public :: value = 0

Register value to write.


Functions

public pure function dm_modbus_access_from_name(name) result(access)

Returns access enumerator from string. Returns MODBUS_ACCESS_NONE on error.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Input string.

Return Value integer

public pure elemental function dm_modbus_access_is_valid(access) result(valid)

Returns .true. if access is a valid enumerator. MODBUS_ACCESS_NONE is invalid.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: access

Modbus access enumerator.

Return Value logical

public pure function dm_modbus_order_from_name(name) result(order)

Returns byte order named parameter associated with given string. For example, the result will be MODBUS_ORDER_ACBD if name is ABCD (case-insensitive). Returns MODBUS_ORDER_NONE if the string is invalid.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Input string.

Return Value integer

public pure elemental function dm_modbus_order_is_valid(order) result(valid)

Returns .true. if argument is a valid float byte order enumerator. MODBUS_ORDER_NONE is not a valid byte order.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: order

Modbus byte order enumerator.

Return Value logical

public pure elemental function dm_modbus_register_is_valid(register) result(valid)

Returns .true. if Modbus register type is valid.

Arguments

Type IntentOptional Attributes Name
type(modbus_register_type), intent(in) :: register

Modbus register type.

Return Value logical

public pure elemental function dm_modbus_type_is_valid(type) result(valid)

Returns .true. if the given Modbus number type is valid. MODBUS_TYPE_NONE is invalid.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: type

Modbus number type.

Return Value logical

public pure elemental function dm_modbus_type_from_name(name) result(type)

Returns Modbus number type from given name. If name is invalid, MODBUS_TYPE_NONE is returned.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Modbus type name.

Return Value integer


Subroutines

public pure elemental subroutine dm_modbus_parse(string, register, error)

Parses string for the following Modbus parameters and returns the values in register:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string

Input string.

type(modbus_register_type), intent(out) :: register

Modbus I/O type.

integer, intent(out), optional :: error

Error code.

public subroutine dm_modbus_register_out(register, unit)

Outputs Modbus register type.

Arguments

Type IntentOptional Attributes Name
type(modbus_register_type), intent(inout) :: register

Modbus register type.

integer, intent(in), optional :: unit

File unit.