lammertb/libfins

any example

jjqcat opened this issue · 8 comments

Hi, I need one simple example to show how to call these functions when using , thanks

I can't use this library communicate with fins server... would you give me examples?

struct fins_cpudata_tp cpudata;
finslib_cpu_unit_data_read((fins_sys_tp*)_fins,&cpudata);

    after connected to PLC server, this function call return error

Without context (TCP/UDP), type of PLC, the commands to open the connection, error code, etc, it is guessing what is going wrong.

In general, it is a bad idea to use type casts in function calls because it disables the type checking logic of the compiler. Better is to use finslib_cpu_unit_data_read(_fins,&cpudata); If the compiler complains with this function call, the _fins parameter has probably the wrong type.

Oh, after call finslib_tcp_connect succeeded, fins_sys_tp's member plc_mode value is 0, then failed to call finslib_cpu_unit_data_read

the function finslib_tcp_connect return FINS_RETVAL_CLOSED_BY_REMOTE error, I don't know what's reason.

Which PLC model do you try to connect to? I will see if I have a comparable device here and create a piece of working example code.

I use one OMRON Fins virtual server, set plc_mode=2 and it works well.

Well, it looks like your issue is a hardware issue then, not a software issue. Hardware support is available as a paid service, not as a free service through github. I will close this issue now as being not a bug.