Menu

Errors: "Response CRC check failed", "No Response from Modbus Slave"

2017-08-24
2017-08-24
  • Kirill Rudenko

    Kirill Rudenko - 2017-08-24

    Hi. When using your library v4.3 during request of data very often there are two mistakes, namely "Response CRC check failed" and "No Response from Modbus Slave". These mistakes arise during request of data in a cycle and prevent normal work of the program. Case of emergence of floating. I can start several times in a row performance of this cycle and it will take place successfully, but then will be interrupted from one of mistakes.

    And for purity of an experiment I have downloaded NModbus4 library and have checked her work. So it is stable all the work out. But your library in use was pleasant more and the most part of the program is already written. it wouldn't be desirable to remake. There are some reasons on the matter?

    for (int i = 0x8000; i < 0x80B8; i++)
    {
    modbusClient.ReadHoldingRegisters(i, 125);
    jrnCrashByteArr = jrnCrashByteArr.Concat(modbusClient.receiveData.Skip(skipBytes).Take(250).ToArray()).ToArray();
    }

     
    • Rossmann Engineering

      Hi,

      I will run some tests the next days and take care. I was working a lot on the ModbusRTU part and it could be that I missed an issue.

       
    • Rossmann Engineering

       
  • Kirill Rudenko

    Kirill Rudenko - 2017-08-29

    Hi, Rossmann Engineering!

    How would it say =) Ok. I have the following code:

            public async void JournalCrashUpdate()
            {
                var read_UZTS_rdbl_jrncrash = await Task.Run(() =>  Global.Instance.Read_UZTS_rdbl_jrncrash());
                if (read_UZTS_rdbl_jrncrash.Count != 0)
                {
                    UZTS_rdbl_jrncrash = read_UZTS_rdbl_jrncrash;
                }
            }
    
            public ObservableCollection<UZTS_rdbl_jrncrash> Read_UZTS_rdbl_jrncrash()
            {
                lock (locker)
                {
                    var uzts_rdbl_jrncrash = new ObservableCollection<UZTS_rdbl_jrncrash>();
                    var jrnCrashByteArr = new byte[0];
    
                    var stopWatch = new Stopwatch();
                    stopWatch.Start();
                    Debug.WriteLine("START:");
                    for (int startingAddress = 0x8000; startingAddress < 0x80B8; startingAddress++)
                    {
                        try
                        {
                            if (!Global.Instance.ModbusClient.Connected)
                                Global.Instance.ModbusClient.Connect();
    
                            Global.Instance.ModbusClient.ReadHoldingRegisters(startingAddress, 125);
    
                            jrnCrashByteArr = jrnCrashByteArr.Concat(Global.Instance.ModbusClient.receiveData.
                                Skip(3).
                                Take(250).
                                ToArray()).ToArray();
                        }
                        catch (Exception ex)
                        {
                            //MessageBox.Show(
                            //                String.Format("{0} {1} \nПереподключитесь к устройству и повторите попытку.\nЕсли не помогает - перезагрузите ВИБ.",
                            //                ex.Message,
                            //                ex.InnerException != null ? ex.InnerException.Message : String.Empty),
                            //                "Ошибка в Read_UZTS_rdbl_jrncrashAsync", MessageBoxButton.OK, MessageBoxImage.Error);
                            Debug.WriteLine(ex.Message);
                            startingAddress--;
                            Global.Instance.ModbusClient.Disconnect();
                        }
                    }
                    stopWatch.Stop();
                    TimeSpan ts = stopWatch.Elapsed;
                    Debug.WriteLine(String.Format("STOP: {0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds));
    
                    for (int i = 0, startIndex = 0; i < 1000; i++, startIndex += 46)
                    {
                            uzts_rdbl_jrncrash.Add(new UZTS_rdbl_jrncrash()
                            {
                                Datatime_jrn = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(BitConverter.ToUInt32(jrnCrashByteArr, startIndex)),
                                Second = jrnCrashByteArr[startIndex + 4],
                                ...
                            });
                    }
                    return uzts_rdbl_jrncrash;
                }
            }
    

    In the new version of the V4.4Alpha library, there seem to be no errors, but the execution time is very long:

    START:
    The thread 0x4084 ended with code 0 (0x0).
    The thread 0x3f0 ended with code 0 (0x0).
    STOP: 00:04:47

    In the previous version of v4.3, these indicators were as follows:

    START:
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The thread 0x504 ended with code 0 (0x0).
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The stream 0x1a7c ended with code 0 (0x0).
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The 0x46e0 thread ended with code 0 (0x0).
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The 0x37dc thread ended with code 0 (0x0).
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The 0x1dac thread ended with code 0 (0x0).
    STOP: 00:00:14


    START:
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The stream 0x1810 ended with code 0 (0x0).
    STOP: 00:00:09


    START:
    Вызвано исключение: "EasyModbus.Exceptions.CRCCheckFailedException" в EasyModbus.dll
    Response CRC check failed
    Поток 0x170c завершился с кодом 0 (0x0).
    Вызвано исключение: "EasyModbus.Exceptions.CRCCheckFailedException" в EasyModbus.dll
    Response CRC check failed
    Поток 0x4720 завершился с кодом 0 (0x0).
    Вызвано исключение: "System.TimeoutException" в EasyModbus.dll
    No Response from Modbus Slave
    Поток 0x3ab0 завершился с кодом 0 (0x0).
    STOP: 00:00:11


    START:
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The stream 0x34e8 ended with code 0 (0x0).
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The thread 0x3654 ended with code 0 (0x0).
    An exception is thrown: "System.TimeoutException" in EasyModbus.dll
    No Response from Modbus Slave
    The 0x3fdc thread ended with code 0 (0x0).
    STOP: 00:00:08

    In the NModbus4 library, the same code is executed for the next time and without errors:

    START:
    STOP: 00:00:01
    START:
    STOP: 00:00:01
    START:
    STOP: 00:00:01

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.