Logic Machine Forum
Modbus error handling - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Modbus error handling (/showthread.php?tid=3331)



Modbus error handling - JRP - 29.04.2021

Hello
I am delving into the use of Modbus in wiser and I am with profiling and memory mapping. For now everything is fine and above all easier with Daniel's profile manager.

The question is that now I would be interested to see how I handle the issue of modbus errors.

In the Modbus tab, by clicking on the error logs button, they appear in the pop-up window if there are errors in the communication. So my questions are:
  How can I access those errors?
With a script?
How many errors are there?
Could you assign them to alerts?

Thank you.
Greetings


RE: Modbus error handling - admin - 30.04.2021

Errors are stored in a separate DB table. There's no direct way of placing these error into alerts.
You can show them in the visualization via .lp file placed into an iframe. This will show a table with the latest 50 Modbus error logs:
Code:
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="/apps/css/bootstrap.css">
</head>
<body>
<table class="table table-striped">
<tr>
  <th>Date/time</th>
  <th>Error</th>
</tr>
<?
require('apps')

items = db:getall([[
  SELECT * FROM modbus_errors
  ORDER BY errortime DESC
  LIMIT 50
]])

for _, item in ipairs(items) do
  datetime = os.date('%Y.%m.%d %H:%M:%S', item.errortime)
?>
<tr>
  <td><?=datetime?></td>
  <td><?=escape(item.errortext)?></td>
</tr>
<? end ?>
</table>
</body>
</html>



RE: Modbus error handling - JRP - 30.04.2021

Hello
Thank you for the answer.
She thought it would be easier, but this solution is feasible.

Any document, thread or tutorial to learn how to use .lp files? I have read it several times in the forum but I do not know exactly how to use them.

Greetings


RE: Modbus error handling - admin - 30.04.2021

Save the file as modbus.lp, enable FTP server in System Config, connect via FTP by using apps username and upload modbus.lp file into user directory. Then you can access it via http://LM_IP/user/modbus.lp


RE: Modbus error handling - JRP - 30.04.2021

Hello

Very concise but perfect instructions, thank you.

I have placed the iframe in the visualization and in url I have put the indicated one, changing to the corresponding IP.

A frame is displayed with the date / time and error columns, but no records.

In the modbus tab if errors appear, in fact I have it active and mapped but the modbus device not connected, so the error in the image appears.

I have rebooted and the logs are not showing.
What could be happening?

Now that I think about it, I have not indicated that it is Modbus TCP, in case it is relevant.
Greetings






RE: Modbus error handling - Daniel - 30.04.2021

Try opening the url in browser.


RE: Modbus error handling - JRP - 30.04.2021

It also does not work as I tried it above.

Greetings


RE: Modbus error handling - Daniel - 30.04.2021

I tried the same and works fine for me. Paste URL you use.


RE: Modbus error handling - JRP - 30.04.2021

http://192.168.0.10/user/modbus.lp


RE: Modbus error handling - Daniel - 30.04.2021

This looks correct and what do you see when you open it? For frame inside same LM you can just use /user/modbus.lp


RE: Modbus error handling - JRP - 30.04.2021

Could it be a permission issue?



This is what i see



RE: Modbus error handling - Daniel - 30.04.2021

So the page is actually loading, I see this:
   


RE: Modbus error handling - JRP - 30.04.2021

The frame appears but is completely empty. IN the above post is the capture of what I see on the visualization.


RE: Modbus error handling - Daniel - 30.04.2021

Same for me, this is end visu. I have no more ideas. Admin?


RE: Modbus error handling - JRP - 30.04.2021

As the last test.

Can you send me the file, in case it is something relative to how I create it?


RE: Modbus error handling - Daniel - 30.04.2021

Here you go


RE: Modbus error handling - JRP - 30.04.2021

Eureka ¡¡¡It is the file.

Something incomprehensible, I have created it with Notepad ++ and put the extension, even with Visual Studio Code, thinking that the problem could come from that side. I have also tried with a text file changing the extension and nothing.
Will it be the extension? Although it seems silly, it is Lp (I put it in capital letters to distinguish it) not Ip, because of the source I will stop the same. Although I have tried both.
I am attaching my file in case you see the problem.

Thank you very much for your invaluable help.
Greetings


One more question.
What is the best configuration of the frame?
Persistence yes / no
Update time?

I notice that if the page is not reloaded, the records are not updated.
Greetings


RE: Modbus error handling - Daniel - 30.04.2021

I created it in notepad++ and just saved it directly from there and just typed the extension while saving .lp
You can set the refresh in some seconds for frame otherwise you will need to refresh manually.


RE: Modbus error handling - JRP - 03.05.2021

Well, it's exactly the same as I did, mysteries.
Ok with the settings.
Thank you very much for her help.
Greetings