Hi,
I want to establish a client server communication between the PMC and my PC to send and receive data from a C# application.
I tried both: PMC as client and as server (from advanced chat server example)
I want to use the PMC in PLC IDE, which means means my sketch file runs under the Resources/Sketch section.
#include <PortentaEthernet.h>
arduino::EthernetClass eth(&m_netInterface);
#include <Ethernet.h>
#include <SocketHelpers.h>
#include <MbedServer.h>
#include "Wire.h"
#include <Arduino_MachineControl.h>
using namespace machinecontrol;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 2, 170);
IPAddress myDns(192, 168, 2, 1);
EthernetServer server1(555);
EthernetClient client1;
void setup()
{
eth.begin(mac,ip,myDns);
delay(1000);
server1.begin();
Serial.print("server address:");
Serial.println(eth.localIP());
}
void loop()
{
if(!client1.connected())
{
// check for any new client connecting
EthernetClient newClient = server1.available();
if(newClient>0)
{
client1 = newClient;
client1.println("connected with PMC");
Serial.println("client connected");
}
}
Serial.println("running");
}
The problem is, that the execution of the loop() stopps when I connect the client (tested with "running" message over Serial).