Jump to content

hoseman

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by hoseman

  1. I am using the demo ComDriver code as follows:

    using System;
    using Unitronics.ComDriver;
    
    namespace Com_Drive_Net___Example
    {
    	class AccessClass
    	{
    		static PLC plc;
    
    		public static void Test (){
    
    			Ethernet eth = new Ethernet ("192.168.1.152", 20256, EthProtocol.TCP, 3, 3000);
    
    			try{
    				plc = PLCFactory.GetPLC(eth, 0);
    				plc.EventAbortCompleted+=new PLC.AbortCompletedDelegate(plc_EventAbortCompleted);
    			}catch(Exception e){
    				eth.Disconnect();
    				Console.WriteLine ("Error1:"+e.Message+"-->("+e.TargetSite+")"+e.StackTrace+"-->"+e.Source);
    			}
    			try{
    				Console.WriteLine(plc.Version.OPLCModel);
    				Console.WriteLine (plc.PlcName);
    				Console.WriteLine(eth.Connected);
    				Console.WriteLine(plc.UnitId);
    			}catch(Exception e){
    				eth.Disconnect();
    				Console.WriteLine ("Error2:"+e.Message+"-->("+e.TargetSite+")"+e.StackTrace);
    			}
    	
    			Console.Read ();
    		} 
    		public static void plc_EventAbortCompleted(){
    			Console.WriteLine ("dunno");
    		}
    	}
    }
    

    It is pretty much straight out of the book.  

     

    I continue to get the following error:

    Unhandled Exception:
    Unitronics.ComDriver.ComDriveExceptions: Cannot communicate with the PLC with the specified UnitID!
      at Unitronics.ComDriver.PLC..ctor (Int32 unitId, Unitronics.ComDriver.Channel channel, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 
      at Unitronics.ComDriver.PLCFactory.getPLC (Unitronics.ComDriver.Channel& channel, Int32 unitId, System.Boolean& isConnected, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: Unitronics.ComDriver.ComDriveExceptions: Cannot communicate with the PLC with the specified UnitID!
      at Unitronics.ComDriver.PLC..ctor (Int32 unitId, Unitronics.ComDriver.Channel channel, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 
      at Unitronics.ComDriver.PLCFactory.getPLC (Unitronics.ComDriver.Channel& channel, Int32 unitId, System.Boolean& isConnected, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 
    
    

    I have tried three different versions of Unitronics.ComDriver.dll, dated 7/26/15, 7/29/15 and compiled myself yesterday, 3/2/16.  Same error on everyone.  I am not a C# expert by no means, but I can't see what I might be doing wrong.

     

    We set the the PLC to TCP/slave and set its Socket 0 Port to 20256 (mostly in desperation)

     

    I'm not sure what to try next?

     

    Thanks

×
×
  • Create New...