0

I am trying to interface between a radio and computer via USB. Here is the code that I am using:

def __getSync(self, raise_error=True):
    c = self.__recv(raise_error)
    if c is None:
        return False
    if (c != self.INSYNC):
        self.debug("unexpected 0x%x instead of INSYNC (0x%x)" % (c, self.INSYNC))
        if raise_error:
            raise RuntimeError("unexpected 0x%x instead of INSYNC (0x%x)" % (c, self.INSYNC))
        return False
    c = self.__recv()
    if (c != self.OK):
        self.debug("unexpected 0x%x instead of OK (0x%x)" % (c, self.OK))
        if raise_error:
            raise RuntimeError("unexpected 0x%x instead of OK (0x%x)" % (c, self.OK))
        return False
    self.debug("__getSync OK", 2)
    return True

And when I do I receive the the following message:

Traceback(most recent call last):    
    File "uploader.py", line 152, in __getSync
        self.debug("unexpected 0x%x instead of INSYNC (0x%x)" % (c, self.INSYNC))
TypeError: %x format: an integer is required, not bytes

I have tried int.from_bytes(c, "big") only to have 'bytes' in the error message be replaced with 'str'. Anybody able to give any help?

Thanks in advance.

1 Answer 1

3

xxx.hex() works for me, it parses bytes to hex string

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.