This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Universal Modbus TCP/RTU Slave
#41
(14.03.2023, 06:18)admin Wrote: holdingregisters = registers, you need to use inputregisters instead.
mb.setfloat16precision(2) sets how float16 is converted to integer. By default it's 2 decimals (0.01 precision). Change 2 to 0 to convert to integer without any decimals.

I tried to change "registers" to "inputegisters", but it still doesn't work. I disabled and then re-enabled the resident script, but the address mapped by "inputegister" still doesn't work.

This is the changed code:
Code:
mb.setmapping({
  [7] = {
    coils = {
      [1] = '0/0/1',
      [2] = '0/0/2',
      [3] = '0/0/3',
    },
    registers = {
      [1] = '0/1/1',
      [2] = '0/1/2',
      [3] = '0/1/3',
    } ,
    inputregisters = {
      [1] = '0/1/4',
      [2] = '0/1/5',
    }
  }
})

In addition, I want to implement the knx address' 1/1/1 'to' 1/1/100 'to map the continuous list of registered addresses [0] to [100]. Now I need to write 100 mapping statements to implement it. Is there a fast implementation method?
Reply
#42
Check that the name is exactly inputregisters, you have the name misspelled twice in your post.
Reply
#43
(14.03.2023, 07:39)rw_echo Wrote:
(14.03.2023, 06:18)admin Wrote: holdingregisters = registers, you need to use inputregisters instead.
mb.setfloat16precision(2) sets how float16 is converted to integer. By default it's 2 decimals (0.01 precision). Change 2 to 0 to convert to integer without any decimals.

I tried to change "registers" to "inputegisters", but it still doesn't work. I disabled and then re-enabled the resident script, but the address mapped by "inputegister" still doesn't work.

This is the changed code:
Code:
mb.setmapping({
  [7] = {
    coils = {
      [1] = '0/0/1',
      [2] = '0/0/2',
      [3] = '0/0/3',
    },
    registers = {
      [1] = '0/1/1',
      [2] = '0/1/2',
      [3] = '0/1/3',
    } ,
    inputregisters = {
      [1] = '0/1/4',
      [2] = '0/1/5',
    }
  }
})

In addition, I want to implement the knx address' 1/1/1 'to' 1/1/100 'to map the continuous list of registered addresses [0] to [100]. Now I need to write 100 mapping statements to implement it. Is there a fast implementation method?

ChatGPT will be fast enough 
Code:
inputregisters = {
      [1] = '1/1/0',
      [2] = '1/1/1',
      [3] = '1/1/2',
      [4] = '1/1/3',
      [5] = '1/1/4',
      [6] = '1/1/5',
      [7] = '1/1/6',
      [8] = '1/1/7',
      [9] = '1/1/8',
      [10] = '1/1/9',
      [11] = '1/1/10',
      [12] = '1/1/11',
      [13] = '1/1/12',
      [14] = '1/1/13',
      [15] = '1/1/14',
      [16] = '1/1/15',
      [17] = '1/1/16',
      [18] = '1/1/17',
      [19] = '1/1/18',
      [20] = '1/1/19',
      [21] = '1/1/20',
      [22] = '1/1/21',
      [23] = '1/1/22',
      [24] = '1/1/23',
      [25] = '1/1/24',
      [26] = '1/1/25',
      [27] = '1/1/26',
      [28] = '1/1/27',
      [29] = '1/1/28',
      [30] = '1/1/29',
      [31] = '1/1/30',
      [32] = '1/1/31',
      [33] = '1/1/32',
      [34] = '1/1/33',
      [35] = '1/1/34',
      [36] = '1/1/35',
      [37] = '1/1/36',
      [38] = '1/1/37',
      [39] = '1/1/38',
      [40] = '1/1/39',
      [41] = '1/1/40',
      [42] = '1/1/41',
      [43] = '1/1/42',
      [44] = '1/1/43',
      [45] = '1/1/44',
      [46] = '1/1/45',
      [47] = '1/1/46',
      [48] = '1/1/47',
      [49] = '1/1/48',
      [50] = '1/1/49',
      [51] = '1/1/50',
      [52] = '1/1/51',
      [53] = '1/1/52',
      [54] = '1/1/53',
      [55] = '1/1/54',
      [56] = '1/1/55',
      [57] = '1/1/56',
      [58] = '1/1/57',
      [59] = '1/1/58',
      [60] = '1/1/59',
      [61] = '1/1/60',
      [62] = '1/1/61',
      [63] = '1/1/62',
      [64] = '1/1/63',
      [65] = '1/1/64',
      [66] = '1/1/65',
      [67] = '1/1/66',
      [68] = '1/1/67',
      [69] = '1/1/68',
      [70] = '1/1/69',
      [71] = '1/1/70',
      [72] = '1/1/71',
      [73] = '1/1/72',
      [74] = '1/1/73',
      [75] = '1/1/74',
      [76] = '1/1/75',
      [77] = '1/1/76',
      [78] = '1/1/77',
      [79] = '1/1/78',
      [80] = '1/1/79',
      [81] = '1/1/80',
      [82] = '1/1/81',
      [83] = '1/1/82',
      [84] = '1/1/83',
      [85] = '1/1/84',
      [86] = '1/1/85',
      [87] = '1/1/86',
      [88] = '1/1/87',
      [89] = '1/1/88',
      [90] = '1/1/89',
      [91] = '1/1/90',
      [92] = '1/1/91',
      [93] = '1/1/92',
      [94] = '1/1/93',
      [95] = '1/1/94',
      [96] = '1/1/95',
      [97] = '1/1/96',
      [98] = '1/1/97',
      [99] = '1/1/98',
      [100] = '1/1/99',
      [101] = '1/1/100',
}
    

Attached Files Thumbnail(s)
   
Reply
#44
There was a bug with input registers in the library. Use updated code from the first post and restart the resident script afterwards.
Reply
#45
(14.03.2023, 08:15)admin Wrote: Check that the name is exactly inputregisters, you have the name misspelled twice in your post.

I did make two errors in my post, but I checked that the "inputegisters" in the code were correct.

I saw that there is no relevant description of "inputegisters" in the user library 'mbtcp' script in Daniel's post. Is "user. mbtcp" missing the command statement of "inputegisters"?
Reply


Forum Jump: