Page 1 of 1

Python, no definition to call serial.close() to close the serial port.

Posted: Mon Feb 26, 2018 2:33 pm
by JorgeP
I read through all the code and documentation of called modules, like serial, and I don't see any definition for a call to "serial.close()'!

I see at the end of "roboclaw.py" a call to open:

Code: Select all

	def Open(self):
		try:
			self._port = serial.Serial(port=self.comport, baudrate=self.rate, timeout=1, interCharTimeout=self.timeout)
		except:
			return 0
		return 1
Shouldn't there be a seperate definition for the code to call:

Code: Select all

	self._port.close()
as well as a call to ensure all motors are stopped before the call to close()?

Luckily I was able to re-run the program again and issue a motor stop command before killing the test app. I thought it might be automatic upon loss of serial communications but that doesn't seem to be the case.

Re: Python, no definition to call serial.close() to close the serial port.

Posted: Mon Feb 26, 2018 3:17 pm
by Basicmicro Support
You need to install pyserial to use our class. Serial is part of the pyserial class.