Go Down

Topic: Redirecting serial monitor port on Mega2560? (Read 1 time) previous topic - next topic

l10i

Hello!

I was wondering: is there any way (short of tinkering with the source code) to have the built-in Serial Monitor listen for activity on a port different from TX0/RX0, in the case of the Mega2560?
This would be definitely useful in order to have a log without affecting communication of a mounted shield (such the Xbee or Ethernet).

Thanks,
Luca

retrolefty


Hello!

I was wondering: is there any way (short of tinkering with the source code) to have the built-in Serial Monitor listen for activity on a port different from TX0/RX0, in the case of the Mega2560?
This would be definitely useful in order to have a log without affecting communication of a mounted shield (such the Xbee or Ethernet).

Thanks,
Luca


Not without hardware wiring modifications on the board. The serial in and out data from the usb serial convertor chip is 'hardwired' to arduino pins 0 and 1, so that wiring would have to be changed to have the usb comm directly monitoring any of the other three serial ports.

I guess it would be possible in your sketch to have any data received on say serial port 3 to be sent out on the standard serial port to the PC using software statements in your sketch?

Lefty

l10i

It certainly would. But, then again, it would interfere with the TX/RX of, say, an Xbee shield communicating through port 0. That is my concern: being able to mount a shield that uses port 0 and simultaneously have an independent stream on the USB port. You could devise a time multiplexing strategy, but it would be pretty brittle.

johnmchilton

I am ramping up to do a project using a Maple board (leaflabs.com) with a BlueSMiRF talking to an Arduino Pro Mini with a BlueSMiRF. But to debug, I'm using an Arduino Mega instead of the Pro Mini since it has > 1 UART.

I have a communication protocol implemented already and am going to debug my connection in the following way:

+ Plug in the Bluetooth radios to UART 1 on both devices respectively (the USB connection is UART 0 on both).

+ For every byte of data that comes IN the USB connection, send it out over Bluetooth
+ For every byte of data that comes IN from the Bluetooth device, send it over USB to the computer

This way I can test that my Bluetooth devices are configured correctly and that the Arduino/Maple knows how to establish a connection.

Then I'll remove the computer from one side of the equation to make sure that my software stack is implementing the protocol correctly. That is, I'll check for proper responses on the computer from the board that is still acting as a serial data relay.

Then I'll put that first board back on the serial-relay program and make sure the other side is functioning correctly with its custom software.

Then, hopefully, everything will work!

The point of the story I am telling is that you can write a program like this:
Code: [Select]
void setup() {
  Serial.begin(57600);
  Serial1.begin(57600);
}

void loop() {
  while(Serial.available()) {
    Serial1.write(Serial.read());
  }

  while(Serial1.available()) {
    Serial.write(Serial1.read());
  }
}


I hope that helps!

lefstin

You could wire a TTL-USB converter to one of the other Mega serial ports, and monitor the output with a separate terminal program on the PC.

Go Up