modbus/mb_utils.py
changeset 2437 105c20fdeb19
parent 2432 dbc065a2f7a5
child 2647 990004083eb8
equal deleted inserted replaced
2436:82bfc75bcd9d 2437:105c20fdeb19
    21 #
    21 #
    22 # This code is made available on the understanding that it will not be
    22 # This code is made available on the understanding that it will not be
    23 # used in safety-critical situations without a full and competent review.
    23 # used in safety-critical situations without a full and competent review.
    24 
    24 
    25 from __future__ import absolute_import
    25 from __future__ import absolute_import
       
    26 from __future__ import division
    26 from six.moves import xrange
    27 from six.moves import xrange
    27 
    28 
    28 # dictionary implementing:
    29 # dictionary implementing:
    29 # key   - string with the description we want in the request plugin GUI
    30 # key   - string with the description we want in the request plugin GUI
    30 # tuple - (modbus function number, request type, max count value,
    31 # tuple - (modbus function number, request type, max count value,
   185 {"%(locreqstr)s", %(nodeid)s, %(slaveid)s, %(iotype)s, %(func_nr)s, %(address)s , %(count)s,
   186 {"%(locreqstr)s", %(nodeid)s, %(slaveid)s, %(iotype)s, %(func_nr)s, %(address)s , %(count)s,
   186 DEF_REQ_SEND_RETRIES, 0 /* error_code */, 0 /* prev_code */, {%(timeout_s)d, %(timeout_ns)d} /* timeout */,
   187 DEF_REQ_SEND_RETRIES, 0 /* error_code */, 0 /* prev_code */, {%(timeout_s)d, %(timeout_ns)d} /* timeout */,
   187 {%(buffer)s}, {%(buffer)s}}'''
   188 {%(buffer)s}, {%(buffer)s}}'''
   188 
   189 
   189     timeout = int(GetCTVal(child, 4))
   190     timeout = int(GetCTVal(child, 4))
   190     timeout_s = int(timeout / 1000)
   191     timeout_s = timeout // 1000
   191     timeout_ms = timeout - (timeout_s * 1000)
   192     timeout_ms = timeout - (timeout_s * 1000)
   192     timeout_ns = timeout_ms * 1000000
   193     timeout_ns = timeout_ms * 1000000
   193 
   194 
   194     request_dict = {
   195     request_dict = {
   195         "locreqstr": "_".join(map(str, child.GetCurrentLocation())),
   196         "locreqstr": "_".join(map(str, child.GetCurrentLocation())),