I am sending commands to Eddie using pySerial. I need to specify a carriage-return in my readline, but pySerial 2.6 got rid of it... Is there a workaround?
Here are the Eddie command set is listed on the second and third pages of this PDF. Here is a backup image in the case where the PDF is inaccessible.
Input: <cmd>[<WS><param1>...<WS><paramN>]<CR>
Response (Success): [<param1>...<WS><paramN>]<CR>
Response (Failure): ERROR[<SP>-<SP><verbose_reason>]<CR>
As you can see all responses end with a \r
. I need to tell pySerial to stop.
def sendAndReceive(self, content):
logger.info('Sending {0}'.format(content))
self.ser.write(content + '\r')
self.ser.flush();
response = self.ser.readline() # Currently stops reading on timeout...
if self.isErr(response):
logger.error(response)
return None
else:
return response
From pyserial 3.2.1 (default from debian Stretch) read_until is available. if you would like to change cartridge from default ('\n') to '\r', simply do:
import serial
ser=serial.Serial('COM5',9600)
ser.write(b'command\r') # sending command
ser.read_until(b'\r') # read until '\r' appears
b'\r'
could be changed to whatever you will be using as carriadge return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With