is there a command, to see in which com-port the arduino is connected to?
For example, if my arduino is connected to COM4, is there a way to get this in my arduino program?
if i do for example : test = Serial.getPort().... and that "test" takes the value of the com-port, so that "test" = "COM4".
jeffreyy:
Buth i thought if the arduino itselfs know in what com-port it's in, it was verry easy.
Actually, I don't see that would be any help at all since the Arduino has no way to tell anyone what port it's on unless they have already connected to the correct port.
Better would be to have the client establish a list of possible COM ports (on Windows you can look in the Windows Registry to find which COM ports the Arduino USB driver has created, or you might just try all COM ports) and implement a handshake between the client and the Arduino so that the client can ask, in effect, "Are you the Arduino I'm looking for?" and the Arduino can reply "Yes I am".
Buth i thought if the arduino itselfs know in what com-port it's in, it was verry easy.
Only the arduino IDE knows what com port you selected is, and even the IDE doesn't know if you told it the correct port name or not. The AVR chip is just sending and receiving TTL serial data out pins 0 and 1 with no idea if anyone is really connected or not, let alone which com port an attached PC might be using. So no, the arduino board has no way of knowing or caring and neither does the sketch when compiling know that information.