示例#1
0
    def decode(self, data):
        ''' Decodes response pdu

        :param data: The packet data to decode
        '''
        self.byte_count = struct.unpack(">B", data[0])[0]
        self.bits = unpack_bitstring(data[1:])
示例#2
0
 def decode_bits(self):
     ''' Decodes a byte worth of bits from the buffer
     '''
     self._pointer += 1
     fstring = self._endian + 'B'
     handle = self._payload[self._pointer - 1:self._pointer]
     return unpack_bitstring(handle)
    def decode(self, data):
        ''' Decodes response pdu

        :param data: The packet data to decode
        '''
        self.byte_count = struct.unpack(">B", data[0])[0]
        self.bits = unpack_bitstring(data[1:])
示例#4
0
    def decode(self, data):
        ''' Decodes response pdu

        :param data: The packet data to decode
        '''
        self.byte_count = byte2int(data[0])
        self.bits = unpack_bitstring(data[1:])
示例#5
0
 def decode_bits(self):
     ''' Decodes a byte worth of bits from the buffer
     '''
     self._pointer += 1
     fstring = self._endian + 'B'
     handle = self._payload[self._pointer - 1:self._pointer]
     return unpack_bitstring(handle)
示例#6
0
    def decode(self, data):
        ''' Decodes response pdu

        :param data: The packet data to decode
        '''
        self.byte_count = byte2int(data[0])
        self.bits = unpack_bitstring(data[1:])
示例#7
0
 def decode_bits(self):
     """ Decodes a byte worth of bits from the buffer
     """
     self._pointer += 1
     # fstring = self._endian + 'B'
     handle = self._payload[self._pointer - 1:self._pointer]
     handle = make_byte_string(handle)
     return unpack_bitstring(handle)
示例#8
0
    def decode(self, data):
        ''' Decodes a write coils request

        :param data: The packet data to decode
        '''
        self.address, count, self.byte_count = struct.unpack('>HHB', data[0:5])
        values = unpack_bitstring(data[5:])
        self.values = values[:count]
示例#9
0
文件: payload.py 项目: dices/pymodbus
 def decode_bits(self):
     """ Decodes a byte worth of bits from the buffer
     """
     self._pointer += 1
     # fstring = self._endian + 'B'
     handle = self._payload[self._pointer - 1:self._pointer]
     handle = make_byte_string(handle)
     return unpack_bitstring(handle)
示例#10
0
    def decode(self, data):
        ''' Decodes a write coils request

        :param data: The packet data to decode
        '''
        self.address, count, self.byte_count = struct.unpack('>HHB', data[0:5])
        values = unpack_bitstring(data[5:])
        self.values = values[:count]
示例#11
0
文件: events.py 项目: 4rc4n4/pymodbus
    def decode(self, event):
        ''' Decodes the event message to its status bits

        :param event: The event to decode
        '''
        bits = unpack_bitstring(event)
        self.overrun   = bits[4]
        self.listen    = bits[5]
        self.broadcast = bits[6]
示例#12
0
    def decode(self, event):
        ''' Decodes the event message to its status bits

        :param event: The event to decode
        '''
        bits = unpack_bitstring(event)
        self.overrun = bits[4]
        self.listen = bits[5]
        self.broadcast = bits[6]
示例#13
0
    def __get_bit(self, key, offset, count):
        '''

        :param key: The key prefix to use
        :param offset: The address offset to start at
        :param count: The number of bits to read
        '''
        response = self.__get_bit_values(key, offset, count)
        response = (r or self.__bit_default for r in response)
        result = ''.join(response)
        result = unpack_bitstring(result)
        return result[offset:offset + count]
示例#14
0
    def decode(self, event):
        ''' Decodes the event message to its status bits

        :param event: The event to decode
        '''
        # todo fix the start byte count
        bits = unpack_bitstring(event)
        self.read = bits[0]
        self.slave_abort = bits[1]
        self.slave_busy = bits[2]
        self.slave_nak = bits[3]
        self.write_timeout = bits[4]
        self.listen = bits[5]
示例#15
0
文件: events.py 项目: 4rc4n4/pymodbus
    def decode(self, event):
        ''' Decodes the event message to its status bits

        :param event: The event to decode
        '''
        # todo fix the start byte count
        bits = unpack_bitstring(event)
        self.read          = bits[0]
        self.slave_abort   = bits[1]
        self.slave_busy    = bits[2]
        self.slave_nak     = bits[3]
        self.write_timeout = bits[4]
        self.listen        = bits[5]
示例#16
0
 def decode_bits(self):
     """ Decodes a byte worth of bits from the buffer
     """
     self._pointer += 1
     handle = self._payload[self._pointer - 1:self._pointer]
     return unpack_bitstring(handle)
示例#17
0
 def testBitPacking(self):
     ''' Test all string <=> bit packing functions '''
     self.assertEqual(unpack_bitstring('\x55'), self.bits)
     self.assertEqual(pack_bitstring(self.bits), '\x55')
示例#18
0
 def decode_bits(self):
     """ Decodes a byte worth of bits from the buffer
     """
     self._pointer += 1
     handle = self._payload[self._pointer - 1:self._pointer]
     return unpack_bitstring(handle)
示例#19
0
 def testBitPacking(self):
     ''' Test all string <=> bit packing functions '''
     self.assertEqual(unpack_bitstring('\x55'), self.bits)
     self.assertEqual(pack_bitstring(self.bits), '\x55')