I am writing a program that sends command codes to a serial device and gets a response from the device, then sends another command. I can send the commands perfectly, and even get a response. However, my if statement does not seem to acknowledge the responses.
Example:
response = sendCommand(beep)
if response == '0D6010100':
print"Command beeped!"
Like I mentioned, I get a successful response code of 0D6010100, but the if statement doesn’t acknowledge it. Any ideas?
I am working with Python 2.7 and using PySerial
UDPATE:
print type(response) gives me:
print repr(response) gives me: ‘0D6010100\r\n’
I assume the \r\n at the end of the repr(response) has some kind hand in this issue?
You need to trim the response first: