How to use the pyads.adsdatatype.AdsDatatype function in pyads

To help you get started, we’ve selected a few pyads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github counsyl / counsyl-pyads / pyads / adsdevice.py View on Github external
def ReadByHandle(self, symbolHandle, adsDatatype):
        length = AdsDatatype.GetSize(adsDatatype)
        data = self.Read(0xF005, symbolHandle, length).Data
        return AdsDatatype.Unpack(data, adsDatatype)
github counsyl / counsyl-pyads / pyads / adsdatatype.py View on Github external
def Unpack(value, adsDatatype):
        
        packFmt = AdsDatatype.GetPackFormat(adsDatatype)
        
        if(packFmt != None):
            return struct.unpack(packFmt, value)[0]
        else:
            return value
github counsyl / counsyl-pyads / pyads / adsdevice.py View on Github external
def WriteByHandle(self, symbolHandle, adsDatatype, value):
        valueRaw = AdsDatatype.Pack(value, adsDatatype)
        self.Write(0xF005, symbolHandle, valueRaw)
github counsyl / counsyl-pyads / pyads / adsdevice.py View on Github external
def ReadByHandle(self, symbolHandle, adsDatatype):
        length = AdsDatatype.GetSize(adsDatatype)
        data = self.Read(0xF005, symbolHandle, length).Data
        return AdsDatatype.Unpack(data, adsDatatype)
github counsyl / counsyl-pyads / pyads / symbolinfo.py View on Github external
def ReadFrom(self, byteBuffer):
        
        if (self.AdsDatatype == AdsDatatype.Bool):
            result = AdsDatatype.UnpackFrom(AdsDatatype.UInt8, byteBuffer, self.IndexOffset)
            result = ((result & (1 << self.BitOffset)) == True)
        else:
            result = AdsDatatype.UnpackFrom(self.AdsDatatype, byteBuffer, self.IndexOffset)
        
        self.Value = result
        return result
github counsyl / counsyl-pyads / pyads / symbolinfo.py View on Github external
def WriteTo(self, byteBuffer):
        
        # byte shift needed, if bool!
        if (self.AdsDatatype == AdsDatatype.Bool):
            currentByte = AdsDatatype.UnpackFrom(AdsDatatype.UInt8, byteBuffer, self.IndexOffset)
            if (self.Value):
                newByte = currentByte | (1 << self.BitOffset)
            else:
                newByte = currentByte & ~(1 << self.BitOffset) & 0xF
                
            AdsDatatype.PackInto(AdsDatatype.UInt8, byteBuffer, self.IndexOffset, newByte)
        
        else:
            AdsDatatype.PackInto(self.AdsDatatype, byteBuffer, self.IndexOffset, self.Value)