Author Topic: OmronFINSEthernet Driver, Detect if there is a communication error  (Read 1718 times)

TheColonel26

  • Newbie
  • *
  • Posts: 25
    • View Profile
What is the best way to detect if communications have stopped when using the OmronFINSEthernet Driver? It seems that when you are using subscriptions there are no exceptions thrown.

I am going to do some more investigation on this tomorrow, with a test app. I have the driver under several graph layers in my application I am working on so it is kinda hard to tell what is going on.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OmronFINSEthernet Driver, Detect if there is a communication error
« Reply #1 on: August 07, 2018, 09:15:54 PM »
Try adding an event handler for the ComError event. It should fire on errors and loss of communication.

TheColonel26

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: OmronFINSEthernet Driver, Detect if there is a communication error
« Reply #2 on: August 08, 2018, 06:15:11 PM »
Nope :( After I am connected I disconnect the Ethernet Cable and I get nothing. The event is never raised.

For the record, I am using version 3.9.9.16. I did comment out the log files writes in the driver class, because at one put I was thinking it was causing a crash on the Raspberry Pi, but I don't think it actually was. Other than that it should be untouched.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OmronFINSEthernet Driver, Detect if there is a communication error
« Reply #3 on: August 08, 2018, 06:51:35 PM »
You may want to try it with the latest version of 3.99.24

TheColonel26

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: OmronFINSEthernet Driver, Detect if there is a communication error
« Reply #4 on: September 13, 2018, 12:07:26 PM »
Alright Archie, sorry it took me a while to get back to this project.

I updated to Version 3.99y (which I think is the latest correct?)

the Com Error event is now firing however, it keeps passing this message back "DataStartIndex greater than data length", at least one occurrence of this is when I am doing an explicit write for example

Code: [Select]
startAddress = "W510.01";
dataToWrite = "1";
_FINsCom.Write(startAddress, dataToWrite);
it seems that the Write is successful and no exception is thrown, but the error event is fired. I also can't find where error event is raised in the Driver project so it must be in the closed source reference .dll? I did a search through the project with the message text but couldn't find it.


Also On a side note: I have noticed that when I write to a bit address the driver wants "0" or "1" however when I read a bit address, the driver now returns "True" or "False" can this be made consistent? I've had to create some workarounds in my code to address this.

EDIT: Actually now I am not sure when that even is fired it might be during an explicit Read.

« Last Edit: September 13, 2018, 12:27:26 PM by TheColonel26 »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OmronFINSEthernet Driver, Detect if there is a communication error
« Reply #5 on: September 13, 2018, 04:26:59 PM »
The error code results from a response packet that contains no data. It could be a success packet from the write command. I won't have access to an Omron PLC until next week to test it.

I will make the Writing accept True/False in the next release. In the mean time, you can modify FINSBaseCom.vb to do it. Go to line 570 and modify the code to this:
Code: [Select]
           '* Bit level writing clears bit 7
            Dim MemoryAreaCode As Byte = address.MemoryAreaCode
            If MemoryAreaCode > &H80 AndAlso address.BitsPerElement = 1 Then
                MemoryAreaCode -= CByte(&H80)

                '* Convert True/False to 1/0
                For index = 0 To dataToWrite.Length - 1
                    If dataToWrite(index).IndexOf("true", 0, dataToWrite(index).Length, StringComparison.CurrentCultureIgnoreCase) >= 0 Then
                        dataToWrite(index) = "1"
                    ElseIf dataToWrite(index).IndexOf("false", 0, dataToWrite(index).Length, StringComparison.CurrentCultureIgnoreCase) >= 0 Then
                        dataToWrite(index) = "0"
                    End If
                Next
            End If

TheColonel26

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: OmronFINSEthernet Driver, Detect if there is a communication error
« Reply #6 on: September 14, 2018, 08:04:00 AM »
Thank you Archie, Please let me know what you find.