mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-07 20:44:07 +05:30
Removed DOS-like CR/LF line terminators in arduino_driver.py
This commit is contained in:
parent
142e529de9
commit
59488c7b36
@ -112,18 +112,38 @@ class Arduino:
|
|||||||
'''
|
'''
|
||||||
c = ''
|
c = ''
|
||||||
value = ''
|
value = ''
|
||||||
attempts = 0
|
start = time.time()
|
||||||
|
|
||||||
while c != '\r':
|
while c != '\r':
|
||||||
c = self.serial_port.read(1)
|
c = self.serial_port.read(1)
|
||||||
value += c
|
value += c
|
||||||
attempts += 1
|
if time.time() - start > timeout:
|
||||||
if attempts * self.interCharTimeout > timeout:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
value = value.strip('\r')
|
value = value.strip('\r')
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
# def recv(self, timeout=0.5):
|
||||||
|
# timeout = min(timeout, self.timeout)
|
||||||
|
# ''' This command should not be used on its own: it is called by the execute commands
|
||||||
|
# below in a thread safe manner. Note: we use read() instead of readline() since
|
||||||
|
# readline() tends to return garbage characters from the Arduino
|
||||||
|
# '''
|
||||||
|
# c = ''
|
||||||
|
# value = ''
|
||||||
|
# attempts = 0
|
||||||
|
# while c != '\r':
|
||||||
|
# c = self.serial_port.read(1)
|
||||||
|
# value += c
|
||||||
|
# attempts += 1
|
||||||
|
# if attempts * self.interCharTimeout > timeout:
|
||||||
|
# return None
|
||||||
|
#
|
||||||
|
# value = value.strip('\r')
|
||||||
|
#
|
||||||
|
# return value
|
||||||
|
|
||||||
def recv_ack(self):
|
def recv_ack(self):
|
||||||
''' This command should not be used on its own: it is called by the execute commands
|
''' This command should not be used on its own: it is called by the execute commands
|
||||||
below in a thread safe manner.
|
below in a thread safe manner.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user