Writing to String Table using .NET Controller SDK Error

Good day.
Hope anyone can assist me.

I and using the .NET Controller SDK and is experiencing an error when I try to write to a string table only.

  1. I can connect to the EPIC successfully
  2. I can read from integer variables successfully
  3. I can write to integer variables successfully
  4. I can read from string variables successfully
  5. I can write to string variables successfully
  6. I can read from string tables successfully

BUT I cannot write to a string table using “controller.WriteStringTable()”

This returns a “CommunicationError” message and then I have to disconnect and reconnect from the controller before I can communicate with it at all after this error.

To me it seems to be an SDK error.

Welcome to the forums Gerhard.
Will need to check in with some engineers Monday morning California time to ask about that one.
I’ve never used the .NET stuff.

Thanks
Appreciate any help I can find.
This is the only thing holding by dev up.
Other than that the SDK is working great

Hi Gerhard,
I did a quick test and the write to string table works for me.
Here is the c# code in case you want to try it, but it is almost right out of the example provided with the SDK.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using PACController;

namespace OptoConsole
{
    internal class Program
    {
 
        static void Main(string[] args)
        {
               String sControllerIpAddress = "127.0.0.1";
            Int32 i32ControllerPort = 22001;
            Int32 i32InitialTimeoutMs = 1000;


            Console.WriteLine("Opto Console");

            Controller controller = new Controller();

            Controller.ErrorResponse eMethodResponse = controller.OpenSession(sControllerIpAddress, i32ControllerPort, i32InitialTimeoutMs);
            if (eMethodResponse != Controller.ErrorResponse.Success)
            {
                Console.WriteLine("OpenSession failed with ERROR {0}.", eMethodResponse);
                return;
            }
            else
            {
                
                Console.WriteLine("Opening connection to {0}:{1} succeeded", sControllerIpAddress, i32ControllerPort);
            }



            // read an integer

            eMethodResponse = controller.Read32BitIntegerVariable("flagCoverOff",  false, out int iStatus);
            if (eMethodResponse == Controller.ErrorResponse.Success)
            {
                Console.WriteLine("Read int32 flagCoverOff status returned value {0}.", iStatus);
            }
            else
            {
                Console.WriteLine("Read int32 flagCoverOff returned ERROR {0}.", eMethodResponse);
            }


            // Write String Table

            String[] saryTestValues = new String[100];
            saryTestValues[0] = "Testing Alarm0";
            saryTestValues[1] = "Testing Alarm1";


            eMethodResponse = controller.WriteStringTable("AlarmLog", false, saryTestValues, 0, 2);
            if (eMethodResponse == Controller.ErrorResponse.Success)
            {
                Console.WriteLine("Write  String table AlarmLog  status returned value {0}.", iStatus);
            }
            else
            {
                Console.WriteLine("Write iString table AlarmLog returned ERROR {0}.", eMethodResponse);
            }



        }
    }
}

1 Like

Thank you.

I’m doing the same which is weird and all other methods are working great.
Could you confirm if we are using the same version of the SDK?

My Version:
Library: Controller_Std_2_0
File version: 6.0.0.1
Product version: 1.0.0
Date: 03/02/2023 13:53
Dll runtime Version: v4.0.30319

1 Like

We are using the same version.

So just a few thoughts about what might be wrong…

  • the number of elements (if you shortened the number of elements to 1 will it work)
  • the size of the strings being written (could the strings be longer than the width of the string table variable)
  • the declaration of the string in the c# code

How about if you create a string table called AlarmLog with a width of 100 and length of 100 and try the WriteStringTable code that I have?

1 Like

My issue seems to have been network related…
All working fine now.

Strange that some calls worked.

Thank you all for input and assistance.

1 Like