Finding an NXT in a specific USB port

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
ricardocrl
Posts: 117
Joined: 27 Dec 2010, 19:27

Finding an NXT in a specific USB port

Post by ricardocrl »

Hey all,

I'm wondering if it is possible to choose a specific USB phisical port, in a laptop, to assign a specific NXT connection.

I want to have several NXTs, each one connected to a USB ports in a host computer, but I would like to do the connections regardless of the MAC addresses, so that if I change the equipment, the only thing that matters to know to which NXT to talk is the USB port on the computer.

Any ideas?

Cheers,
Ricardo
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Finding an NXT in a specific USB port

Post by afanofosc »

I don't think I understand your question. Can you elaborate or give an example of what you are hoping to be able to do?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Finding an NXT in a specific USB port

Post by mattallen37 »

I think he wants to be able to have multiple NXTs, and have them recognized by the computer, not by the mac address, but by the USB port they are connected to on the computer. Basically, use the computer port address to know the NXT, not the NXT mac address.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
ricardocrl
Posts: 117
Joined: 27 Dec 2010, 19:27

Re: Finding an NXT in a specific USB port

Post by ricardocrl »

Exactly!

The idea is to connect them, regardless of their MAC address, but connecting the NXT that does "task A" to that specific USB port, so that if I change the LEGO equipment, I don't have to change the code, defines or whatever on the PC side.

I didn't know if there was an physical address of the USB ports accessible by software. I'm not familiar with this. That way, I imagine I can get the NXT mac addresses on each USB port. With that, I know to which NXT object (from the list found by the fantom drivers) I should assign the right task.

Thank you mattalen. :-)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Finding an NXT in a specific USB port

Post by afanofosc »

Yeah, I still don't understand the question. Can you write some pseudo code that suggests what you would like to do on the PC to connect to one of n NXTs? I assume you are talking about programmatic connection establishing rather than connecting via BricxCC's UI. I rarely connect to my NXTs by their mac address. When you use "usb" as the port name in BricxCC it connects to whatever NXT is connected to the first USB port that happens to have an NXT connected to it.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
ricardocrl
Posts: 117
Joined: 27 Dec 2010, 19:27

Re: Finding an NXT in a specific USB port

Post by ricardocrl »

Yes, I'm not using Bricxcc UI, I mean in a programmatic way, together with the fantom API to connect to a specific USB port.

The application is supposed to work as a server, from the host computer, sending requests to the NXT's connected in the several USB ports. Let's say that I want to attribute task "A" to the NXT "1", about which I don't know the MAC address. But if I know that my NXT 1 is connected to the USB phisical port "X", I will do:

- Finding the NXT device present on the phisical USB port "X" (This is what I don't know how to do by now, I was not even sure if it was feasible);
- Saving the MAC address/serial number of that NXT in memory;
- Through the fantom API, getting a list of all NXT's;
- Looking at their MAC addr (in the resource name) and find out which NXT object has the same MAC as the one I found in the port "X";
- Finally I know which NXT object to use and ask to run task "A".

Then, for instance, I can put a sticker on the laptop, near each USB port, like: "NXT 1".

Isn't it nice? Not very exciting for the majority of the projects, but it may be for some... :-)

Ricardo

PS: How are you John since LW2010? I was kind of in need to greet you, once I had the pleasure to meet you there. I will miss those days until next event. ;-)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests