Arduino Forum

Products => Arduino Yún => Topic started by: robotboy27 on May 18, 2015, 06:41 am

Title: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 18, 2015, 06:41 am
Hi . I have connected my computer to my yun network. Am I able to use labview TCP/IP to communicate to Yun wirelessly? Has anyone done this before?
Title: Re: Yun to labview TCP/IP wireless
Post by: Angelo9999 on May 18, 2015, 11:26 am
Please, don't double post. Continue the discussion here http://forum.arduino.cc/index.php?topic=323068.0 (http://forum.arduino.cc/index.php?topic=323068.0)
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 18, 2015, 10:49 pm
Hi . I have connected my computer to my yun network. Am I able to use labview TCP/IP to communicate to Yun wirelessly? Has anyone done this before?
@robotboy27,
it appears you can use  labview TCP/IP to communicate with the Yun wirelessly, but it is a real over kill for any purpose the Yun was designed for. I have not used the product, but I did read the literature.

What are your trying to do?

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 19, 2015, 05:07 am
Hi . What do you mean by over kill? What I would love to do is to control my arduino yun wirelessly using Labview GUI with TCP/IP . Do you know other ways I can control my arduino yun using this way?
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 19, 2015, 07:50 am
Hi . What do you mean by over kill? What I would love to do is to control my arduino yun wirelessly using Labview GUI with TCP/IP . Do you know other ways I can control my arduino yun using this way?
@robotboy27,
it depends on what you are trying to do, but typical development is to use CURL (http://curl.haxx.se/docs/manpage.html). It is a command line utility to send not just packets, but files, if needed. Otherwise, the YUN is a fully functional Linux box, so it can be configured as a server. You can login using ssh, or use the YunSerialTerminal (http://www.arduino.cc/en/Tutorial/YunSerialTerminal) to issue command, it also has a webserver running so you can use that. Or you can install your own set of tools.

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 19, 2015, 08:49 am
Oh so sorry . Right now I am using Yun's network . I am trying to communicate with my computer labview(client) to my yun (server). I tried to communicate  using TCP/IP but no data was recieved nor sent out.Here below is what I have done . Please guide me on where am I wrong.

Here is the code I used for my yun
i change it a little from the example
 
#include <SPI.h>
#include <Ethernet.h>
#include<Console.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {
0x90, 0xA2, 0XDA , 0XF0 , 0X24 , 0X23
};
IPAddress ip(192, 168, 240, 117);
EthernetServer server(3477);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip);
// start listening for clients
server.begin();
Bridge.begin(); // Initialize Bridge
Console.begin();

// Open serial communications and wait for port to open:
while (!Console);

Console.print("Chat server address:");
Console.println(Ethernet.localIP());
}
void loop() {
// wait for a new client:
EthernetClient client = server.available();
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
client.flush();
Console.println("HI");
client.println("Hello, client!");
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Console.write(thisChar);
}
}
}
 
I am unable to send nor receive . HELPP!!
I am getting error 63 and tcp open connection in untitled one
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 19, 2015, 10:14 am
@robotboy27,

Okay. This common. You have a misunderstanding about the Yun. The answer below is a canned answer. It is not the question you asked, but it will answer many of your questions.

To be clear, you code shows that you have a misunderstanding. Please read the section below, it will help you get started in the right direction.

Again, there is a misunderstanding about how the Yun works. Read below.

But before you follow any of the steps below read the whole thing, and first read this:
Guide to the Arduino Yún
http://www.arduino.cc/en/Guide/ArduinoYun (http://www.arduino.cc/en/Guide/ArduinoYun)


= [Q:] I cannot connect to My Arduino Yún. What do I do? =


First it's good to know, when  Arduino Yun cannot find the AP you have set it for (like your home wifi), it has a script that puts it back into default SSID and AP mode.

Next, you may have already watched this video, but it's worth watching again. Pay extra attention to the part with the sketches.
Getting started with Arduino Yún - tutorial (6:53)
https://www.youtube.com/watch?v=9-hPhWHWnvs (https://www.youtube.com/watch?v=9-hPhWHWnvs)

Then, read these short instructions. We (the volunteer support group) already know these steps by heart, so be familiar with the different reboot methods, and especially the 30+ second wifi reset. Also, not mentioned on that page, if you reset the Wifi/Linux part of the Yun, it will take from 2-8 minutes for the reboot. Lastly on this part, YOU MUST WAIT for the Linux portion to fully boot BEFORE YOU PRESS ANY of the REST buttons.
Resetting the processors (AR9331, WiFi, and 32U4)
http://arduino.cc/en/Guide/ArduinoYun#toc6 (http://arduino.cc/en/Guide/ArduinoYun#toc6)

'''Then start over''', plug your Yun into the USB port, run this sketch, and hit the ''Wifi Reset button''  (for 5-10 seconds). (See Image below for location of buttons.)
http://arduino.cc/en/Tutorial/YunSerialTerminal (http://arduino.cc/en/Tutorial/YunSerialTerminal)

The ''YunSerialTerminal'' provides a simplified console access to the Linux part of the Yun. It works via the USB port (the one that powers the Yun - the microUSB). From there you'll be able to run a few commands to give us a better idea of problems.

Also, be ready with this sketch YunWiFiStatus (http://arduino.cc/en/Tutorial/YunWiFiStatus). This sketch will help us see the status of your home AP. The sketch prints the wifi status to the console every 5 seconds or so. This sketch might seem familiar as it was in that first video link (above).

Let us know how it goes.
Post results from the YunSerialTerminal (http://www.arduino.cc/en/Tutorial/YunSerialTerminal), if you are still having problems.
Please use markup when posting results. (See image below)

Lastly, if you are not familiar with Linux, you may want to read this:
http://arduino.cc/en/Tutorial/LinuxCLI (http://arduino.cc/en/Tutorial/LinuxCLI)

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 19, 2015, 11:19 am
hmmmm... but I have to set up a link from my arduino to labview using TCP/IP . How do I do it?
Title: Re: Yun to labview TCP/IP wireless
Post by: ShapeShifter on May 19, 2015, 12:42 pm
Here is the code I used for my yun
i change it a little from the example
 
#include <SPI.h>
#include <Ethernet.h>
#include<Console.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {
0x90, 0xA2, 0XDA , 0XF0 , 0X24 , 0X23
};
IPAddress ip(192, 168, 240, 117);
EthernetServer server(3477);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip);
// start listening for clients
server.begin();
Bridge.begin(); // Initialize Bridge
Console.begin();
What example did you start with? It looks like you made a LOT of changes. This will never work.

The code highlighted in red is for the Arduino Ethernet shield. The Yun's networking is completely different and the code in that library cannot be made to work with the Yun.

On the other hand, the code highlighted in blue is from the Yun's Bridge library, and is the correct code to use.

Step 1: pretend that anything in the standard Ethernet (http://arduino.cc/en/Reference/Ethernet) or WiFi (http://arduino.cc/en/Reference/WiFi) libraries doesn't exist - they will not work with Yun.

Step 2: read up on the Yun Bridge Library (http://arduino.cc/en/Reference/YunBridgeLibrary), everything network related goes through that library.

Step 3: specifically study the YunServer (http://arduino.cc/en/Reference/YunServerConstructor) and YunClient (http://arduino.cc/en/Reference/YunClientConstructor) classes, they are the closest to the server and client objects you used in your sketch.
Title: Re: Yun to labview TCP/IP wireless
Post by: ShapeShifter on May 19, 2015, 01:24 pm
A little more information:

I think the code IN THIS POST (http://forum.arduino.cc/index.php?topic=288665.msg2038090#msg2038090) is close to what you posted above, and might be a starting point for you.

This may also be helpful: Beginner's Introduction to Yun Web Services (http://forum.arduino.cc/index.php?topic=315554.msg2185197#msg2185197)
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 20, 2015, 12:39 am
hmmmm... but I have to set up a link from my arduino to labview using TCP/IP . How do I do it?
@robotboy27,

I'm not being clear. YOUR CODE is NOT correct. You are using libraries that are intended for use the Leonardo, the Uno and others. The Yun is different. You need to use a different library or send the data to the Linux side to be able to see your data.

USING labview will get you nothing because your code is written wrong. Please watch the videos provided.

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 20, 2015, 04:17 am
Alright . Wow I did not know that . Sorry the Yun is so confusing . Thank you guys . So if I changed my codes ,  TCP/IP labview will be able to read it right?
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 20, 2015, 05:39 am
Alright . Wow I did not know that . Sorry the Yun is so confusing . Thank you guys . So if I changed my codes ,  TCP/IP labview will be able to read it right?
@robotboy27,
if you insist on using labview, you can; but it is an overkill. You should be able to write an application in an hour or so, if you start from one or the tutorials.

I have to ask again, what are you going to use labview for?

Labview is not intended for application development. It is a tool for network analysis. This is like using a pair of paper scissors when you only need a sewing needle.

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 20, 2015, 08:01 am
Oh I am using labview as my GUI . What I am doing is building energy management system. And my teacher wanted it to be wireless so I have no choice that I will have to use TCP/IP. All I want is to use it to turn on a relay using my Labview GUI . That's what I have to do.
Title: Re: Yun to labview TCP/IP wireless
Post by: ShapeShifter on May 20, 2015, 12:56 pm
Alright . Wow I did not know that . Sorry the Yun is so confusing . Thank you guys . So if I changed my codes ,  TCP/IP labview will be able to read it right?
I don't know about that, I haven't used Labview in 20 years, and it was only a cursory use back then over GPIB, not a network. I don't know what's involved in getting Labview to talk over a network.

But I do know how to get the Yun to listen for incoming connections from other computers, and that's what the code I linked to earlier does. Making the connection is only half of the battle, understanding the Labview protocols and commands is the bigger part of it. I'm sorry, but you're on your own there.

Labview is not intended for application development. It is a tool for network analysis.
I think you're thinking about the wrong product? Labview (http://www.ni.com/labview) is a graphical programming environment designed for analytical instrument control and data collection. While it can communicate with instruments over a network, it is not a networking tool.
Title: Re: Yun to labview TCP/IP wireless
Post by: mart256 on May 20, 2015, 01:08 pm
You better build an html webapp as GUI. Its easy and Yun can serve it.
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 20, 2015, 04:12 pm
Yeah I wish I could . But my teacher wants it in LabView . So now I am having a lot of problem understanding TCP/IP in Labview . I do not know how to link them . All I know is I will have to make codes for arduino and make a client TCP for Labview. But I am no way near there . :(
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 20, 2015, 10:10 pm
Yeah I wish I could . But my teacher wants it in LabView . So now I am having a lot of problem understanding TCP/IP in Labview . I do not know how to link them . All I know is I will have to make codes for arduino and make a client TCP for Labview. But I am no way near there . :(
@robotboy27,

I understand now. I thought this might be the case. Teachers understand theory, not pratice. Don't tell youd teacher I said he was a fool. Come back as often as you need to get this done.

Use the Bridge example from your laptop
http://www.arduino.cc/en/Tutorial/Bridge (http://www.arduino.cc/en/Tutorial/Bridge)

Once you have it working, which should be an hour or two, then try to do the same on Labview.

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 20, 2015, 10:12 pm
::::SNIP::::

I think you're thinking about the wrong product? Labview (http://www.ni.com/labview) is a graphical programming environment designed for analytical instrument control and data collection. While it can communicate with instruments over a network, it is not a networking tool.
@ShapeShifter,
Yep, we are talking about the same thing with different words again. I said it was in #12
It is a tool for network analysis.
I have marked that section for you. ;)

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: ShapeShifter on May 20, 2015, 11:31 pm
@ShapeShifter,
Yep, we are talking about the same thing with different words again. I said it was in #12
It is a tool for network analysis.
I have marked that section for you. ;)

Jesse
But Labview IS NOT a tool for network analysis!

From http://www.ni.com/labview (http://www.ni.com/labview):
Quote
LabVIEW System Design Software

LabVIEW software is ideal for any measurement or control system, and the heart of the NI design platform. Integrating all the tools that engineers and scientists need to build a wide range of applications in dramatically less time, LabVIEW is a development environment for problem solving, accelerated productivity, and continual innovation.
I certainly don't think the teacher is a fool for trying to teach an appropriate instrumentation control system. Easily controlling equipment (and collecting data from it) is what it's designed to do.
Title: Re: Yun to labview TCP/IP wireless
Post by: mart256 on May 20, 2015, 11:52 pm
I think you can control Yun with less heavier solutions. If you are using labview just as a GUI, then it is an overkill IMO.
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 21, 2015, 12:44 am
But Labview IS NOT a tool for network analysis!

From http://www.ni.com/labview (http://www.ni.com/labview):
I certainly don't think the teacher is a fool for trying to teach an appropriate instrumentation control system. Easily controlling equipment (and collecting data from it) is what it's designed to do.
@ShapeShifter,
After sometime, I recalled Labview. It is a very good analysis tool. But it is an overkill for developing Apps. Labview was widely used in the valley (Silicon Valley) for some time until Network engineers decided it was an overkill.

For instance, if I was going to design a Switch system with Multiple types of technologies from say ISDN to IP, then Labview would definitely be in my arsenal. But if I just wanted to talk to the Arduino Yun or Ethernet Switch with 100 channels, I'd just use my laptop. Now, if that Ethernet Switch had issues that could NOT be determined by unplugging subnets, then Labview is great.

Just to be clear on this point, NI sold (or gave) this software to lots of teleco's and I'd seen them used, but mostly I'd seen these systems gather dust. Labview is a great tool; it's just not well understood. Hell, I even forgot about it, till yesterday.

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: ShapeShifter on May 21, 2015, 03:43 am
I think you can control Yun with less heavier solutions. If you are using labview just as a GUI, then it is an overkill IMO.
Yes, there are more efficient ways of doing things. But teaching scenarios often introduce artificial constraints in order to introduce new concepts. Simply controlling the output of a Yun using Labview is overkill, but I'm guessing it's an early baby step towards introducing more complex control scenarios.

Labview was widely used in the valley (Silicon Valley) for some time until Network engineers decided it was an overkill.
I just don't see network engineers being a target market for Labview, it's no wonder they don't use it.

The prime market I see for it is in a laboratory setup where a chemist/technician/engineer wants to hook up a bunch of lab instruments to a computer, remotely control them, and collect data from them. That may not be the most efficient way, but it's a way to accomplish the task without having to learn a programming language, having to figure out how to talk to all of the different instruments, or figure out a complex API for each machine. Just load up the drivers that provide a high level abstraction of each instrument and connect it all together with the graphical programming environment. I see it as the laboratory equivalent of a PLC: it's used to connect and automate a bunch of test instruments in a similar way as a PLC would be used to control a bunch of industrial machines.

You're right in that I just don't see it being used for networking control or analysis. But I do see it controlling lab equipment, and I do see the OP's project as a first step to integrating an arbitrary machine into such an environment (if only as a learning experience.) Sure there are different ways to do it, and Labview wouldn't be my first choice either, but you aren't going to get good grades in a class if you don't do the assignment as instructed. I remember an early algorithms class where I had to write a program to do a Gauss-Jordan reduction in FORTRAN, thinking that it's silly because I could do it in one operator using APL: while that would've been much more efficient, it would've given me failing grade in that FORTRAN algorithm assignment!
Title: Re: Yun to labview TCP/IP wireless
Post by: robotboy27 on May 21, 2015, 04:15 am
Yeah . I think LabView is more like a teaching tool . Anyway , I want to sent 1 or 0 to turn off my relay from my labView GUi to my YUN. Since TCP is all strings , how can I tell it to turn the relay on and off?
How can I code this in the IDE ? Sorry but this is quite advance for a beginner user in both platforms.Is anyone able to help me?
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 22, 2015, 12:34 am
Yeah . I think LabView is more like a teaching tool . Anyway , I want to sent 1 or 0 to turn off my relay from my labView GUi to my YUN. Since TCP is all strings , how can I tell it to turn the relay on and off?
How can I code this in the IDE ? Sorry but this is quite advance for a beginner user in both platforms.Is anyone able to help me?
@robotboy27,
No problem. I think ShapeShifter is likely right in this task. Let's get you moving.

On the Yun side, you'll be using the Bridge Library (http://www.arduino.cc/en/Reference/YunBridgeLibrary). You specifically want the Bridge Tutorial Example (http://www.arduino.cc/en/Tutorial/Bridge) loaded on the Yun, then access that sketch via your laptop with your webbrowser.

Specifically, you'll be using the REST API (http://www.arduino.cc/en/Guide/ArduinoYun#toc5). Get it working on your laptop or desktop, then copy the URL over to the Labview system and set it up.

In other words, you can turn your relay on and off with a 0 (zero) or 1 (one) - just with your laptop, then it will be a matter of making labview do the same thing.

FWIW: there is an LED (#13) on the Yun that is part of the tutorial. You can test the sketch and the REST API just with that.

I hope I've given you enough. If not, someone else will chime in.
Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: sonnyyu on May 22, 2015, 07:45 pm
Yeah . I think LabView is more like a teaching tool . Anyway , I want to sent 1 or 0 to turn off my relay from my labView GUi to my YUN. Since TCP is all strings , how can I tell it to turn the relay on and off?
How can I code this in the IDE ? Sorry but this is quite advance for a beginner user in both platforms.Is anyone able to help me?
Load this code first:

Console Pixel example from IDE:

Code: [Select]
#include <Console.h>
const int ledPin = 13; // the pin that the LED is attached to
char incomingByte;      // a variable to read incoming Console data into
void setup() {
  Bridge.begin();   // Initialize Bridge
  Console.begin();  // Initialize Console
  while (!Console);   // Wait for the Console port to connect
  Console.println("type H or L to turn pin 13 on or off");  
  pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:
}
void loop() {
  // see if there's incoming Console data:
  if (Console.available() > 0) {
    incomingByte = Console.read();  // read the oldest byte in the Console buffer:
    Console.println(incomingByte);
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);  // if it's a capital H (ASCII 72), turn on the LED:
    }
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);   // if it's an L (ASCII 76) turn off the LED:
    }
  }
}
Title: Re: Yun to labview TCP/IP wireless
Post by: sonnyyu on May 22, 2015, 07:54 pm
Test  Above code

Code: [Select]
ssh root@ yourYunsName.local 'telnet localhost 6571'

type "H" will be on, type "L" will be off.

Now we need redirect port 8888 of Arduino Yun ip (i.e. 192.168.0.102) to localhost 6571.


Code: [Select]
opkg update
opkg install socat



Code: [Select]
(socat TCP-LISTEN:8888,fork TCP:127.0.0.1:6571) &


Now you should be able access Yun from PC  which runs LabView via:

Code: [Select]
telnet 192.168.0.102 8888

type "H" will be on, type "L" will be off.


At LabView select TCP...


Title: Re: Yun to labview TCP/IP wireless
Post by: sonnyyu on May 22, 2015, 07:58 pm
socat - 1.7.2.1-1 - SoCat (for SOcket CAT) establishes two bidirectional byte streams and transfers data between them. Data channels may be files, pipes, devices (terminal or modem, etc.), or sockets (Unix, IPv4, IPv6, raw, UDP, TCP, SSL). It provides forking, logging and tracing, different modes for interprocess communication and many more options.





Title: Re: Yun to labview TCP/IP wireless
Post by: ShapeShifter on May 22, 2015, 09:17 pm
Now we need redirect port 8888 of Arduino Yun ip (i.e. 192.168.0.102) to localhost 6571.
Very Nice!  8)

