Assistance with VB.Net program

Hi guys, hope I ma posting this in the right forum area, if not please let me know.

I have a VB.Net program that reads data send from a Mega.
There is a Mega in every machine (large telemanipualtors) we build, and everytime the PC is connected to a new machine and hence a new Mega it takes out a new Com port address for it. This give us a problem in that we need to change the address in the software everytime we go to a new machine. If we go back to an old machine, it will reuse an older Com port.

My VB.Net program scans the PC for ports, but will only list the avaialble ports, not identify if a Mega is atached.
My question is...... is it possible to "ping" the Mega and get a predetermined responce which would tell the program if the Mega is on that particular port or not.

If so, does anyone have any pointers on how to do this in VB.Net

Sorry if my explanation is not clear.

Many thanks in advance for your help.

Andrew

My VB.Net program scans the PC for ports, but will only list the avaialble ports, not identify if a Mega is atached.
My question is...... is it possible to "ping" the Mega and get a predetermined responce which would tell the program if the Mega is on that particular port or not.

What is a Telemanipulator ?

I'm sorry but I don't know what exactly you mean by COM port. There was a time when it meant RS232 but now I would think it means USB. If that is the case then I don't know if that would work because I believe the USB port on a Mega , like an UNO is a SLAVE port and not a HOST port. The Mega has multiple serial ports and you could alway get a USB HOST port shield which can look for a specific string message and send an ACK response if it receives it. The whole concept seems to hinge on the hardware because the SW should be trivial.

A telemanipulator is a very large robotic arm, exo-skeleton type devide for heavy industry.

Sorry if my discription was not clear, i mean the Com ports on the laptop.
I want to write some VB code for the laptop program that sends a "hello are you a Mega" message to the Mega.
It i hope would then respond with "Yes i am a Mega" and thereafter i know which computer com port the Mega is plugged in to and the program can start to read data from that port.
Does this make it clearer.

Andrew

rockhoppers1964:
Sorry if my discription was not clear, i mean the Com ports on the laptop.

It was perfectly clear

I want to write some VB code for the laptop program that sends a "hello are you a Mega" message to the Mega.
It i hope would then respond with "Yes i am a Mega" and thereafter i know which computer com port the Mega is plugged in to and the program can start to read data from that port.

Unless you have disabled the Auto Reset on the Mega there will be a delay after the PC opens the Com port while the Mega resets and the PC must wait until that completes before trying to talk to the Mega.

I usually deal with this by getting my Arduino to send a short message from setup() such as Serial.println("Arduino is Ready") and my PC programs wait for that before beginning communications.

Maybe you could use that to determine what is connected - if the exected initial message does not arrive within a defined time the PC will know it is not connected to your device.

...R

Maybe you could use that to determine what is connected - if the exected initial message does not arrive within a defined time the PC will know it is not connected to your device.

And, if the message that was returned indicated that a Mega was attached, you'd know even more. And, if the message indicated which Mega was attached, you'd know even more.

i mean the Com ports on the laptop.

Well if it is so perfectly clear would someone mind telling me if you are talking about RS232 DB9 COM ports or USB COM ports
or does it even matter. I did not see a single reference to USB or RS232 in any of the posts in this thread. If I am not mistaken ,
a "COM" port can be either. I am simply asking if that is true.

I am simply asking if that is true.

Yes it is. It matters not whether the port is a real serial port (DB9 connector) or a virtual serial port (USB).