How to use the pyads.commands.adsresponse.AdsResponse 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 / commands / deviceinforesponse.py View on Github external
import struct
from .adsresponse import AdsResponse

class DeviceInfoResponse(AdsResponse):
    
    def __init__(self, responseAmsPacket):
        AdsResponse.__init__(self, responseAmsPacket)
        
        self.MajorVersion = struct.unpack_from('B', responseAmsPacket.Data, 4)[0]
        self.MinorVersion = struct.unpack_from('B', responseAmsPacket.Data, 5)[0]
        self.Build = struct.unpack_from('H', responseAmsPacket.Data, 6)[0]
        
        deviceNameEnd = 16
        for i in range(8, 24):
            if ord(responseAmsPacket.Data[i]) == 0:
                deviceNameEnd = i
                break
                
        deviceNameRaw = responseAmsPacket.Data[8:deviceNameEnd]
        self.DeviceName = deviceNameRaw.decode("latin-1").strip(' \t\n\r')
github counsyl / counsyl-pyads / pyads / commands / readwriteresponse.py View on Github external
import struct
from .. import AmsPacket
from .adsresponse import AdsResponse

class ReadWriteResponse(AdsResponse):
    
    def __init__(self, responseAmsPacket):
        AdsResponse.__init__(self, responseAmsPacket)

        self.Length = struct.unpack_from('I', responseAmsPacket.Data, 4)[0]
        self.Data = responseAmsPacket.Data[8:]
        
        
    Length = 0
    
    Data = '0'
    
    
    def __str__(self):
        result = "AdsReadWriteResponse:\n"
        result += AmsPacket.GetHexStringBlock(self.Data)
github counsyl / counsyl-pyads / pyads / commands / readstateresponse.py View on Github external
import struct
from .adsresponse import AdsResponse

class ReadStateResponse(AdsResponse):
    
    def __init__(self, responseAmsPacket):
        AdsResponse.__init__(self, responseAmsPacket)
        
        self.AdsState = struct.unpack_from('H', responseAmsPacket.Data, 4)[0]
        self.DeviceState = struct.unpack_from('H', responseAmsPacket.Data, 6)[0]
        
        
    AdsState = 0
    
    DeviceState = 0
    

    def __str__(self):
        return "Ads/Device State: %s/%s" % (self.AdsState, self.DeviceState)
github counsyl / counsyl-pyads / pyads / commands / readresponse.py View on Github external
import ctypes
import struct
import pyads
from .adsresponse import AdsResponse

class ReadResponse(AdsResponse):
    
    def __init__(self, responseAmsPacket):
        AdsResponse.__init__(self, responseAmsPacket)
        
        self.Length = struct.unpack_from('I', responseAmsPacket.Data, 4)[0]
        self.Data = responseAmsPacket.Data[8:]
        
        
    Length = 0
    
    Data = '0'
    
    
    def __str__(self):
        result = "AdsReadResponse:\n"
        result += pyads.HexBlock(self.Data)
github counsyl / counsyl-pyads / pyads / commands / writeresponse.py View on Github external
import struct
from .. import AmsPacket
from .adsresponse import AdsResponse

class WriteResponse(AdsResponse):
    
    def __init__(self, responseAmsPacket):
        AdsResponse.__init__(self, responseAmsPacket)