Up until now I had a clumsy time accessing the Console by any method other than the Serial Monitor button on the IDE (if the Yun even showed up on the Port menu.)

But this is simple and it works! Now I can make a direct connection from PuTTY or an application without having to jump through hoops.

I'll say it again: Very Nice!  8)
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on May 23, 2015, 03:58 am
Quote
Quote from: sonnyyu on Today at 11:54 am

    Now we need redirect port 8888 of Arduino Yun ip (i.e. 192.168.0.102) to localhost 6571.
Very Nice!  8)

::::SNIP::::
@ShapeShifter,
I knew Sonny would give us a better solution. I used to use netcat, but this (so-cat) a better solution. 8)

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: sonnyyu on May 26, 2015, 11:05 am
...
I knew Sonny would give us a better solution. I used to use netcat, but this (so-cat) a better solution. 8)
...
The netcat should worked as well.

Code: [Select]
opkg  update
opkg install netcat


Code: [Select]
mkfifo /tmp/fifo
(netcat -l -p 8887 < /tmp/fifo | netcat 127.0.0.1 6571 > /tmp/fifo) &




Title: Re: Yun to labview TCP/IP wireless
Post by: pal30130 on Dec 17, 2015, 10:54 am
How do you success of using it at the end?
Title: Re: Yun to labview TCP/IP wireless
Post by: nickgammon on Dec 18, 2015, 07:37 am
This reply is meaningless. Please explain yourself, or be banned.
Title: Re: Yun to labview TCP/IP wireless
Post by: CrossRoads on Dec 18, 2015, 07:44 am
Poor translation I think Nick. His other post is just a touch better.
Title: Re: Yun to labview TCP/IP wireless
Post by: jessemonroy650 on Dec 20, 2015, 03:12 am
@Nick,
Agree with crossroads.

This subject in particular has been annoying. Some professor, some where in Europe (we think) is assigning students to have Arduino Yun talk to Labview. What makes it silly is theses students don't know a thing about TCP/IP networking. Which means all we can do is hand them a canned answer. Answers they cannot expand - because they don't understand the answer; let alone the question.

Jesse
Title: Re: Yun to labview TCP/IP wireless
Post by: pal30130 on Jan 08, 2016, 06:07 am
How to use labview and Arduino yun's Wireless Protocol??