pybricks / support

Pybricks support and general discussion
MIT License
109 stars 7 forks source link

[Question] Communicate with PC with USB. #1008

Closed Developer-Mike closed 1 year ago

Developer-Mike commented 1 year ago

Question Is it possible to communicate between the EV3-Brick and the PC through USB?

Context I'm trying to make a Mindstorms robot that plays a game using the Minimax algorithm. The problem is that the brick is too slow to calculate those moves.

dlech commented 1 year ago

Pybricks currently only supports Bluetooth communications. Please see #262 for more info.

Developer-Mike commented 1 year ago

Thank you for your blazingly fast response. So I guess that this is an example that would fit my case.

dlech commented 1 year ago

Yes, that is the simplest way to use Bluetooth with Pybricks on EV3.

Although I should also mention on EV3, it is possible to have a network connection over USB too, so you can use basic networks sockets if you know how to do that.

Developer-Mike commented 1 year ago

Can you elaborate further? What do you mean by a network connection over USB? Do you mean a connection to the network over the PC?

dlech commented 1 year ago

Out of the box, ev3dev is set up to create a network connection to the host computer over USB. https://www.ev3dev.org/docs/tutorials/connecting-to-the-internet-via-usb/

This is what allows connecting to the EV3 via SSH either for a remote terminal or transferring files with SCP.

But since it is just a basic network connection, you can do TCP/IP, e.g. using the MicroPython socket module.

Developer-Mike commented 1 year ago

Thank you so much. Because I'm connected to the network of the PC the IP address for connecting from the brick to the computer should be 127.0.0.1. Correct?

dlech commented 1 year ago

No, 127.0.0.1 is the localhost address, so would be the address of the computer itself. When connected, the IP v4 address of the EV3 is shown on the screen on the EV3. You can also resolve the hostname ev3dev.local to get the address (replace ev3dev if you changed the hostname of the EV3).

Developer-Mike commented 1 year ago

Worked! Thank you so much 😊