Author Topic: AB Logix Driver Exception with 16bit Integer  (Read 1157 times)

StephenSDH

  • Newbie
  • *
  • Posts: 36
    • View Profile
AB Logix Driver Exception with 16bit Integer
« on: June 27, 2015, 10:30:45 PM »
If I reference a bit inside a 16-Bit Integer with a toggle button, I get an exception.  Exception says can't convert String to Boolean.  I worked around by making the integer a DINT.

I'm good with converting the integers a DINT, but I'd be glad to test if you want to address.

Files
https://www.dropbox.com/sh/1plfjjlxb7p07cy/AACe9UUbg47Y5foOJMZmM8ZKa?dl=0

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: AB Logix Driver Exception with 16bit Integer
« Reply #1 on: June 28, 2015, 05:38:16 AM »
- Edit EthernetIPforCLXCom.vb
- Go to line 856
- Change the Case condition block of code to this:



            Case &HD3 '* BOOL Array
                Dim i As Integer
                Dim x, BitValue As UInt64
                Dim CurrentBitPos As Integer = BitIndex
                For j = 0 To ((returnedData.Length - startIndex) / ElementSize) - 1
                    Select Case ElementSize
                        Case 1 '* SINT
                            x = returnedData(Convert.ToInt32(j * ElementSize + startIndex))
                        Case 2 ' * INT
                            x = BitConverter.ToUInt16(returnedData, Convert.ToInt32(j * ElementSize + startIndex))
                        Case 8 ' * LINT
                            x = BitConverter.ToUInt64(returnedData, Convert.ToInt32(j * ElementSize + startIndex))
                        Case Else
                            x = BitConverter.ToUInt32(returnedData, Convert.ToInt32(j * ElementSize + startIndex))
                    End Select

                    While CurrentBitPos < BitsPerElement
                        BitValue = Convert.ToUInt64(2 ^ (CurrentBitPos))
                        result(i) = Convert.ToString((x And BitValue) > 0)
                        i += 1
                        CurrentBitPos += 1
                    End While
                    CurrentBitPos = 0
                Next




To make sure the right amount of code was changed, be sure the next line of code after the above code is:
Case &H82, &H83 '* TODO: Timer, Counter, Control

StephenSDH

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: AB Logix Driver Exception with 16bit Integer
« Reply #2 on: June 28, 2015, 07:54:29 AM »
Tested, and it worked.  Thanks