Hallo
ich habe mir ein Arduino Yun zugelegt.
Leifer funktionieren die Beispielprojekte für WiFi nicht.
Wie wird bei einem Yun eine Ehernt client oder Wifi Client eingerichtet.
Habe ein Projekt für ein Arduino Uno
Kann mir jemand helfen wie ich dies auf Yun Lan und Wifi ändern muss ?
/*----------------------------------------------------------------------
RUN/STOP Demo
Created 19 Nov 2013
by Davide Nardella
------------------------------------------------------------------------
WARNING
This demo will perform cyclic RUN/STOP to your CPU
Don't use it in a production Environment
Use it at your own risk
------------------------------------------------------------------------
The model extended is needed.
- During the loop, try to disconnect the ethernet cable.
The system will report the error and will reconnect automatically
when you re-plug the cable.
- This demo uses ConnectTo() with Rack=0 and Slot=2 (S7300)
- If you want to connect to S71200/S71500 change them to Rack=0, Slot=0.
- If you want to connect to S7400 see your hardware configuration.
- If you want to work with a LOGO 0BA7 or S7200 please refer to the
documentation and change
Client.ConnectTo(<IP>, <Rack>, <Slot>);
with the couple
Client.SetConnectionParams(<IP>, <LocalTSAP>, <Remote TSAP>);
Client.Connect();
----------------------------------------------------------------------*/
#include <SPI.h>
#include <Ethernet.h>
#include "Settimino.h"
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0F, 0x08, 0xE11 };
IPAddress Local(192,168,0,70); // Local Address
IPAddress PLC(192,168,0,71); // PLC Address
S7Client Client;
//----------------------------------------------------------------------
// Setup : Init Ethernet and Serial port
//----------------------------------------------------------------------
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Start the Ethernet Library
Ethernet.begin(mac, Local);
// Setup Time, someone said me to leave 2000 because some
// rubbish compatible boards are a bit deaf.
delay(2000);
Serial.println(Ethernet.localIP());
}
//----------------------------------------------------------------------
// Connects to the PLC
//----------------------------------------------------------------------
bool Connect()
{
int Result=Client.ConnectTo(PLC,
0, // Rack (see the doc.)
2); // Slot (see the doc.)
Serial.print("Connecting to ");Serial.println(PLC);
if (Result==0)
{
Serial.print("Connected ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
}
//----------------------------------------------------------------------
// Prints the Error number
//----------------------------------------------------------------------
void CheckError(int ErrNo)
{
Serial.print("Error No. 0x");
Serial.println(ErrNo, HEX);
// Checks if it's a Severe Error => we need to disconnect
if (ErrNo & 0x00FF)
{
Serial.println("SEVERE ERROR, disconnecting.");
Client.Disconnect();
}
}
//----------------------------------------------------------------------
// Main Loop
//----------------------------------------------------------------------
void loop()
{
int Result, Status;
// Connection
while (!Client.Connected)
{
if (!Connect())
delay(500);
}
Result = Client.GetPlcStatus(&Status);
if (Result==0)
{
if (Status==S7CpuStatusRun)
{
Serial.println("STOPPING THE CPU");
Client.PlcStop();
}
else
{
Serial.println("STARTING THE CPU");
Client.PlcStart();
}
}
else
CheckError(Result);
delay(3000);
}