Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random transmission errors #1

Closed
jeremiedecock opened this issue Aug 26, 2015 · 2 comments
Closed

Random transmission errors #1

jeremiedecock opened this issue Aug 26, 2015 · 2 comments
Labels

Comments

@jeremiedecock
Copy link
Owner

The following snippet is sometimes executed correctly (i.e. returns "True" when the dynamixel #1 is connected) but fails otherwise, either by returning "False" (i.e. the input buffer is empty) or by returning a ValueError ("Incomplete packet"). This failures seems to occur randomly, even on successive executions.

from pyax12.connection import Connection

# Connect to the serial port
serial_connection = Connection(port="COM9", baudrate=57600)

# Ping the first dynamixel unit
dynamixel_id = 1
is_available = serial_connection.ping(dynamixel_id)
print(is_available)

# Close the serial connection
serial_connection.close()

These transmission errors have never been encountered on Gnu/Linux test platform so far.

@jeremiedecock
Copy link
Owner Author

Packet frames have been captured with a digital oscilloscope while executing the example:

  • Instruction packets and Status packets are always good (Instruction packet = FF FF 01 02 01 FB and Status packet = FF FF 01 02 00 FC);
  • there is roughly 1ms delay between the Instruction packet and the Status packet (see the attached image).

20150825_230304

The issue seems to come from the Connection.send() function with the following instructions:

time.sleep(0.01)
num_bytes_available = self.serial_connection.inWaiting()
status_packet_bytes = self.serial_connection.read(num_bytes_available)

@jeremiedecock
Copy link
Owner Author

Increasing the "time.sleep()" argument to e.g. "0.1" (100ms) fix this issue.

Despite the short 1ms delay response (of Dynamixel units) measured on the oscilloscope (i.e. the time between the Instruction packet and the Status packet), the operating system actually needs more than 10ms to fill its buffer...

To avoid this error, the "time.sleep()" delay between Instruction and Status packets can now be configured by a class member.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant