Skip to content

Fixed the code for selecting ports when using multi robot, added missing dll files.#104

Open
Begelit wants to merge 1 commit intodji-sdk:masterfrom
Begelit:master
Open

Fixed the code for selecting ports when using multi robot, added missing dll files.#104
Begelit wants to merge 1 commit intodji-sdk:masterfrom
Begelit:master

Conversation

@Begelit
Copy link
Copy Markdown

@Begelit Begelit commented Oct 4, 2024

Problem solved when using multiEP.

Due to randomization when selecting ports, duplicate ports could be encountered, which caused a conflict
proto._port = random.randint(config.ROBOT_SDK_PORT_MIN, config.ROBOT_SDK_PORT_MAX)

Added check for repetition and port busy:
while True: port = random.randint(config.ROBOT_SDK_PORT_MIN, config.ROBOT_SDK_PORT_MAX) if port not in self._port_list: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: logger.info(port,proto._ip,s.connect_ex((proto._ip, port))) if s.connect_ex((proto._ip, port)) != 0: self._port_list.append(port) proto._port = port logger.info("Set up port: {0}".format(proto._port)) break else: logger.info("port {0} are using".format(port)) else: logger.info("Repeated port: {0}".format(port))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant