Hi,
I'm sorry to keep asking you questions, but I am still having problems trying to get the PLC and the PC to communicate.
I have made all the changes that you have suggested and I even made a different c# program that concentrates on just trying to connect with the PLC.
I have researched on the forums, the internet, and have read documentations that Unitronics has provided and I still don't understand exactly what I am doing wrong.
I've tried using both TCP and UDP in the PLC to initiate the call to the PC but it doesn't connect.
I have included my VisiLogic program and c# program for references. I hope you can help and I appreciate any feedback. Thanks in advance.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Unitronics.ComDriver;
using Unitronics.ComDriver.Messages.DataRequest;
using System.Runtime.Remoting.Messaging;
using System.Reflection;
namespace Ethernet
{
public partial class Form1 : Form
{
private PLC plc;
const int LOCAL_PORT = 20260;
delegate void SetControlValueCallback(Control oControl, string propName, object propValue);
public Form1()
{
InitializeComponent();
Listener();
}
private void Listener()
{
try
{
EthernetListener listener = PLCFactory.GetChannel(LOCAL_PORT);
if (listener == null)
listener = new EthernetListener(LOCAL_PORT, 3, 3000);
listener.OnListenerConnectionAccepted += new EthernetListener.ListenerConnectionAcceptedDelegate(OnConnect);
PLCFactory.GetPLC(listener);
}
catch
{
MessageBox.Show("Could not connect");
}
}
private void OnConnect(PLC oPlc)
{
plc = oPlc;
MessageBox.Show("Connected");
}
}
}
TCP.vlp