gos7 icon indicating copy to clipboard operation
gos7 copied to clipboard

Best practice: Should change 'dbIndex' in 'DBX' format

Open jiekechoo opened this issue 2 years ago • 1 comments

@robinson , Thanks for your project 'gos7', it is very useful in my project. I found some use tips for develpers in MultiItems write:

  • if use DBX format, change dbIndex, for example: DB1.DBX12.5, the startaddress should be dbIndex + dbBit (DBX12.5 = 12<<3 + 5 = 96+5 = 101 = 0x65), in my case:
dbBit, _ := strconv.ParseInt(string(string(dbArray[2])), 10, 16)
dbIndex = dbIndex<<3 + dbBit
  • and, I want to use 20 items in one AGReadMulti, PDU error, so I use 16-18, it works.
  • and I have a question: what is the mean S7DataItem.Amout, could you tell me some details?

jiekechoo avatar Apr 11 '23 02:04 jiekechoo

@jiekechoo thanks for you tip as well. Regarding S7DataItem.Amount, it is the amount of address that you want to read from or write to. For example, from AGWriteMulti depend on the Amount it should be converted to to calculate the data_size, whether that is a bit, a timer... Hope that helps. //R

robinson avatar Apr 21 '23 13:04 robinson