SAPHIR - Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Gmodbus over TCP Server

Solved!
Go to solution

Wondering if anyone has a quick example implementation of this working.  The demo file works fine.

 

I am having issues getting the modbus server portion working.  Here are the steps I am taking in this order

 

Single run

I open the TCP Connection

I initialize the listener

 

In the loop

Then I take the listener_ID created and listen_for_connections with that ID

Then listen for requests

 

It seems to have an issue with the listener_ID created because that is the only variables I am taking into the "listen_for_connections"

 

 

 

Attached the error, initialize, and running code

 

Initialize Code

MB_Server_Initialize_Code.png

 

Running Code

 

MB_Server_running_Code.png

 

Error

 

MB_Server_Error.png

 

   

 

 

0 Kudos
Message 1 of 5
(2,504 Views)
Solution
Accepted by Trinity32244

Hi,

 

In the modbus server code, you must use the "Initialize Listener" and the "Listen Connections" functions (see attachment).

The port number must be connected to the first input of the function "Initialize listener"

 

Hope this helps!

 

Mathilde

Message 2 of 5
(2,472 Views)

I really appreciate the help and your example worked.  I can't figure out why when I try to organize it a little differently it stops working.  Looks like it gets hung up after the initialize listener.  I can work around it since you helped me get the basic connection code but have other reasons for organizing it this way and can't see the difference between what you sent and the execution of the other code.  Thanks again in advance

Download All
0 Kudos
Message 3 of 5
(2,466 Views)

The second case structure must be executed after the first, otherwise the local variable is not initialized.
In your code, the 2 structures are not sequenced.

0 Kudos
Message 4 of 5
(2,463 Views)

Thank you.  I did try that previously in my main code and did not work using a flat sequence structure wrapped around the case structures.  I revised this example to include as well and still gets hung up with error 56 like previously.

 

Trinity32244_0-1638289257678.png

 

Trinity32244_1-1638289318616.png

 

 

 

 

0 Kudos
Message 5 of 5
(2,459 Views)