[Gambas-user] Help for libmodbus TCP

bb adamnt42 at gmail.com
Fri Sep 23 09:24:18 CEST 2022


On Fri, 2022-09-23 at 08:16 +0200, fabien.toniutti at free.fr wrote:
> 
> Public Sub Button1_Click()
> Dim mb As Modbus_t()  
> '<--------------------------------------------------- error here
>    mb = New Modbus_new_tcp("127.0.0.1", 1502)
> End
> 
> but when i execute program, gambas says to me : unknown indetifier 
> Modbus_t() (where is arrow above)
> Could you explain me how to solve this problem?
> is already someone used to program modbus tcpip in gambas on the net?
> i 
> need example.
> Thanks a lot for  your answer.
> spheris
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

>From the Fine Help:
Sometimes an external function returns a pointer, and this pointer will
be required in order to invoke subsequent calls to the external
library. This case is much like creating a Form, and using its
reference to operate on the form itself. In this case, the data behind
(pointed by) the pointer is said to be "opaque": we can not see through
something opaque, so we don't know, and we don't want to know. This is
the simplest case; an example about this is the LDAP library. The first
thing to do to interact with LDAP is to open a connection to a server.
All the subsequent operations will be made on the connection created by
a specific call. Things go like this:

LIBRARY "libldap:2"
PRIVATE EXTERN ldap_init(host AS String, port AS Integer) AS Pointer
PRIVATE ldapconn as Pointer
...
ldapconn = ldap_init(host, 389)
IF ldapconn = NULL THEN error.Raise("Can not connect to the ldap
server")

 and from the Fine Help for libmodbus:

https://www.libmodbus.org/docs/v3.1.7/modbus_new_tcp.html

see especially what the function returns....

b



More information about the User mailing list