sending bytes to a specific serial port

Hi all.

I know that using Serial.write(buf, len) I can write a specific number of bytes to the serial port, but how can I send that specific amount of bytes to a specific port?

I have a device connected to COM7 waiting for data from the serial port but when I use Serial.write(buf, len) it does not receives anything. I can see the data I'm sending with the serial monitor but nothing on my device.

What am I doing wrong?

On COM7 I have a telosb mote programmed with TinyOS running SerialAMReceiverC.
Working with a ESP8266 NodeMCU (on a WSN project with the mote).

The choice of serial port is made on the PC, not on the Arduino. The Arduino can only send data through the USB cable. It has no control over what (if anything) is on the other end.

…R

Robin2:
The choice of serial port is made on the PC, not on the Arduino. The Arduino can only send data through the USB cable. It has no control over what (if anything) is on the other end.

…R

So that means I won’t be able to communicate with my device using an Arduino? Maybe with some other program?

akher:
So that means I won't be able to communicate with my device using an Arduino? Maybe with some other program?

As you have not given any details about "my device" I don't know how to help.

...R

i’ve written code that runs on a laptop to communicate with an Arduino thru a specific com port on the laptop. The com port is passed as an argument to that laptop code and I need to figure out which port the Arduino is connected to. This can be determined from the Arduino IDE.

of course, only one PC application can connect to a com port. My code can’t communicate with the Arduino while the Arduino IDE is connected to that port.

1. Open the Device Manager of your PC and record COMX Port with which your device (telosb mote programmer) is found connected.

2. Open Arduino IDE and make it to detect your device (telosb mote programmer) via Tool Menu of the IDE at the same COMX Port of Step-1.

3. Now, you can receive (automatically) data at the 'agreed buad rate' on the OtputBox of Serial Monitor (Fig-1) from your device (telosb mote programmer).

4. How you can send data/command from the InputBox of the Serial Monitor to your device (telosb mote programmer) is beyond my understanding.

Serial Monitor:
SerialMonitor.png
Fig-1:

SerialMonitor.png

"I have a device connected to COM7 waiting for data from the serial port but when I use Serial.write(buf, len) it does not receives anything. I can see the data I'm sending with the serial monitor but nothing on my device."

Could be any number of things, like mismatched baud rates or a mismatch between communication methods like TTL vs. RS232. Maybe inappropriate wiring connections. The crystal ball is cloudy.