Pages: [1]   Go Down
Author Topic: Attach Serial Monitor to Another Line?  (Read 884 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am posting this question here because there doesn't seem to be a category into which it fits...this seems to be the closest.

Is there a way to configure the Serial Monitor in the development environment to attach itself to a different serial port?  Currently it always attaches to Serial.   I am using the Mega and would like to attach it to Serial1, or perhaps Serial2.  Is this possible?  If so, how??
Thanks
J
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5666
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am posting this question here because there doesn't seem to be a category into which it fits...this seems to be the closest.

Is there a way to configure the Serial Monitor in the development environment to attach itself to a different serial port?  Currently it always attaches to Serial.   I am using the Mega and would like to attach it to Serial1, or perhaps Serial2.  Is this possible?  If so, how??

You can use a program like "putty" instead (and leave the window open between compiles!)
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only Serial port that is connected to the USB to Serial converter on the Arduino is Serial.

No, you can't attach the Serial Monitor to non-existent stuff.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 503
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's possible if you get an FTDI cable (effectively giving you another serial to USB connection). Then plug Rx of that cable into Serial1, Serial2 or Serial3 and view the output in putty or similar (connect Gnd as well of course).

eg. https://www.adafruit.com/products/70
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5666
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am posting this question here because there doesn't seem to be a category into which it fits...this seems to be the closest.

Is there a way to configure the Serial Monitor in the development environment to attach itself to a different serial port?  Currently it always attaches to Serial.   I am using the Mega and would like to attach it to Serial1, or perhaps Serial2.  Is this possible?  If so, how??

You can use a program like "putty" instead (and leave the window open between compiles!)


You have to add another serial cable to do this, obviously...  smiley-wink

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah, I think you all misunderstand my question.  I am not talking about physically connecting a device to an Arduino Tx-Rx pair....
I am talking about using the Serial Monitor in the IDE - the one that comes up when you Tools - Serial Monitor (Ctl-Shift-M)
It logically attaches itself to the stream associated with Serial.write..blah blah....
Suppose I have two streams, Serial and Serial1.   How do I direct Serial Monitor to attach to a specific serial stream??????? or can't I?
I am using a Mega bd that has 4 serial tx-rx pairs

j
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 503
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, because the hardware on the board connects the USB to the first serial port. As PaulS said.
Logged


Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

*If* you have a second USB-Serial converter, and *if* you then connected it to RX1 and TX1, then you could simply select the com port of this second port in tools->serial port. Then when you open the Serial monitor you would see messages coming out of and could send data to "Serial1".

If you don't have a second converter (or a third or a fourth), then you are stuck with the onboard one which is physically (and permanently) wired to RX0 and TX0. As a result you can only see messages from "Serial". This is due to hardware connections not the IDE. Serial sends data out of RX0, Serial1 sends data out of RX1, Serial2 from RX2, Serial3 from RX3. If these are not connected to the computer, how can you see anything from them in the serial monitor?
« Last Edit: October 30, 2012, 07:22:18 pm by Tom Carpenter » Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
*If* you have a second USB-Serial converter, and *if* you then connected it to RX1 and TX1, then you could simply select the com port of this second port in tools->serial port. Then when you open the Serial monitor you would see messages coming out of and could send data to "Serial1".

Ok, so what you are saying is that there is a hard wired connection from the Tx and Rx pins associated with Serial to the USB port and the serial data is streamed from the Tx pin 0 to the USB to which the Serial Monitor is attached.  

This is different than the way I interpreted how the Serial Monitor is working.  My initial perception was that the serial data was intercepted by the Serial monitor just before the data hit the Tx buffer.  Instead, according to you, the data goes out of the CPU pin and is routed via a trace to the USB connection.

Hmmmm, I would not have done it this way - it is very inflexible and relies on having a serial to usb cable and the necessary USB ports on the PC...I would have virtualized the whole com port thing, allowing it to be logically attached to the stream of choice.
OR, I would have put jumpers to select what serial line I wanted to feed the USB connection.  Whatever....

Be that as it is, now I know what I have to do.

Thanks for your clarification.

John

« Last Edit: October 30, 2012, 09:42:07 pm by Nick Gammon » Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmmm, I would not have done it this way - it is very inflexible and relies on having a serial to usb cable and the necessary USB ports on the PC...I would have virtualized the whole com port thing, allowing it to be logically attached to the stream of choice.
So the arduino "virtually" sends messages to the PC...? The pulses have to come from somewhere and go somewhere else --- it can't be "virtual"
Quote
OR, I would have put jumpers to select what serial line I wanted to feed the USB connection.  Whatever....

Why? That can easily be done in code, even if you switch back and forth a lot in the same program:
Code:
HardwareSerial& PCmon = Serial;
HardwareSerial& GPS = Serial1;
HardwareSerial& otherserialdevice = Serial2;

void setup() {
  PCmon.begin(115200);
  GPS.begin(9600);
  otherserialdevice.begin(4800);
}

void loop() {
  PCmon.println("Hello, PC!");
  GPS.print("Give me data please.");
  while (GPS.available() < 5);
  int xloc = GPS.read();
}

Then if you want to change the GPS to serial2, you just change the one line at the top.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 503
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 My initial perception was that the serial data was intercepted by the Serial monitor just before the data hit the Tx buffer.  Instead, according to you, the data goes out of the CPU pin and is routed via a trace to the USB connection.

What Serial monitor? That is running on the PC/Mac. The USB interface is provided as a convenience for uploading programs and outputting serial data.

Think for a moment about data coming from the PC to the Arduino. How would it know which serial port to send incoming data to if there is some sort of "intercepted" connection? And if you had jumpers, and started up the bootloader, which serial port would it look to grab a new copy of the program from?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What Serial monitor? That is running on the PC/Mac. The USB interface is provided as a convenience for uploading programs and outputting serial data.

Think for a moment about data coming from the PC to the Arduino. How would it know which serial port to send incoming data to if there is some sort of "intercepted" connection? And if you had jumpers, and started up the bootloader, which serial port would it look to grab a new copy of the program from?

I understand the convenience of the USB line. I've written drivers for a number of arm and TI processors, along with upld, dnld, bootoaders and monitor programs for them, so I understand the concepts.  As in most routing schemes/virtual connections, there is a default connection that is understood by both the IDE on the PC and the monitor/helper/bootloader program on the target.  Depending on how it is implemented, one or the other device keeps and controls the connection list.  The protocol of who knows what is designed as part of the functionality, would most likely be PC and arduino program in firmware would be small.  Anyway, this is all speculation and not indicative of how the thing actually works...like I said, I looked at it differently.


Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 503
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The protocol of who knows what is designed as part of the functionality, would most likely be PC and arduino program in firmware would be small. 

Absolutely.

Perhaps if you drew a diagram?
Logged


Pages: [1]   Go Up
Jump to: