Author Topic: ModbusTCP  (Read 1552 times)

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
ModbusTCP
« on: August 17, 2016, 12:36:41 AM »
Hey Guys,

I know this is off topic but didn't knew who else to ask to. I have written my own Modbus-TCP Protocol and I'm able to read words. But i don't know how to read floating points and characters. Any help in that direction would be greatly appreciated.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: ModbusTCP
« Reply #1 on: August 17, 2016, 03:32:13 AM »
The common Modbus protocol does not support floating or strings directly. You read the data as words, then convert them. For example, read 2 words, arrange the bytes, then convert to a single type. In .NET you can use BitConverter

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: ModbusTCP
« Reply #2 on: August 17, 2016, 09:19:14 AM »
Hi Archie,

Thanks for the support. I'm already using
Dim dat As Byte() = BitConverter.GetBytes(CShort(IPAddress.HostToNetworkOrder(CShort(word(x)))))
to get word data

what can we use for the floating point numbers.