Пример #1
0
    def getEncoder(self):
        # Assemble packet and write to USB
        packet = pu.getPacket(0x08, self.cid, list())
        self.ser.write(packet)

        # Read four bytes
        resp = su.readBytes(4)

        # Check if the read failed, if yes, return -1
        if pu.isEmpty(resp):
            return -1

        # Get Integer
        return su.BytesToInt(resp[0:4])
Пример #2
0
    def getFault(self):
        # Assemble packet and write to SPI
        packet = pu.getPacket(0x0F, self.cid, list())
        self.ser.write(packet)

        # Read one byte
        resp = su.readBytes(1)

        # Check if the read failed, if yes, return -1
        if pu.isEmpty(resp):
            return -1

        # If read succeeded, return first element, the fault state
        return resp[0]
Пример #3
0
    def getCurrent(self):
        # Assemble packet and write to USB
        packet = pu.getPacket(0x04, self.cid, list())
        self.ser.write(packet)

        # Read two bytes
        resp = su.readBytes(2)

        # Check if the read failed, if yes, return -1
        if pu.isEmpty(resp):
            return -1

        # If read succeeded, return current in mA as short
        return su.BytesToShort(resp)