Sending data from one Yun to another Yun - HELP

Hello everyone.

I am still searching out a mechanism to transfer simple ASCII data from one Yun to another Yun over WiFi. Some individuals had helped get me on the right path, but I am facing some odd data coming over the Serial Monitor.

Here's my setup. One Arduino Uno with a Yun on top (Server), and a second Arduino Uno with a Yun on top (Client).

I logged into the web portal of the Server Yun, set an appropriate SSID, and set it to "Access Point" mode.

I then logged into the web portal of the Client Yun, set a different SSID, changed its static IP address so there wasn't a conflict on the network with both running, and then set it to "Client" mode.

So far, so good. I can still login to both Yun devices, make changes if necessary, SSH in to look around, etc. No issues.

NEXT, as a simple test I found the completed sketch someone was working on here, which simply sends a value of "42" from the client to the server, and displays it:

I had to make a couple changes. First, based on warnings during compilatio I changed YunClient.h and YunServer.h to BridgeClient.d and BridgeServer.h. Second, I changed the IP address given in the example to reflect the IP address of my "server" Yun. Everything compiled and uploaded to their respective Arduino devices.

This is where I ran into a problem. I can't seem to get a CONSOLE monitor display going?? I assumed it was talking about the Serial Monitor, but I think I am wrong. In the serial monitor there is just an unending string of random ASCII symbols (i.e. - ÿüþýøýøúøøúøøþþøøøúþýøþþþúþøþ......). If this console monitor is a linux thing, well I'm not very fluent in linux. I found some commands online that would supposedly open a console window, but none of them were recognized commands in my SSH session, so I'm kinda stuck. I just don't have the knowledge for what to do next, especially regarding linux-specific topics.

I swapped the Console.println for a Serial.println, thinking it would re-route the display to the Serial Monitor, but that did nothing - there is just the same random string of ASCII symbols.

I don't even know if the code is running. With no code uploaded and just power hooked up to the Yun devices, the Serial Monitor still shows the same unending string of ASCII symbols. Same as what it is doing now with supposedly appropriate working code uploaded.

Can anyone help?

The forum link I provided had no examples of how to setup the Yun hardware, so based on other suggestions I received I configured the two Yun devices accordingly (mentioned above) based on my assumptions of how the communication should take place. That is likely incorrect as well.

Thank you in advance!

-Dave

Xxx

prosper50:
This is where I ran into a problem. I can't seem to get a CONSOLE monitor display going?? I assumed it was talking about the Serial Monitor, but I think I am wrong. In the serial monitor there is just an unending string of random ASCII symbols (i.e. - ÿüþýøýøúøøúøøþþøøøúþýøþþþúþøþ......). If this console monitor is a linux thing, well I'm not very fluent in linux. I found some commands online that would supposedly open a console window, but none of them were recognized commands in my SSH session, so I'm kinda stuck. I just don't have the knowledge for what to do next, especially regarding linux-specific topics.

OK, it seems we have some basic misunderstandings here, let's see if we can clear some of this up. :wink:

First off, there are two different processors on the Yun: the one that runs your sketch, and the one that runs Linux. Both of them have communications abilities, and both of them could use the generic term "console" but in different ways. I'm sure that's a big part of the confusion.

First, the processor that runs the sketch: there are two ways you can get serial communications between it and your computer: over the USB port, or over the network. (For the sake of this discussion, 'network" means WiFi or wired Ethernet -they both work the same way, and are interchangeable. It doesn't matter how the network is connected, only that it is.)

USB Serial: If you use a USB cable to connect the micro-USB port of the Yun to your computer, you can use the USB serial link. To do so, you use something like this:

Serial.begin(115200);  // The parameter is the baud rate, but it is really meaningless for the USB connection: doesn't matter what you use

// Optional code to wait for a serial connection from the computer.
// Note that this will cause the sketch to hang until the computer connects
// so you don't want this unless you ALWAYS connect with the computer.
while (!Serial)
   ; // Do nothing.

Serial.prinln("Hello world!");

Now, in the Arduino IDE, when you have the Yun's USB serial port selected in the Port menu, you can open the Serial Monitor. This will connects to the Yun's USB serial port, and you will see the output from the Yun (and can send commands that are read with Serial.available() and Serial.read().) This is one way to set up communications between your sketch and your computer.

Console class: This is a way to do the same thing, but without the USB port: it talks over the network (wired or wireless.) It makes use of the Console class (note the capital C) that is part of the Bridge library. You use it in much the same way, just replace "Serial" with "Console" and add a call to initialize the Bridge library:

Bridge.begin();
Console.begin();

// Optional code to wait for a serial connection from the computer.
// Note that this will cause the sketch to hang until the computer connects
// so you don't want this unless you ALWAYS connect with the computer.
while (!Console)
   ; // Do nothing.

Console.prinln("Hello world!");

Anything you can do with the Serial class, you should also be able to do with the Console class. To use this on the computer side, in the IDE you need to select the Yun's IP address on the Port menu, not the Yun's serial port. Then, open the Serial Monitor, and it should connect to the Yun over the network, and you can then talk to the sketch using the Console class. While it's nice to be able to do this over the network, I've personally found that the Console class isn't quite as reliable as the USB serial connection, and I prefer the USB connection when possible.

Linux console: now for the Linux side. First of all, not that I spelled console with a lower case C. This is not a class or object, but is just a general term. The Linux console (where you see boot messages and system diagnostic output, and can control the boot process) is the same serial port that is connected between the Linux and sketch processors. You can't directly connect to this port with a computer, but you can access it by loading the Yun Serial Terminal example, and then connecting to the Yun's USB port (same way as described above.) This example sketch copies everything received from the Linux console port to the USB port, and anything received from the USB port to the Linux console port. So it's the next best thing to a direct connection. This is useful for diagnosing boot up issues, or for doing critical Linux maintenance like resetting the root password, but I've noticed that it sometimes drops characters, especially when sending escape sequences. Which brings us to:

Linux SSH: this is a way to connect to the Linux command line over the network. This is much more reliable than using the Yun Serial Terminal sketch, but it doesn't give you access to watching the boot messages go by, or to access the Linux bootloader if you are having booting problems. But once Linux is fully booted, it's the best way to get the command line interpreter for routine Linux system operations and programming. Note that I'm specifically calling this the "command line" and not the "console." Some will use those two terms interchangeably, but it's not really correct: the console is the specific serial port (connected to the sketch processor on the Yun) that is used while booting Linux, while the command line is the command interpreter that can be accessed by several methods.

Hopefully this explanation clears up some things, and at least tells you the difference between the various connection methods. If you want to see debug print statements from your sketch, you need to use the Serial class (for a wired USB connection) or the Console class (for a network connection.) Now, you should be be able to decide which connection method you want to use, and how to use it.

I would suggest you write a very simple sketch that allows you to connect from your computer and see the printed debug output. Try using the Serial and Console connections and see which works better for you. Once you can get that part working reliably, go back to your sketch that's giving you trouble and try and get your debug output working properly.