├── obj └── README ├── examples ├── README └── obj │ └── README ├── lib └── README ├── .gitignore ├── cmake └── finsConfig.cmake.in ├── libfins.vcxproj.user ├── android ├── android.vcxproj.user └── android.sln ├── doc ├── fins_default.md ├── finslib_disconnect.md ├── fins_unitdata_tp.md ├── finslib_valid_directory.md ├── finslib_valid_filename.md ├── finslib_cycle_time_init.md ├── finslib_file_memory_format.md ├── finslib_milli_second_sleep.md ├── fins_force.md ├── finslib_clock_read.md ├── finslib_cycle_time_read.md ├── finslib_set_cpu_stop.md ├── finslib_cpu_unit_status_read.md ├── finslib_cpu_unit_data_read.md ├── finslib_access_right_forced_acquire.md ├── finslib_access_right_release.md ├── finslib_write_access_log_clear.md ├── finslib_set_cpu_run.md ├── finslib_monotonic_sec_timer.md ├── finslib_filename_to_83.md ├── fins_msg.md ├── finslib_program_area_clear.md ├── finslib_clock_write.md ├── finslib_forced_set_reset_cancel.md ├── finslib_access_right_acquire.md ├── finslib_parameter_area_clear.md ├── finslib_connection_data_read.md ├── fins_cpu_mode.md ├── finslib_error_clear_all.md ├── finslib_error_clear_current.md ├── finslib_error_log_clear.md ├── finslib_program_area_write.md ├── finslib_message_clear.md ├── finslib_raw.md ├── fins_cycletime_tp.md ├── finslib_area_file_compare.md ├── finslib_program_area_read.md ├── finslib_error_clear.md ├── finslib_error_clear_fal.md ├── finslib_error_clear_fals.md ├── finslib_area_to_file_transfer.md ├── finslib_file_to_area_transfer.md ├── finslib_access_log_read.md ├── finslib_message_fal_fals_read.md ├── fins_param_area.md ├── finslib_file_name_read.md ├── finslib_file_read.md ├── finslib_message_read.md ├── finslib_tcp_connect.md ├── finslib_file_write.md ├── finslib_error_log_read.md ├── finslib_errmsg.md ├── fins_multidata_tp.md ├── finslib_parameter_area_read.md ├── finslib_memory_area_fill.md ├── finslib_memory_area_transfer.md ├── finslib_memory_area_read_bit.md ├── finslib_memory_area_read_word.md ├── finslib_memory_area_write_bit.md ├── finslib_memory_area_write_word.md ├── finslib_parameter_area_write.md ├── fins_data_type.md ├── finslib_memory_area_read_int16.md ├── finslib_memory_area_read_int32.md ├── finslib_memory_area_read_uint16.md ├── finslib_memory_area_read_uint32.md ├── finslib_memory_area_read_bcd16.md ├── finslib_memory_area_read_bcd32.md ├── finslib_int_to_bcd.md ├── finslib_bcd_to_int.md ├── finslib_memory_area_write_int16.md ├── finslib_memory_area_write_int32.md ├── finslib_memory_area_write_uint16.md ├── finslib_memory_area_write_uint32.md ├── finslib_memory_area_write_bcd16.md ├── finslib_memory_area_write_bcd32.md ├── finslib_memory_area_read_sbcd16.md ├── fins_cpustatus_tp.md └── finslib_memory_area_read_sbcd32.md ├── LICENSE ├── libfins.sln ├── .github └── workflows │ ├── cmake-windows.yml │ ├── cmake.yml │ ├── cmake-macos.yml │ ├── msbuild-android.yml │ └── msbuild.yml ├── CMakeLists.txt └── src ├── fins_04_03.c ├── fins_26_02.c ├── fins_21_03.c ├── fins_21_41.c ├── fins_23_02.c ├── fins_04_02.c ├── fins_init.c ├── fins_0c_02.c ├── fins_0c_03.c ├── fins_06_20_init.c ├── fins_09_20_clear.c ├── fins_26_01.c ├── fins_04_01.c ├── fins_03_08.c ├── fins_26_03.c ├── fins_22_04.c ├── fins_raw.c ├── fins_0c_01.c ├── fins_09_20_fal.c ├── fins_02_03.c ├── fins_03_07.c ├── fins_09_20_read.c ├── fins_07_01.c └── fins_22_08.c /obj/README: -------------------------------------------------------------------------------- 1 | # 2 | # Directory for object files 3 | # 4 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | # 2 | # Directory for example files 3 | # 4 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | # 2 | # Directory for the library file 3 | # 4 | -------------------------------------------------------------------------------- /examples/obj/README: -------------------------------------------------------------------------------- 1 | # 2 | # Directory for object files 3 | # 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | make.exe 2 | *~ 3 | .*.swp 4 | obj/*.obj 5 | obj/*.o 6 | lib/*.lib 7 | lib/*.a 8 | x64 9 | Release 10 | build 11 | .vscode 12 | .vs 13 | -------------------------------------------------------------------------------- /cmake/finsConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") 3 | 4 | check_required_components("@PROJECT_NAME@") -------------------------------------------------------------------------------- /libfins.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/android.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /doc/fins_default.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### Default communication settings 4 | 5 | |Name|Description| 6 | |:---|:---| 7 | |**`FINS_DEFAULT_PORT`**|The default port number used by the FINS/TCP protocol| 8 | 9 | ### Description 10 | 11 | ### See Also 12 | 13 | * [`finslib_disconnect();`](finslib_disconnect.md) 14 | * [`finslib_tcp_connect();`](finslib_tcp_connect.md) 15 | -------------------------------------------------------------------------------- /doc/finslib_disconnect.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_disconnect( sys, ctime );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`ctime`**|`struct fins_cycletime_tp *`|A pointer to a structure where the cycle times must be stored| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`void`|This function does not return a value| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_tcp_connect();`](finslib_tcp_disconnect.md) 24 | -------------------------------------------------------------------------------- /doc/fins_unitdata_tp.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `struct fins_unitdata_tp;` 4 | 5 | ### Fields 6 | 7 | | Field | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`model`**|`char[21]`|The model name of the unit| 10 | |**`unit`**|`uint8_t`|The unit number of the unit| 11 | 12 | ### Description 13 | 14 | The structure `fins_unitdata_tp` is used to store the information of one special I/O unit in a PLC system when unit data is requested with a call to the [`finslib_connection_data_read()`](finslib_connection_data_read.md) function. 15 | 16 | ### See Also 17 | 18 | * [`finslib_connection_data_read();`](finslib_connection_data_read.md) 19 | * [`finslib_cpu_unit_data_read();`](finslib_cpu_unit_data_read.md) 20 | -------------------------------------------------------------------------------- /doc/finslib_valid_directory.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_valid_directory( path );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`path`**|`const char *`|The path to check| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`bool`|**`true`** when the provided directory name is a valid name| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_filename_to_83();`](finslib_filename_to_83.md) 23 | * [`finslib_file_memory_format();`](finslib_file_memory_format.md) 24 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 25 | -------------------------------------------------------------------------------- /doc/finslib_valid_filename.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_valid_filename( filename );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`filename`**|`const char *`|The filename to check| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`bool`|**`true`** when the provided file name is a valid filename| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_filename_to_83();`](finslib_filename_to_83.md) 23 | * [`finslib_file_memory_format();`](finslib_file_memory_format.md) 24 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 25 | -------------------------------------------------------------------------------- /doc/finslib_cycle_time_init.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_cycle_time_init( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_cycle_time_read();`](finslib_cycle_time_read.md) 23 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 24 | -------------------------------------------------------------------------------- /doc/finslib_file_memory_format.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_file_memory_format( sys, disk );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`disk`**|`uint16_t`|The disk in the remote PLC to format| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_file_name_read();`](finslib_file_name_read.md) 24 | -------------------------------------------------------------------------------- /doc/finslib_milli_second_sleep.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_milli_second_sleep( int msec );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`msec`**|`int`|The amount of milliseconds the current thread should be suspended. 10 | 11 | ### Return Value 12 | 13 | *none* 14 | 15 | ### Description 16 | 17 | The function `finslib_milli_second_sleep()` suspends the current thread for the amount of milliseconds specified. The accuracy of the sleep time depends on the operating system specific implementation and the amount of other threads and processes which compete for time slots. 18 | 19 | ### See Also 20 | 21 | * [`finslib_monotonic_sec_timer();`](finslib_monotonic_sec_timer.md) 22 | -------------------------------------------------------------------------------- /doc/fins_force.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### Bit force modes 4 | 5 | |Name|Description| 6 | |:---|:---| 7 | |**`FINS_FORCE_RELEASE_TO_OFF`**|The bit force must be released and the bit value is reset| 8 | |**`FINS_FORCE_RELEASE_TO_ON`**|The bit force must be released and the bit value is set| 9 | |**`FINS_FORCE_RELEASE`**|The bit force must be released and the bit value is unchanged| 10 | |**`FINS_FORCE_RESET`**|The bit status must be forced and the bit value is reset| 11 | |**`FINS_FORCE_SET`**|The bit status must be forced and the bit value is set| 12 | 13 | ### Description 14 | 15 | ### See Also 16 | 17 | * [`finslib_forced_set_reset_cancel();`](finslib_forced_set_reset_cancel.md) 18 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 19 | -------------------------------------------------------------------------------- /doc/finslib_clock_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_clock_read( sys, datetime );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`datetime`**|`struct fins_datetime_tp *`|Pointer to the memory location where the read date and time must be stored| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_clock_write();`](finslib_clock_write.md) 24 | -------------------------------------------------------------------------------- /doc/finslib_cycle_time_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_cycle_time_read( sys, ctime );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`ctime`**|`struct fins_cycletime_tp *`|A pointer to a structure where the cycle times must be stored| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_cycle_time_init();`](finslib_cycle_time_init.md) 24 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 25 | -------------------------------------------------------------------------------- /doc/finslib_set_cpu_stop.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_set_cpu_stop( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`FINS_CPU_MODE_...`](doc/fins_cpu_mode.md) – PLC CPU modes 23 | * [`finslib_set_cpu_run();`](finslib_set_cpu_run.md) 24 | * [`finslib_cycle_time_read();`](finslib_cycle_time_read.md) 25 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 26 | -------------------------------------------------------------------------------- /doc/finslib_cpu_unit_status_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_cpu_unit_status_read( sys, status );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`status`**|`struct fins_cpustatus_tp *`|A pointer to a structure where the CPU status must be stored| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_connection_data_read();`](finslib_connection_data_read.md) 24 | * [`finslib_cpu_unit_data_read();`](finslib_cpu_unit_data_read.md) 25 | -------------------------------------------------------------------------------- /doc/finslib_cpu_unit_data_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_cpu_unit_data_read( sys, cpudata );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`cpudata`**|`struct fins_cpudata_tp *`|A pointer to a structure where the CPU information must be stored| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_connection_data_read();`](finslib_connection_data_read.md) 24 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 25 | -------------------------------------------------------------------------------- /doc/finslib_access_right_forced_acquire.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_access_right_forced_acquire( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_access_log_read();`](finslib_access_log_read.md) 23 | * [`finslib_access_right_acquire();`](finslib_access_right_acquire.md) 24 | * [`finslib_access_right_release();`](finslib_access_right_release.md) 25 | * [`finslib_write_access_log_clear();`](finslib_write_access_log_clear.md) 26 | -------------------------------------------------------------------------------- /doc/finslib_access_right_release.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_access_right_release( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_access_log_read();`](finslib_access_log_read.md) 23 | * [`finslib_access_right_acquire();`](finslib_access_right_acquire.md) 24 | * [`finslib_access_right_forced_acquire();`](finslib_access_right_forced_acquire.md) 25 | * [`finslib_write_access_log_clear();`](finslib_write_access_log_clear.md) 26 | -------------------------------------------------------------------------------- /doc/finslib_write_access_log_clear.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_write_access_log_clear( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_access_log_read();`](finslib_access_log_read.md) 23 | * [`finslib_access_right_acquire();`](finslib_access_right_acquire.md) 24 | * [`finslib_access_right_forced_acquire();`](finslib_access_right_forced_acquire.md) 25 | * [`finslib_access_right_release();`](finslib_access_right_acquire.md) 26 | -------------------------------------------------------------------------------- /doc/finslib_set_cpu_run.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_set_cpu_run( sys, do_monitor );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`do_monitor`**|`bool`|**`true`** if the CPU should run in monitor mode| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`FINS_CPU_MODE_...`](doc/fins_cpu_mode.md) – PLC CPU modes 24 | * [`finslib_set_cpu_stop();`](finslib_set_cpu_stop.md) 25 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 26 | * [`finslib_cycle_time_read();`](finslib_cycle_time_read.md) 27 | -------------------------------------------------------------------------------- /doc/finslib_monotonic_sec_timer.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_monotonic_sec_timer( void );` 4 | 5 | ### Parameters 6 | 7 | *none* 8 | 9 | ### Return Value 10 | 11 | | Type | Description | 12 | | :--- | :--- | 13 | |`time_t`|A monotonic counter of the number of seconds which have passed since an unspecified starting point in time| 14 | 15 | ### Description 16 | 17 | The function `finslib_monotonic_sec_timer()` provides a seconds timer which is guaranteerd to be monotonic. This timer is therefore not directly bound to the internal wall clock. Due to this it is immune for changes in the clock settings and for changes in the time which happen during the transistion to and from daylight saving time. 18 | 19 | The return value is the amount of seconds since an unspecified moment. 20 | 21 | ### See Also 22 | 23 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 24 | * [`finslib_milli_second_sleep();`](finslib_milli_second_sleep.md) 25 | -------------------------------------------------------------------------------- /doc/finslib_filename_to_83.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_filename_to_83( infile, outfile );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`infile`**|`const char *`|The filename in human readable format| 10 | |**`outfile`**|`char *`|Location to store the to 8.3 format converted filename| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_file_name_read();`](finslib_file_name_read.md) 24 | * [`finslib_file_read();`](finslib_file_read.md) 25 | * [`finslib_file_write();`](finslib_file_write.md) 26 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 27 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 28 | -------------------------------------------------------------------------------- /doc/fins_msg.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### FINS user message masks 4 | 5 | |Name|Description| 6 | |:---|:---| 7 | |**`FINS_MSG_0`**|Bit mask indicating user program generated message MSG 0| 8 | |**`FINS_MSG_1`**|Bit mask indicating user program generated message MSG 1| 9 | |**`FINS_MSG_2`**|Bit mask indicating user program generated message MSG 2| 10 | |**`FINS_MSG_3`**|Bit mask indicating user program generated message MSG 3| 11 | |**`FINS_MSG_4`**|Bit mask indicating user program generated message MSG 4| 12 | |**`FINS_MSG_5`**|Bit mask indicating user program generated message MSG 5| 13 | |**`FINS_MSG_6`**|Bit mask indicating user program generated message MSG 6| 14 | |**`FINS_MSG_7`**|Bit mask indicating user program generated message MSG 7| 15 | |**`FINS_MSG_ALL`**|Bit mask indicating all user program generated messages| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`finslib_message_clear();`](finslib_message_clear.md) 22 | * [`finslib_message_read();`](finslib_message_read.md) 23 | -------------------------------------------------------------------------------- /doc/finslib_program_area_clear.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_program_area_clear( sys, do_interrupt_tasks );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`do_interrupt_tasks`**|`bool`|**`true`** if the interrupt tasks must be also cleared| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_memory_area_fill();`](finslib_memory_area_fill.md) 24 | * [`finslib_parameter_area_clear();`](finslib_parameter_area_clear.md) 25 | * [`finslib_program_area_read();`](finslib_program_area_read.md) 26 | * [`finslib_program_area_write();`](finslib_program_area_write.md) 27 | -------------------------------------------------------------------------------- /doc/finslib_clock_write.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_clock_write( sys, date_time, do_sec, do_dow );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`datetime`**|`struct fins_datetime_tp *`|A pointer to a structure with the data and time which must be transferred to the PLC| 11 | |**`do_sec`**|`bool`|**`true`** when the seconds on the remote PLC must also be set. 12 | |**`do_dow`**|`bool`|**`true`** when the day of the wak on the remote PLC must also be set. This parameter is only functional when `do_sec` is also set to **`true`**| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | ### See Also 23 | 24 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 25 | * [`finslib_clock_read();`](finslib_clock_read.md) 26 | -------------------------------------------------------------------------------- /doc/finslib_forced_set_reset_cancel.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_forced_set_reset_cancel( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`FINS_FORCE...`](fins_force.md) – Bit force mode list 23 | * [`finslib_memory_area_read_bit();`](finslib_memory_area_read_bit.md) 24 | * [`finslib_memory_area_read_word();`](finslib_memory_area_read_word.md) 25 | * [`finslib_memory_area_write_bit();`](finslib_memory_area_write_bit.md) 26 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 27 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 28 | -------------------------------------------------------------------------------- /doc/finslib_access_right_acquire.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_access_right_acquire( sys, nodedata );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`nodedata`**|`struct fins_nodedata_tp *`|Pointer to a memory location where the node information should be stored of another node when access is currently locked by that node| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_access_log_read();`](finslib_access_log_read.md) 24 | * [`finslib_access_right_forced_acquire();`](finslib_access_right_forced_acquire.md) 25 | * [`finslib_access_right_release();`](finslib_access_right_release.md) 26 | * [`finslib_write_access_log_clear();`](finslib_write_access_log_clear.md) 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2023 Lammert Bies 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /doc/finslib_parameter_area_clear.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_parameter_area_clear( sys, area_code, num_words );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`area_code`**|`uint16_t`|The area code in which data must be cleared| 11 | |**`num_words`**|`size_t`|The number of words that must be cleared in the parameter area| 12 | 13 | ### Return Value 14 | 15 | | Type | Description | 16 | | :--- | :--- | 17 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 18 | 19 | ### Description 20 | 21 | ### See Also 22 | 23 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 24 | * [`FINS_PARAM_AREA...`](fins_param_area.md) – CPU parameter area list 25 | * [`finslib_memory_area_fill();`](finslib_memory_area_fill.md) 26 | * [`finslib_parameter_area_read();`](finslib_parameter_area_read.md) 27 | * [`finslib_parameter_area_write();`](finslib_parameter_area_write.md) 28 | * [`finslib_program_area_clear();`](finslib_program_area.clear.md) 29 | -------------------------------------------------------------------------------- /doc/finslib_connection_data_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_connection_data_read( sys, unitdata, start_unit, num_units );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`unitdata`**|`struct fins_unitdata_tp *`|A pointer to the location where the unit data read from a remote PLC must be stored| 11 | |**`start_unit`**|`uint8_t`|The first unit from which the unit information should be read| 12 | |**`num_units`**|`size_t *`|The maximum number unit information blocks to return. At function return this contains the actual number of unit information blocks read| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | ### See Also 23 | 24 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 25 | * [`finslib_cpu_unit_data_read();`](finslib_cpu_unit_data_read.md) 26 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 27 | -------------------------------------------------------------------------------- /doc/fins_cpu_mode.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### PLC CPU modes 4 | 5 | | Name | Description | 6 | | :--- | :--- | 7 | |**`FINS_CPU_MODE_MONITOR`**|Status code indicating that the PLC CPU is in monitor mode| 8 | |**`FINS_CPU_MODE_PROGRAM`**|Status code indicating that the PLC CPU is in program mode| 9 | |**`FINS_CPU_MODE_RUN`**|Status code indicating that the PLC CPU is in run mode| 10 | 11 | ### Description 12 | 13 | The CPU of a PLC can be in different modes. It can be stopped, running or running with monitoring switched on. The functions [`finslib_set_cpu_run()`](finslib_set_cpu_run.md) and [`finslib_set_cpu_stop()`](finslib_set_cpu_stop.md) are used to change the current mode of the PLC. The current mode can be read with a call to [`finslib_cpu_unit_status_read()`](finsliv_cpu_unit_status_read.md). Where applicable, a constant from the range `FINS_CPU_MODE...` is used to set or read the CPU mode. 14 | 15 | ### See Also 16 | 17 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 18 | * [`finslib_cycle_time_read();`](finslib_cpu_cycle_time_read.md) 19 | * [`finslib_set_cpu_run();`](finslib_set_cpu_run.md) 20 | * [`finslib_set_cpu_stop();`](finslib_set_cpu_stop.md) 21 | -------------------------------------------------------------------------------- /doc/finslib_error_clear_all.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_clear_all( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_error_clear();`](finslib_error_clear.md) 23 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 24 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 25 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 26 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 27 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 28 | * [`finslib_message_clear();`](finslib_message_clear.md) 29 | * [`finslib_message_read();`](finslib_message_read.md) 30 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_error_clear_current.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_clear_current( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_error_clear();`](finslib_error_clear.md) 23 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 24 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 25 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 26 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 27 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 28 | * [`finslib_message_clear();`](finslib_message_clear.md) 29 | * [`finslib_message_read();`](finslib_message_read.md) 30 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_error_log_clear.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_log_clear( sys );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | 11 | ### Return Value 12 | 13 | | Type | Description | 14 | | :--- | :--- | 15 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 16 | 17 | ### Description 18 | 19 | ### See Also 20 | 21 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 22 | * [`finslib_error_clear();`](finslib_error_clear.md) 23 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 24 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 25 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 26 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 27 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 28 | * [`finslib_message_clear();`](finslib_message_clear.md) 29 | * [`finslib_message_read();`](finslib_message_read.md) 30 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_program_area_write.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_program_area_write( sys, data, start_word, num_bytes );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`data`**|`const unsigned char *`|Pointer to the buffer with data which must be written to the program area| 11 | |**`start_word`**|`uint32_t`|Offset in the program area where writing data must begin| 12 | |**`num_bytes`**|`size_t`|Number of bytes to write| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | ### See Also 23 | 24 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 25 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 26 | * [`finslib_parameter_area_write();`](finslib_parameter_area_write.md) 27 | * [`finslib_program_area_clear();`](finslib_program_area_clear.md) 28 | * [`finslib_program_area_read();`](finslib_program_area_read.md) 29 | -------------------------------------------------------------------------------- /doc/finslib_message_clear.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_message_clear( sys, msg_mask );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`msg_mask`**|`uint8_t`|Bit mask representing the messages to clear| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`FINS_MSG...`](fins_msg.md) – Message bit mask list 24 | * [`finslib_error_clear();`](finslib_error_clear.md) 25 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 26 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 27 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 28 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 29 | * [`finslib_message_read();`](finslib_message_read.md) 30 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_raw.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_raw( sys, command, buffer, send_len, recv_len );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`command`**|`uint16_t`|The command to execute over FINS on the remote PLC| 11 | |**`buffer`**|`unsigned char *`|Buffer which contains both the command body when invoking the function, and the return body when the function is finished| 12 | |**`send_len`**|`size_t`|The number of relevant bytes in the buffer when the function is invoked| 13 | |**`recv_len`**|`size_t *`|The size of the buffer when the function is invoked, and the size of the return body when the function is finished| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | ### See Also 24 | 25 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 26 | * [`finslib_disconnect();`](finslib_disconnect.md) 27 | * [`finslib_tcp_connect();`](finslib_tcp_connect.md) 28 | -------------------------------------------------------------------------------- /doc/fins_cycletime_tp.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `struct fins_cycletime_tp;` 4 | 5 | ### Fields 6 | 7 | | Field | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`avg`**|`uint32_t`|The average cycle time over the last eight cycles of the PLC. The time is expressed in units of 0.1 msec.| 10 | |**`max`**|`uint32_t`|The maximum cycle time of the PLC since the last cycle time reset. The time is expressed in units of 0.1 msec.| 11 | |**`min`**|`uint32_t`|The minimum cycle time of the PLC since the last cycle time reset. The time is expressed in units of 0.1 msec.| 12 | 13 | ### Description 14 | 15 | The structure `fins_cycletime_tp` is used by the function `finslib_cycle_time_read()` to store the minimum, average and maximum cycle times of the PLC. The average cycle time is calculated over the last eight cycles. Note that the values are in 0.1 millisecond increments. 16 | 17 | ### See Also 18 | 19 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 20 | * [`finslib_cycle_time_init();`](finslib_cycle_time_init.md) 21 | * [`finslib_cycle_time_read();`](finslib_cycle_time_read.md) 22 | * [`finslib_set_cpu_run();`](finslib_set_cpu_run.md) 23 | * [`finslib_set_cpu_stop();`](finslib_set_cpu_stop.md) 24 | -------------------------------------------------------------------------------- /doc/finslib_area_file_compare.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_area_file_compare( sys, start, disk, path, file, num_records );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|ASCII representation of the first memory word to compare| 11 | |**`disk`**|`uint16_t`|Disk where the file is located| 12 | |**`path`**|`const char *`|Subdirectory path of the file| 13 | |**`file`**|`const char *`|Name of the file| 14 | |**`num_records`**|`size_t *`|The number of records to compare| 15 | 16 | ### Return Value 17 | 18 | | Type | Description | 19 | | :--- | :--- | 20 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 21 | 22 | ### Description 23 | 24 | ### See Also 25 | 26 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 27 | * [`finslib_area_to_file_transfer();`](finslib_area_to_file_transfer.md) 28 | * [`finslib_file_to_area_transfer();`](finslib_file_to_area_transfer.md) 29 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 30 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_program_area_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_program_area_read( sys, data, start_word, num_bytes );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`data`**|`unsigned char *`|Pointer to the buffer where the retrieved data must be stored| 11 | |**`start_word`**|`uint32_t`|Offset in the program area where reading data must begin| 12 | |**`num_bytes`**|`size_t *`|The amount of bytes to read and if the function returns successfully the actual amount of bytes read| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | ### See Also 23 | 24 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 25 | * [`finslib_memory_area_read_word();`](finslib_memory_area_read_word.md) 26 | * [`finslib_parameter_area_read_word();`](finslib_parameter_area_read_word.md) 27 | * [`finslib_program_area_clear();`](finslib_program_area_clear.md) 28 | * [`finslib_program_area_write();`](finslib_program_area_write.md) 29 | -------------------------------------------------------------------------------- /doc/finslib_error_clear.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_clear( sys, error_code );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`error_code`**|`uint16_t`|The code of the error to be cleared| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_error_clear_all()`](finslib_error_clear_all.md) 24 | * [`finslib_error_clear_current()`](finslib_error_clear_current.md) 25 | * [`finslib_error_clear_fal()`](finslib_error_clear_fal.md) 26 | * [`finslib_error_clear_fals()`](finslib_error_clear_fals.md) 27 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 28 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 29 | * [`finslib_message_clear();`](finslib_message_clear.md) 30 | * [`finslib_message_read();`](finslib_message_read.md) 31 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 32 | -------------------------------------------------------------------------------- /doc/finslib_error_clear_fal.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_clear_fal( sys, fal_number );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`fal_number`**|`uint16_t`|The number of the FAL error to be cleared| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_error_clear();`](finslib_error_clear.md) 24 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 25 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 26 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 27 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 28 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 29 | * [`finslib_message_clear();`](finslib_message_clear.md) 30 | * [`finslib_message_read();`](finslib_message_read.md) 31 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 32 | -------------------------------------------------------------------------------- /doc/finslib_error_clear_fals.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_clear_fals( sys, fals_number );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`fals_number`**|`uint16_t`|The number of the FALS error to be cleared| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 17 | 18 | ### Description 19 | 20 | ### See Also 21 | 22 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 23 | * [`finslib_error_clear();`](finslib_error_clear.md) 24 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 25 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 26 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 27 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 28 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 29 | * [`finslib_message_clear();`](finslib_message_clear.md) 30 | * [`finslib_message_read();`](finslib_message_read.md) 31 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 32 | -------------------------------------------------------------------------------- /doc/finslib_area_to_file_transfer.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_area_to_file_transfer( sys, start, disk, path, file, num_records );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|ASCII representation of the start memory address| 11 | |**`disk`**|`uint16_t`|Disk where the file is located| 12 | |**`path`**|`const char *`|Sub directory path where the file is located| 13 | |**`file`**|`const char *`|Name of the file where the data must be written to| 14 | |**`num_records`**|`size_t *`|Number of records written to the file| 15 | 16 | ### Return Value 17 | 18 | | Type | Description | 19 | | :--- | :--- | 20 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 21 | 22 | ### Description 23 | 24 | ### See Also 25 | 26 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 27 | * [`finslib_area_file_compare();`](finslib_area_file_compare.md) 28 | * [`finslib_file_to_area_transfer();`](finslib_file_to_area_transfer.md) 29 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 30 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_file_to_area_transfer.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_file_to_area_transfer( sys, start, disk, path, file, num_records );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|ASCII representation of the starting memory address in the PLC where the file data should be stored| 11 | |**`disk`**|`uint16_t`|The disk where the source file is located| 12 | |**`path`**|`const char *`|The subdirectory where the source file is located| 13 | |**`file`**|`const char *`|The name of the source file| 14 | |**`num_records`**|`size_t *`|The number of records to transfer| 15 | 16 | ### Return Value 17 | 18 | | Type | Description | 19 | | :--- | :--- | 20 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 21 | 22 | ### Description 23 | 24 | ### See Also 25 | 26 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 27 | * [`finslib_area_file_compare();`](finslib_area_file_compare.md) 28 | * [`finslib_area_to_file_transfer();`](finslib_area_to_file_transfer.md) 29 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 30 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 31 | -------------------------------------------------------------------------------- /doc/finslib_access_log_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_access_log_read( sys, accessdata, start_record, num_records, stored_records );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`accessdata`**|`struct fins_accessdata_tp *`|Pointer to the buffer where the access data must be stored| 11 | |**`start_record`**|`uint16_t`|The first access record to retrieve| 12 | |**`num_records`**|`size_t`|The number of records to retrieve and at successful function return the actual number of records read| 13 | |**`stored_records`**|`size_t`|The total number of stored records| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | ### See Also 24 | 25 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 26 | * [`finslib_access_right_acquire();`](finslib_access_right_acquire.md) 27 | * [`finslib_access_right_forced_acquire();`](finslib_access_right_forced_acquire.md) 28 | * [`finslib_access_right_release();`](finslib_access_right_release.md) 29 | * [`finslib_write_access_log_clear();`](finslib_write_access_log_clear.md) 30 | -------------------------------------------------------------------------------- /doc/finslib_message_fal_fals_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_message_fal_fals_read( sys, faldata, fal_number );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`faldata`**|`char *`|Location where the FAL error information must be stored| 11 | |**`fal_number`**|`uint16_t`|The number of the FAL number for which the message must be read| 12 | 13 | ### Return Value 14 | 15 | | Type | Description | 16 | | :--- | :--- | 17 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 18 | 19 | ### Description 20 | 21 | ### See Also 22 | 23 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 24 | * [`finslib_error_clear();`](finslib_error_clear.md) 25 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 26 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 27 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 28 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 29 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 30 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 31 | * [`finslib_message_clear();`](finslib_message_clear.md) 32 | * [`finslib_message_read();`](finslib_message_read.md) 33 | -------------------------------------------------------------------------------- /doc/fins_param_area.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### PLC Parameter Areas 4 | 5 | | Name | Description | 6 | | :--- | :--- | 7 | |**`FINS_PARAM_AREA_ALL`**|Function affects all parameter areas| 8 | |**`FINS_PARAM_AREA_CPU_BUS_UNIT_SETUP`**|Area with setup information for CPU bus units| 9 | |**`FINS_PARAM_AREA_IO_TABLE_REGISTRATION`**|Area with I/O registration information| 10 | |**`FINS_PARAM_AREA_PLC_SETUP`**|Area with PLC setup information| 11 | |**`FINS_PARAM_AREA_ROUTING_TABLE`**|Area with the network routing table| 12 | 13 | ### Description 14 | 15 | An Omron PLC contains a number of parameter areas which store settings used for the functioning of the system and its environment, rather than for the functioning of the user programs themselves. These parameters store for example information about the units attached to the CPU and routing tables for networking. 16 | 17 | The parameter areas can be read and written over the FINS protocol. For each function call to a function which affects a parameter area, it is necessary to specify on which parameter area the activity should be performed. The constants `FINS_PARAM_AREA...` can be used to specify these areas. 18 | 19 | ### See Also 20 | 21 | * [`finslib_parameter_area_clear();`](finslib_parameter_area_clear.md) 22 | * [`finslib_parameter_area_read();`](finslib_parameter_area_read.md) 23 | * [`finslib_parameter_area_write();`](finslib_parameter_area_write.md) 24 | -------------------------------------------------------------------------------- /doc/finslib_file_name_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_file_name_read( sys, diskinfo, fileinfo, disk, path, start_file, num_files );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`diskinfo`**|`struct fins_diskinfo_tp *`|Pointer to the location where the disk information should be stored| 11 | |**`fileinfo`**|`struct fins_fileinfo_tp *`|Pointer to the location where the information of the files must be stored| 12 | |**`disk`**|`uint16_t`|The disk from which the information must be read| 13 | |**`path`**|`const char *path`|The subdirectory in which the files are located| 14 | |**`start_file`**|`size *`|The maximum number of files to read| 15 | 16 | ### Return Value 17 | 18 | | Type | Description | 19 | | :--- | :--- | 20 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 21 | 22 | ### Description 23 | 24 | ### See Also 25 | 26 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 27 | * [`finslib_filename_to_83();`](finslib_filename_to_83) 28 | * [`finslib_file_read();`](finslib_file_read.md) 29 | * [`finslib_file_write();`](finslib_file_write.md) 30 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 31 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 32 | -------------------------------------------------------------------------------- /doc/finslib_file_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_file_read( sys, disk, path, filename, data, file_position, num_bytes );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`disk`**|`uint16_t`|The disk on which the file is located| 11 | |**`path`**|`const char *`|The subdirectory in which the file is located| 12 | |**`filename`**|`const char *`|The name of the file| 13 | |**`data`**|`unsigned char *`|The buffer where the file contents must be stored| 14 | |**`file_position`**|`size_t`|The position in the file where reading should start| 15 | |**`num_bytes`**|`size_t *`|The amount of bytes requested and at function return the actual amount of bytes read| 16 | 17 | ### Return Value 18 | 19 | | Type | Description | 20 | | :--- | :--- | 21 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 22 | 23 | ### Description 24 | 25 | ### See Also 26 | 27 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 28 | * [`finslib_filename_to_83();`](finslib_filename_to_83.md) 29 | * [`finslib_file_name_read();`](finslib_file_name_read.md) 30 | * [`finslib_file_write();`](finslib_file_write.md) 31 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 32 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 33 | -------------------------------------------------------------------------------- /doc/finslib_message_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_message_read( sys, msgdata, msg_mask );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`msgdata`**|`struct fins_msgdata_tp *`|Pointer to the buffer where the message information should be stored| 11 | |**`msg_mask`**|`uint8_t`|Bit mask identifying the messages to be retrieved| 12 | 13 | ### Return Value 14 | 15 | | Type | Description | 16 | | :--- | :--- | 17 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 18 | 19 | ### Description 20 | 21 | ### See Also 22 | 23 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 24 | * [`FINS_MSG...`](fins_msg.md) – Message bit mask list 25 | * [`finslib_error_clear();`](finslib_error_clear.md) 26 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 27 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 28 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 29 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 30 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 31 | * [`finslib_error_log_read();`](finslib_error_log_read.md) 32 | * [`finslib_message_clear();`](finslib_message_read.md) 33 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 34 | -------------------------------------------------------------------------------- /doc/finslib_tcp_connect.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_tcp_connect( sys, address, port, local_net, local_node, local_unit, remote_net, remote_node, remote_unit, error_val, error_max );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`address`**|`const char *`|The IP address of the remote node| 11 | |**`port`**|`uint16_t`|The TCP port to communicate on| 12 | |**`local_net`**|`uint8_t`|The local network number| 13 | |**`local_node`**|`uint8_t`|The local node number| 14 | |**`local_unit`**|`uint8_t`|The local unit number| 15 | |**`remote_net`**|`uint8_t`|The remote network number| 16 | |**`remote_node`**|`uint8_t`|The remote node number| 17 | |**`remote_unit`**|`uint8_t`|The remote unit number| 18 | |**`error_val`**|`int *`|The error code if an error occured| 19 | |**`error_max`**|`int`|The maximum error code| 20 | 21 | ### Return Value 22 | 23 | | Type | Description | 24 | | :--- | :--- | 25 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 26 | 27 | ### Description 28 | 29 | ### See Also 30 | 31 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 32 | * [`FINS_DEFAULT...`](fins_default.md) – Libfins default communication settings 33 | * [`finslib_disconnect();`](finslib_disconnect.md) 34 | * [`finslib_raw();`](finslib_raw.md) 35 | -------------------------------------------------------------------------------- /doc/finslib_file_write.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_file_write( sys, disk, path, filename, data, file_position, num_bytes, open_mode );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`disk`**|`uint16_t`|The disk where the file is located| 11 | |**`path`**|`const char *`|The subdirectory where the file is located| 12 | |**`filename`**|`const char *`|The name of the file| 13 | |**`data`**|`const unsigned char *`|Pointer to the buffer with the data which must be written to the file| 14 | |**`file_position`**|`size_t`|The offset from the beginning of the file where data writing should start| 15 | |**`num_bytes`**|`size_t`|The number of bytes which must be written| 16 | |**`open_mode`**|`uint16_t`|The mode in which the file should be opened| 17 | 18 | ### Return Value 19 | 20 | | Type | Description | 21 | | :--- | :--- | 22 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 23 | 24 | ### Description 25 | 26 | ### See Also 27 | 28 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 29 | * [`finslib_filename_to_83();`](finslib_filename_to_83.md) 30 | * [`finslib_file_name_read();`](finslib_file_name_read.md) 31 | * [`finslib_file_read();`](finslib_file_read.md) 32 | * [`finslib_valid_directory();`](finslib_valid_directory.md) 33 | * [`finslib_valid_filename();`](finslib_valid_filename.md) 34 | -------------------------------------------------------------------------------- /libfins.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfins", "libfins.vcxproj", "{568F098E-992B-416A-B386-461CE7598E9D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {568F098E-992B-416A-B386-461CE7598E9D}.Debug|x64.ActiveCfg = Debug|x64 17 | {568F098E-992B-416A-B386-461CE7598E9D}.Debug|x64.Build.0 = Debug|x64 18 | {568F098E-992B-416A-B386-461CE7598E9D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {568F098E-992B-416A-B386-461CE7598E9D}.Debug|x86.Build.0 = Debug|Win32 20 | {568F098E-992B-416A-B386-461CE7598E9D}.Release|x64.ActiveCfg = Release|x64 21 | {568F098E-992B-416A-B386-461CE7598E9D}.Release|x64.Build.0 = Release|x64 22 | {568F098E-992B-416A-B386-461CE7598E9D}.Release|x86.ActiveCfg = Release|Win32 23 | {568F098E-992B-416A-B386-461CE7598E9D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {7B7509C4-0285-4A67-ACC2-6D271671A636} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /doc/finslib_error_log_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_error_log_read( sys, errordata, start_record, num_records, stored_records );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`errordata`**|`struct fins_errordata_tp *`|A pointer to a buffer where the error log data must be stored| 11 | |**`start_record`**|`uint16_t`|The first error log record to be retrieved| 12 | |**`num_records`**|`size_t *`|The number of records to retrieve| 13 | |**`stored_records`**|`size_t *`|The total number of stored records in the error log| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | ### See Also 24 | 25 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 26 | * [`finslib_error_clear();`](finslib_error_clear.md) 27 | * [`finslib_error_clear_all();`](finslib_error_clear_all.md) 28 | * [`finslib_error_clear_current();`](finslib_error_clear_current.md) 29 | * [`finslib_error_clear_fal();`](finslib_error_clear_fal.md) 30 | * [`finslib_error_clear_fals();`](finslib_error_clear_fals.md) 31 | * [`finslib_error_log_clear();`](finslib_error_log_clear.md) 32 | * [`finslib_message_clear();`](finslib_message_clear.md) 33 | * [`finslib_message_read();`](finslib_message_read.md) 34 | * [`finslib_message_fal_fals_read();`](finslib_message_fal_fals_read.md) 35 | -------------------------------------------------------------------------------- /.github/workflows/cmake-windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build: 15 | strategy: 16 | matrix: 17 | os: [windows-2022] 18 | # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. 19 | # You can convert this to a matrix build if you need cross-platform coverage. 20 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 21 | runs-on: ${{ matrix.os }} 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | 26 | - name: Configure CMake 27 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 28 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 29 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 30 | 31 | - name: Build 32 | # Build your program with the given configuration 33 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 34 | 35 | - name: Test 36 | working-directory: ${{github.workspace}}/build 37 | # Execute tests defined by the CMake configuration. 38 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 39 | run: ctest -C ${{env.BUILD_TYPE}} 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: Linux 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build: 15 | strategy: 16 | matrix: 17 | os: [ubuntu-20.04, ubuntu-22.04] 18 | # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. 19 | # You can convert this to a matrix build if you need cross-platform coverage. 20 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 21 | runs-on: ${{ matrix.os }} 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | 26 | - name: Configure CMake 27 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 28 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 29 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 30 | 31 | - name: Build 32 | # Build your program with the given configuration 33 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 34 | 35 | - name: Test 36 | working-directory: ${{github.workspace}}/build 37 | # Execute tests defined by the CMake configuration. 38 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 39 | run: ctest -C ${{env.BUILD_TYPE}} 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/cmake-macos.yml: -------------------------------------------------------------------------------- 1 | name: MacOS 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build: 15 | strategy: 16 | matrix: 17 | os: [macos-11, macos-12,macos-13] 18 | # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. 19 | # You can convert this to a matrix build if you need cross-platform coverage. 20 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 21 | runs-on: ${{ matrix.os }} 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | 26 | - name: Configure CMake 27 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 28 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 29 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 30 | 31 | - name: Build 32 | # Build your program with the given configuration 33 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 34 | 35 | - name: Test 36 | working-directory: ${{github.workspace}}/build 37 | # Execute tests defined by the CMake configuration. 38 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 39 | run: ctest -C ${{env.BUILD_TYPE}} 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/msbuild-android.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Android 7 | 8 | on: 9 | push: 10 | branches: [ "master" ] 11 | pull_request: 12 | branches: [ "master" ] 13 | 14 | env: 15 | # Path to the solution file relative to the root of the project. 16 | SOLUTION_FILE_PATH: android 17 | 18 | # Configuration type to build. 19 | # You can convert this to a build matrix if you need coverage of multiple configuration types. 20 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 21 | BUILD_CONFIGURATION: Release 22 | 23 | permissions: 24 | contents: read 25 | 26 | jobs: 27 | build: 28 | strategy: 29 | matrix: 30 | platform: [ARM, ARM64, x86, x64] 31 | runs-on: windows-latest 32 | 33 | steps: 34 | - uses: actions/checkout@v3 35 | 36 | - name: Add MSBuild to PATH 37 | uses: microsoft/setup-msbuild@v1.0.2 38 | 39 | - name: Restore NuGet packages 40 | working-directory: ${{env.GITHUB_WORKSPACE}} 41 | run: nuget restore ${{env.SOLUTION_FILE_PATH}} 42 | 43 | - name: Build 44 | working-directory: ${{env.GITHUB_WORKSPACE}} 45 | # Add additional options to the MSBuild command line here (like platform or verbosity level). 46 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference 47 | run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{ matrix.platform }} ${{env.SOLUTION_FILE_PATH}} 48 | -------------------------------------------------------------------------------- /.github/workflows/msbuild.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: MSBuild 7 | 8 | on: 9 | push: 10 | branches: [ "master" ] 11 | pull_request: 12 | branches: [ "master" ] 13 | 14 | env: 15 | # Path to the solution file relative to the root of the project. 16 | SOLUTION_FILE_PATH: . 17 | 18 | # Configuration type to build. 19 | # You can convert this to a build matrix if you need coverage of multiple configuration types. 20 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 21 | BUILD_CONFIGURATION: Release 22 | 23 | permissions: 24 | contents: read 25 | 26 | jobs: 27 | build: 28 | strategy: 29 | matrix: 30 | os: [windows-latest] 31 | platform: [x86, x64] 32 | runs-on: ${{ matrix.os }} 33 | 34 | steps: 35 | - uses: actions/checkout@v3 36 | 37 | - name: Add MSBuild to PATH 38 | uses: microsoft/setup-msbuild@v1.0.2 39 | 40 | - name: Restore NuGet packages 41 | working-directory: ${{env.GITHUB_WORKSPACE}} 42 | run: nuget restore ${{env.SOLUTION_FILE_PATH}} 43 | 44 | - name: Build 45 | working-directory: ${{env.GITHUB_WORKSPACE}} 46 | # Add additional options to the MSBuild command line here (like platform or verbosity level). 47 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference 48 | run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{ matrix.platform }} ${{env.SOLUTION_FILE_PATH}} 49 | -------------------------------------------------------------------------------- /doc/finslib_errmsg.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_errmsg( error_code, buffer, buffer_len );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`error_code`**|`int`|The return value of a FINS function which must be translated to a human readable error message. Valid error codes are one of the [`FINS_RETVAL_...`](fins_retval.md) values.| 10 | |**`buffer`**|`char *`|The buffer where the return string must be stored| 11 | |**`buffer_len`**|`size_t`|The amount of characters including the zero termination character of the string which can be stored in the buffer| 12 | 13 | ### Return Value 14 | 15 | | Type | Description | 16 | | :--- | :--- | 17 | |`const char *`|A pointer to the string message when successful, or NULL when an unrecoverable error occured| 18 | 19 | ### Description 20 | 21 | All functions in the library which have the option of failing return an integer return code. This code can either be an operating system error, an error returned from the remote peer over the FINS protocol, or an error which occured in the libfins library itself. The function `finslib_errmsg()` can be used to translate such an error number to a human readable string. 22 | 23 | If the function fails to provide an error message due to an internal problem like an unexisting string buffer, the function will return NULL. In all other cases the caller provided buffer will be filled with the appropriate error message and the function returns a pointer to the beginning of that buffer. In case the error code is unknown but the function doesn't fail due to an internal error, the text "Unknown error" is returned. 24 | 25 | ### See Also 26 | 27 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 28 | -------------------------------------------------------------------------------- /doc/fins_multidata_tp.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `struct fins_multidata_tp;` 4 | 5 | ### Fields 6 | 7 | | Field | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`address`**|`char[12]`|An ASCII representation of the starting address of the element. For example CIO20.1 or W100| 10 | |**`type`**|`int`|The type of the element to be retrieved. This is one of the [`FINS_MULTI_TYPE...`](FINS_MULTI_TYPE.md) values| 11 | |**`int16`**|`int16_t`|The returned element value if it is a signed 16 bit integer or signed 16 bit BCD| 12 | |**`int32`**|`int32_t`|The returned element value if it is a signed 32 bit integer or signed 32 bit BCD| 13 | |**`uint16`**|`uint16_t`|The returned element value if it is an unsigned 16 bit integer or unsigned 16 bit BCD| 14 | |**`uint32`**|`uint32_t`|The returned element value if it is an unsigned 32 bit integer or unsigned 32 bit BCD| 15 | |**`sfloat`**|`float`|The returned element value if it is a single precision 32 bit floating point| 16 | |**`dfloat`**|`double`|The returned element value if it is a double precision 64 bit floating point| 17 | |**`bit`**|`bool`|The returned element value if it is a bit| 18 | |**`b_force`**|`bool`|The forced status of a bit value if a bit with force status was requested| 19 | |**`word`**|`uint16_t`|The returned element value if an unmodified word was requested| 20 | |**`w_force`**|`uint16_t`|The forced status of the bits of an unmodified word if the force status was requested| 21 | 22 | ### Description 23 | 24 | The structure `fins_multidata_tp` is used by the function [`finslib_multiple_memory_area_read()`](finslib_multiple_memory_area_read.md) to retrieve one or more elements from one or more memory areas in a remote PLC. More information of the usage of this structure can be found in the documentation of that function. 25 | 26 | ### See Also 27 | 28 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 29 | -------------------------------------------------------------------------------- /doc/finslib_parameter_area_read.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_parameter_area_read( sys, area_code, data, start_word, num_words );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`area_code`**|`uint16_t`|The parameter area from which data must be read| 11 | |**`data`**|`uint16_t *`|Pointer to the buffer where the retrieved data must be stored| 12 | |**`start_word`**|`uint16_t`|Offset of the first wordt in the parameter area which must be read| 13 | |**`num_words`**|`size_t`|The number of words to be read from the parameter area| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | The function `finslib_parameter_area_read()` can be used to read data from a parameter area. The area to read must be selected with a [`FINS_PARAM_AREA...`](fins_param_area.md) parameter Also the start offset and number of words must be passed to the function as parameters. It is the responsibility of the calling function to ensure that the buffer which must contain the returned block of words is large enough. 24 | 25 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 26 | 27 | ### See Also 28 | 29 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 30 | * [`FINS_PARAM_AREA...`](fins_param_area.md) – CPU parameter area list 31 | * [`finslib_memory_area_read_word();`](finslib_memory_area_read_word.md) 32 | * [`finslib_parameter_area_clear();`](finslib_parameter_area_clear.md) 33 | * [`finslib_parameter_area_write();`](finslib_parameter_area_write.md) 34 | * [`finslib_program_area_read();`](finslib_program_area_read.md) 35 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_fill.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_fill( sys, start, fill_data, num_word );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to fill| 11 | |**`fill_data`**|`uint16_t`|A 16 bit word containing the data to be written to all the affected words in the remote PLC memory area| 12 | |**`num_word`**|`size_t`|The number of words to write| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the command| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_fill()` can be used to fill a block of 16 bit words in a memory area in a remote PLC with a fill word. The connection with the PLC should already be present before this function is called. 23 | 24 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 25 | 26 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case depending on the error message it is not sure if none, some or all of the data has been written to the PLC and additional processing and communication with the PLC may be necessary to know or set the correct state of the memory contents of the PLC. 27 | 28 | ### See Also 29 | 30 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 31 | * [`finslib_memory_area_transfer();`](finslib_memory_area_transfer.md) 32 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 33 | * [`finslib_parameter_area_clear();`](finslib_parameter_area_clear.md) 34 | * [`finslib_program_area_clear();`](finslib_program_area_clear.md) 35 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.25) 2 | 3 | project(fins LANGUAGES C VERSION 1.0) 4 | 5 | # compiler settings 6 | if(MSVC) 7 | set( 8 | COMPILER_C_FLAGS 9 | -Ot 10 | -GT 11 | -volatile:iso 12 | -nologo 13 | -J 14 | -sdl 15 | -W3 16 | -WX- 17 | -Wv:18 18 | ) 19 | else() 20 | set( 21 | COMPILER_C_FLAGS 22 | -Wall 23 | -Wstrict-prototypes 24 | -Wshadow 25 | -Wpointer-arith 26 | -Wcast-qual 27 | -Wcast-align 28 | -Wwrite-strings 29 | -Wnested-externs 30 | -Wredundant-decls 31 | -funsigned-char 32 | ) 33 | endif() 34 | 35 | # target 36 | file(GLOB_RECURSE LIB_SRCS src/*.c) 37 | file(GLOB_RECURSE LIB_HEADERS include/*.h) 38 | add_library(fins ${LIB_SRCS}) 39 | target_compile_options(fins PRIVATE "${COMPILER_C_FLAGS}") 40 | target_include_directories( 41 | fins PUBLIC 42 | $ 43 | $ 44 | ) 45 | set_target_properties( 46 | fins PROPERTIES 47 | PUBLIC_HEADER "${LIB_HEADERS}" 48 | LINKER_LANGUAGE C 49 | PREFIX lib 50 | ) 51 | 52 | # install logic 53 | install( 54 | TARGETS ${PROJECT_NAME} 55 | EXPORT "${PROJECT_NAME}Targets" 56 | RUNTIME DESTINATION bin 57 | LIBRARY DESTINATION lib 58 | ARCHIVE DESTINATION lib 59 | PUBLIC_HEADER DESTINATION include/fins 60 | ) 61 | 62 | include(CMakePackageConfigHelpers) 63 | configure_package_config_file( 64 | "${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in" 65 | "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" 66 | INSTALL_DESTINATION "share/${PROJECT_NAME}" 67 | ) 68 | 69 | write_basic_package_version_file( 70 | "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" 71 | VERSION "${PROJECT_VERSION}" 72 | COMPATIBILITY SameMajorVersion 73 | ) 74 | 75 | install( 76 | FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" 77 | "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" 78 | DESTINATION share/${PROJECT_NAME} 79 | ) 80 | 81 | install( 82 | EXPORT "${PROJECT_NAME}Targets" 83 | DESTINATION share/${PROJECT_NAME} 84 | NAMESPACE fins:: 85 | ) 86 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_transfer.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_memory_area_transfer( sys, source, dest, num_words );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`source`**|`const char *source`|ASCII representation of the source starting memory area address| 11 | |**`dest`**|`const char *dest`|ASCII representation of the destination starting memory area address| 12 | |**`num_words`**|`size_t`|The number of words to transfer 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_transfer()` can be used to transfer a block of data between two memory areas. The source and destination memory areas may be different which makes it possible to copy blocks of data from for example the `WR` area to the `DM` area. If a number of words of 0 is used, the function will return with a success code but there will be no data transfered. 23 | 24 | Writing to the or counter areas causes the completion flags of the affected timers and counters to be turned off. Note that this function can be called when the CPU is in running mode and that the system may be negatively effected by the memory transfer. The calling party should make sure that the memory transfer will not interfere with a running process or that the CPU is in stop mode, before `finslib_memory_area_transfer()` is called. 25 | 26 | ### See Also 27 | 28 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 29 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 30 | * [`finslib_area_to_file_transfer();`](finslib_area_to_file_transfer.md) 31 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 32 | * [`finslib_file_to_area_transfer();`](finslib_file_to_area_transfer.md) 33 | * [`finslib_memory_area_fill();`](finslib_memory_area_fill.md) 34 | * [`finslib_memory_area_read_word();`](finslib_memory_area_read_word.md) 35 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 36 | * [`finslib_set_cpu_stop();`](finslib_set_cpu_stop.md) 37 | -------------------------------------------------------------------------------- /android/android.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "android", "android.vcxproj", "{5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|ARM64 = Debug|ARM64 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|ARM = Release|ARM 15 | Release|ARM64 = Release|ARM64 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|ARM.ActiveCfg = Debug|ARM 21 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|ARM.Build.0 = Debug|ARM 22 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|ARM64.ActiveCfg = Debug|ARM64 23 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|ARM64.Build.0 = Debug|ARM64 24 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|x64.ActiveCfg = Debug|x64 25 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|x64.Build.0 = Debug|x64 26 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|x86.ActiveCfg = Debug|x86 27 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Debug|x86.Build.0 = Debug|x86 28 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|ARM.ActiveCfg = Release|ARM 29 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|ARM.Build.0 = Release|ARM 30 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|ARM64.ActiveCfg = Release|ARM64 31 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|ARM64.Build.0 = Release|ARM64 32 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|x64.ActiveCfg = Release|x64 33 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|x64.Build.0 = Release|x64 34 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|x86.ActiveCfg = Release|x86 35 | {5FA0FBB2-8E09-4ECB-A4D2-4B47E574428E}.Release|x86.Build.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {3134DE83-6B73-42E2-9C88-A4AB7AC2D347} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /src/fins_04_03.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_04_03.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_04_03.c contains routines to reset a SYSMAC NET 31 | * Link Unit over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_link_unit_reset( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_link_unit_reset() resets a SYSMAC NET LLink Unit 40 | * over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_link_unit_reset( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | 50 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 51 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 52 | 53 | XX_finslib_init_command( sys, & fins_cmnd, 0x04, 0x03 ); 54 | 55 | bodylen = 0; 56 | 57 | return XX_finslib_communicate( sys, & fins_cmnd, & bodylen, false ); 58 | 59 | } /* finslib_link_unit_reset */ 60 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_bit.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_bit( sys, start, data, num_bit );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`bool *`|Pointer to the buffer where the result must be stored| 12 | |**`num_bit`**|`size_t`|The number of bits to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_bit()` can be used to retrieve a block of bits from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_word()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20.0`** and **`W100.5`**. 27 | 28 | The requested number of bits is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_bit()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_forced_set_reset_cancel();`](finslib_forced_set_reset_cancel.md) 37 | * [`finslib_memory_area_read_word();`](finslib_memory_area_read_word.md) 38 | * [`finslib_memory_area_write_bit();`](finslib_memory_area_write_bit.md) 39 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 40 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 41 | -------------------------------------------------------------------------------- /src/fins_26_02.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_26_02.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_26_02.c contains routines to delete the name of a 31 | * SYSMAC NET Link Unit over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_name_delete( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_name_delete() deletes the name of a SYSMAC NET Link Unit 40 | * over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_name_delete( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x26, 0x02 ); 55 | 56 | bodylen = 0; 57 | 58 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 59 | 60 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 61 | 62 | return FINS_RETVAL_SUCCESS; 63 | 64 | } /* finslib_name_delete */ 65 | -------------------------------------------------------------------------------- /src/fins_21_03.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_21_03.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_21_03.c contains routines to clear the error log of 31 | * a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_error_log_clear( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_error_log_clear() clears the error log of a remote PLC 40 | * over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_error_log_clear( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x21, 0x03 ); 55 | 56 | bodylen = 0; 57 | 58 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 59 | 60 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 61 | 62 | return FINS_RETVAL_SUCCESS; 63 | 64 | } /* finslib_error_log_clear */ 65 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_word.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_word( sys, start, data, num_word );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`unsigned char *`|Pointer to the buffer where the result must be stored| 12 | |**`num_word`**|`size_t`|The number of words to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_word()` can be used to retrieve a block of 16 bit words from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. As this function returns a number of words, the size of the data buffer in bytes should be at least twice the number of words requested. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_word()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of words is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_word()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_bit();`](finslib_memory_area_read_bit.md) 37 | * [`finslib_memory_area_write_bit();`](finslib_memory_area_write_bit.md) 38 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 39 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 40 | -------------------------------------------------------------------------------- /src/fins_21_41.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_21_41.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_21_41.c contains routines to clear the write access 31 | * log of a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_write_access_log_clear( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_write_access_log_clear() clears the write access log of 40 | * a remote PLC over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_write_access_log_clear( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x21, 0x41 ); 55 | 56 | bodylen = 0; 57 | 58 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 59 | 60 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 61 | 62 | return FINS_RETVAL_SUCCESS; 63 | 64 | } /* finslib_write_access_log_clear */ 65 | -------------------------------------------------------------------------------- /src/fins_23_02.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_23_02.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_23_02.c contains routines to cancel all forced set 31 | * and reset bits in a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_forced_set_reset_cancel( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_forced_set_reset_cancel() cancels all forced bits in 40 | * a remote PLC over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_forced_set_reset_cancel( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x23, 0x02 ); 55 | 56 | bodylen = 0; 57 | 58 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 59 | 60 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 61 | 62 | return FINS_RETVAL_SUCCESS; 63 | 64 | } /* finslib_forced_set_reset_cancel */ 65 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_write_bit.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_write_bit( sys, start, data, num_bit );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to write| 11 | |**`data`**|`const bool *`|Pointer to the buffer where the data to be written is located| 12 | |**`num_bit`**|`size_t`|The number of bits to write| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the command| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_write_bit()` can be used to write a block of bits to a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the caller supplied buffer to the FINS data stream. Existence and filling of the dataspace is the responsibility of the calling function, but `finslib_memory_area_write_bit()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20.0`** and **`W100.5`**. 27 | 28 | The number of bits to be written in one function call is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_write_bit()` will automatically use multiple request at the FINS layer if the dataset is too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case depending on the error message it is not sure if none, some or all of the data has been written to the PLC and additional processing and communication with the PLC may be necessary to know or set the correct state of the memory contents of the PLC. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_forced_set_reset_cancel();`](finslib_forced_set_reset_cancel.md) 37 | * [`finslib_memory_area_read_bit();`](finslib_memory_area_read_bit.md) 38 | * [`finslib_memory_area_read_word();`](finslib_memory_area_write_bit.md) 39 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 40 | -------------------------------------------------------------------------------- /src/fins_04_02.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_04_02.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_04_02.c contains routines to stop the execution of 31 | * a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_set_cpu_stop( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_set_cpu_stop() stops the execution of a remote PLC with 40 | * a command over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_set_cpu_stop( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x04, 0x02 ); 55 | 56 | bodylen = 0; 57 | 58 | fins_cmnd.body[bodylen++] = 0xff; 59 | fins_cmnd.body[bodylen++] = 0xff; 60 | 61 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 62 | 63 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 64 | 65 | return FINS_RETVAL_SUCCESS; 66 | 67 | } /* finslib_set_cpu_stop */ 68 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_write_word.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_write_word( sys, start, data, num_word );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to write| 11 | |**`data`**|`const unsigned char *`|Pointer to the buffer where the data to be written is located| 12 | |**`num_word`**|`size_t`|The number of words to write| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the command| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_write_word()` can be used to write a block of 16 bit words to a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the caller supplied buffer to the FINS data stream. Existence and filling of the dataspace is the responsibility of the calling function, but `finslib_memory_area_write_word()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The number of words to be written in one function call is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_write_word()` will automatically use multiple request at the FINS layer if the dataset is too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case depending on the error message it is not sure if none, some or all of the data has been written to the PLC and additional processing and communication with the PLC may be necessary to know or set the correct state of the memory contents of the PLC. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_bit();`](finslib_memory_area_read_bit.md) 37 | * [`finslib_memory_area_read_word();`](finslib_memory_area_read_word.md) 38 | * [`finslib_memory_area_write_bit();`](finslib_memory_area_write_bit.md) 39 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 40 | -------------------------------------------------------------------------------- /src/fins_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_init.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_init.c contains routines to initialize the FINS 31 | * command structure of a message to be sent to a remote PLC over the Omron 32 | * FINS protocol. 33 | */ 34 | 35 | #include "fins.h" 36 | 37 | /* 38 | * void XX_finslib_init_command( fins_command_tp *command, uint8_t snn, uint8_t cnn ); 39 | * 40 | * The function XX_finslib_init_command() initializes a FINS command structure 41 | * which will be used to contain a command which is to be sent to a remote FINS 42 | * server like an Omron PLC. 43 | */ 44 | 45 | void XX_finslib_init_command( struct fins_sys_tp *sys, struct fins_command_tp *command, uint8_t mrc, uint8_t src ) { 46 | 47 | command->header[FINS_ICF] = 0x80; 48 | command->header[FINS_RSV] = 0x00; 49 | command->header[FINS_GCT] = 0x02; 50 | command->header[FINS_DNA] = sys->remote_net; 51 | command->header[FINS_DA1] = sys->remote_node; 52 | command->header[FINS_DA2] = sys->remote_unit; 53 | command->header[FINS_SNA] = sys->local_net; 54 | command->header[FINS_SA1] = sys->local_node; 55 | command->header[FINS_SA2] = sys->local_unit; 56 | command->header[FINS_SID] = sys->sid++; 57 | command->header[FINS_MRC] = mrc; 58 | command->header[FINS_SRC] = src; 59 | 60 | } /* XX_finslib_init_command */ 61 | -------------------------------------------------------------------------------- /doc/finslib_parameter_area_write.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_parameter_area_write( sys, area_code, data, start_word, num_words );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`area_code`**|`uint16_t`|The parameter area to which the data must be written| 11 | |**`data`**|`const uint16_t *`|Pointer to the buffer containing the data to be written to the parameter area| 12 | |**`start_word`**|`uint16_t`|Offset from the beginning of the parameter area where writing of this data must start| 13 | |**`num_words`**|`size_t`|Number of words to be written to the parameter area| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | The function `finslib_parameter_area_write()` writes a block of data to a parameter area of a remote PLC over FINS protocol. The area which must be written is provided as a parameter. Also the starting offset an number of words to write are parameters to the `finslib_parameter_area_write()` function. 24 | 25 | Note that all areas except for the routing table must be written in their entirety. 26 | 27 | The I/O registration table can only be written if the CPU is in program mode. When that area is written while the CPU is running or in monitor mode, `finslib_parameter_area_write()` will still return **`FINS_RETVAL_SUCCESS`** but nothing will be written to the area. It is the responsibility of the calling party to first ensure that the CPU is stopped before the I/O registration table is written. 28 | 29 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case depending on the error message it is not sure if none, some or all of the data has been written to the PLC and additional processing and communication with the PLC may be necessary to know or set the correct state of the parameter area memory contents of the PLC. 30 | 31 | ### See Also 32 | 33 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 34 | * [`FINS_PARAM_AREA...`](fins_param_area.md) – CPU parameter area list 35 | * [`finslib_memory_area_write_word();`](finslib_memory_area_write_word.md) 36 | * [`finslib_parameter_area_clear();`](finslib_parameter_area_clear.md) 37 | * [`finslib_parameter_area_read();`](finslib_parameter_area_read.md) 38 | * [`finslib_program_area_write();`](finslib_program_area_write.md) 39 | -------------------------------------------------------------------------------- /src/fins_0c_02.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_0c_02.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_0c_02.c contains routines to get forced access 31 | * rights to a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_access_right_forced_acquire( struct fins_sys_tp *sys ); 38 | * 39 | * The function fins_access_right_forced_acquire() tries to get forced access 40 | * to a remote PLC over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_access_right_forced_acquire( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x0c, 0x02 ); 55 | 56 | bodylen = 0; 57 | 58 | fins_cmnd.body[bodylen++] = 0xff; 59 | fins_cmnd.body[bodylen++] = 0xff; 60 | 61 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 62 | 63 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 64 | 65 | return FINS_RETVAL_SUCCESS; 66 | 67 | } /* finslib_access_right_forced_acquire */ 68 | -------------------------------------------------------------------------------- /src/fins_0c_03.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: sr/fins_0c_03.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_0c_03.c contains routines to release the access 31 | * rights to a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_access_right_release( struct fins_sys_tp *sys ); 38 | * 39 | * The function finslib_access_right_release() releases the access right to a 40 | * remote PLC over the FINS protocol which was previously acquired. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_access_right_release( struct fins_sys_tp *sys ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x0c, 0x03 ); 55 | 56 | bodylen = 0; 57 | 58 | fins_cmnd.body[bodylen++] = 0xff; 59 | fins_cmnd.body[bodylen++] = 0xff; 60 | 61 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 62 | 63 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 64 | 65 | return FINS_RETVAL_SUCCESS; 66 | 67 | } /* finslib_access_right_release */ 68 | -------------------------------------------------------------------------------- /src/fins_06_20_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_06_20.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_06_20.c contains the routines to perform the client 31 | * command 06 20 on FINS. This command is used to measure the minimum, average 32 | * and maximum cycle times of a remote PLC. 33 | */ 34 | 35 | #include "fins.h" 36 | 37 | /* 38 | * int finslib_cycle_time_init( fins_sys_tp *sys ); 39 | * 40 | * The function finslib_cycle_time_init() resets the minimum and maximum values 41 | * of the measured cycle time of the PLC. 42 | * 43 | * The function returns a success or error code from the list FINS_RETVAL_... 44 | */ 45 | 46 | int finslib_cycle_time_init( struct fins_sys_tp *sys ) { 47 | 48 | struct fins_command_tp fins_cmnd; 49 | int retval; 50 | size_t bodylen; 51 | 52 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 53 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 54 | 55 | XX_finslib_init_command( sys, & fins_cmnd, 0x06, 0x20 ); 56 | 57 | bodylen = 0; 58 | 59 | fins_cmnd.body[bodylen++] = 0x00; 60 | 61 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 62 | 63 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 64 | 65 | return FINS_RETVAL_SUCCESS; 66 | 67 | } /* finslib_cycle_time_init */ 68 | -------------------------------------------------------------------------------- /src/fins_09_20_clear.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_09_20_clear.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_09_20_clear.c contains routines to clear messages 31 | * from a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include 35 | #include "fins.h" 36 | 37 | /* 38 | * int finslib_message_clear( struct fins_sys_tp *sys, uint8_t msg_mask ); 39 | * 40 | * The function finslib_message_clear() clears messages from a remote PLC with 41 | * the FINS protocol. 42 | * 43 | * The function returns a success or error code from the list FINS_RETVAL_... 44 | */ 45 | 46 | int finslib_message_clear( struct fins_sys_tp *sys, uint8_t msg_mask ) { 47 | 48 | struct fins_command_tp fins_cmnd; 49 | size_t bodylen; 50 | int retval; 51 | 52 | if ( msg_mask == 0x00 ) return FINS_RETVAL_SUCCESS; 53 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 54 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 55 | 56 | XX_finslib_init_command( sys, & fins_cmnd, 0x09, 0x20 ); 57 | 58 | bodylen = 0; 59 | 60 | fins_cmnd.body[bodylen++] = 0x40; 61 | fins_cmnd.body[bodylen++] = msg_mask; 62 | 63 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 64 | 65 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 66 | 67 | return FINS_RETVAL_SUCCESS; 68 | 69 | } /* finslib_message_clear */ 70 | -------------------------------------------------------------------------------- /src/fins_26_01.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_26_01.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_26_01.c contains routines to set the name of a 31 | * SYSMAC NET Link Unit over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_name_set( struct fins_sys_tp *sys, const char *name ); 38 | * 39 | * The function finslib_name_set() sets the name of a SYSMAC NET Link Unit 40 | * over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_name_set( struct fins_sys_tp *sys, const char *name ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | if ( name == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 54 | 55 | XX_finslib_init_command( sys, & fins_cmnd, 0x26, 0x01 ); 56 | 57 | bodylen = 0; 58 | 59 | while ( bodylen < 8 && name[bodylen] != '\0' ) { 60 | 61 | fins_cmnd.body[bodylen] = name[bodylen]; 62 | bodylen++; 63 | } 64 | 65 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 66 | 67 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 68 | 69 | return FINS_RETVAL_SUCCESS; 70 | 71 | } /* finslib_name_set */ 72 | -------------------------------------------------------------------------------- /src/fins_04_01.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_04_01.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_04_01.c contains routines to change the mode of a 31 | * remote PLC to RUN mode over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_set_cpu_run( struct fins_sys_tp *sys, bool do_monitor ); 38 | * 39 | * The function finslib_set_cpu_run() starts the execution of the program in a 40 | * remote PLC. With a parameter monitor mode can be switched on. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_set_cpu_run( struct fins_sys_tp *sys, bool do_monitor ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 52 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 53 | 54 | XX_finslib_init_command( sys, & fins_cmnd, 0x04, 0x01 ); 55 | 56 | bodylen = 0; 57 | 58 | fins_cmnd.body[bodylen++] = 0xff; 59 | fins_cmnd.body[bodylen++] = 0xff; 60 | fins_cmnd.body[bodylen++] = (do_monitor) ? FINS_CPU_MODE_MONITOR : FINS_CPU_MODE_RUN; 61 | 62 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 63 | 64 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 65 | 66 | return FINS_RETVAL_SUCCESS; 67 | 68 | } /* finslib_set_cpu_run */ 69 | -------------------------------------------------------------------------------- /doc/fins_data_type.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### FINS data types 4 | 5 | |Name|Description| 6 | |:---|:---| 7 | |**`FINS_DATA_TYPE_BCD16`**|16 bit BCD between 0 and 9999| 8 | |**`FINS_DATA_TYPE_BCD32`**|32 bit BCD between 0 and 99999999| 9 | |**`FINS_DATA_TYPE_BIT`**|Single bit| 10 | |**`FINS_DATA_TYPE_BIT_FORCED`**|Single bit with it's forced status| 11 | |**`FINS_DATA_TYPE_DOUBLE`**|64 bit floating point in IEEE 754 format| 12 | |**`FINS_DATA_TYPE_FLOAT`**|32 bit floating point in IEEE 754 format| 13 | |**`FINS_DATA_TYPE_INT16`**|Signed 16 bit integer| 14 | |**`FINS_DATA_TYPE_INT32`**|Signed 32 bit integer| 15 | |**`FINS_DATA_TYPE_SBCD16_0`**|16 bit signed BCD type 0 between -999 and 999| 16 | |**`FINS_DATA_TYPE_SBCD16_1`**|16 bit signed BCD type 1 between -7999 and 7999| 17 | |**`FINS_DATA_TYPE_SBCD16_2`**|16 bit signed BCD type 2 between -999 and 9999| 18 | |**`FINS_DATA_TYPE_SBCD16_3`**|16 bit signed BCD type 3 between -1999 and 9999| 19 | |**`FINS_DATA_TYPE_SBCD32_0`**|32 bit signed BCD type 0 between -9999999 and 9999999| 20 | |**`FINS_DATA_TYPE_SBCD32_1`**|32 bit signed BCD type 1 between -79999999 and 79999999| 21 | |**`FINS_DATA_TYPE_SBCD32_2`**|32 bit signed BCD type 2 between -9999999 and 99999999| 22 | |**`FINS_DATA_TYPE_SBCD32_3`**|32 bit signed BCD type 3 between -19999999 and 99999999| 23 | |**`FINS_DATA_TYPE_UINT16`**|Unsigned 16 bit integer| 24 | |**`FINS_DATA_TYPE_UINT32`**|Unsigned 32 bit integer| 25 | |**`FINS_DATA_TYPE_WORD_FORCED`**|16 bit values with their forced status returned in four two 16 bit words| 26 | 27 | ### Description 28 | 29 | The basic data types in a PLC are 16 bit words and bits but several functions also support other data types which are then mapped in one or more adjacent 16 bit words. The LibFINS data read and write functions support all the data types the PLC recognizes and translates them directly to and from equivalent computer data types making the exchange of data of several types between the PLC and a computer an easy task. 30 | 31 | The constants `FINS_DATA_TYPE_...` are used in the call to [`finslib_multiple_memory_area_read()`](finslib_multiple_memory_area_read.md) and in calls which support signed binary BCD values to distinguish between the several different signed BCD implementations. 32 | 33 | ### See Also 34 | 35 | * [`finslib_bcd_to_int();`](finslib_bcd_to_int.md) 36 | * [`finslib_int_to_bcd();`](finslib_int_to_bcd.md) 37 | * [`finslib_memory_area_read_sbcd16();`](finslib_memory_area_read_sbcd16.md) 38 | * [`finslib_memory_area_read_sbcd32();`](finslib_memory_area_read_sbcd32.md) 39 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 40 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 41 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 42 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_int16.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_int16( sys, start, data, num_int16 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`int16_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_int16`**|`size_t`|The number of 16 bit signed integer values to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_int16()` can be used to retrieve a block of 16 bit signed integer values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_int16()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of signed integer values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_int16()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_int32();`](finslib_memory_area_read_int32.md) 37 | * [`finslib_memory_area_read_uint16();`](finslib_memory_area_read_uint16.md) 38 | * [`finslib_memory_area_read_uint32();`](finslib_memory_area_read_uint32.md) 39 | * [`finslib_memory_area_write_int16();`](finslib_memory_area_write_int16.md) 40 | * [`finslib_memory_area_write_int32();`](finslib_memory_area_write_int32.md) 41 | * [`finslib_memory_area_write_uint16();`](finslib_memory_area_write_uint16.md) 42 | * [`finslib_memory_area_write_uint32();`](finslib_memory_area_write_uint32.md) 43 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 44 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_int32.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_int32( sys, start, data, num_int32 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`int32_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_int32`**|`size_t`|The number of 32 bit signed integer values to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_int32()` can be used to retrieve a block of 32 bit signed integer values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_int32()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of signed integer values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_int32()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`fins_retval...`](fins_retval.md) – Libfins function return code list 35 | * [`fins_data_type...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_int16();`](finslib_memory_area_read_int16.md) 37 | * [`finslib_memory_area_read_uint16();`](finslib_memory_area_read_uint16.md) 38 | * [`finslib_memory_area_read_uint32();`](finslib_memory_area_read_uint32.md) 39 | * [`finslib_memory_area_write_int16();`](finslib_memory_area_write_int16.md) 40 | * [`finslib_memory_area_write_int32();`](finslib_memory_area_write_int32.md) 41 | * [`finslib_memory_area_write_uint16();`](finslib_memory_area_write_uint16.md) 42 | * [`finslib_memory_area_write_uint32();`](finslib_memory_area_write_uint32.md) 43 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 44 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_uint16.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_uint16( sys, start, data, num_uint16 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`uint16_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_uint16`**|`size_t`|The number of 16 bit unsigned integer values to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_uint16()` can be used to retrieve a block of 16 bit unsigned integer values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_uint16()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of unsigned integer values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_uint16()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_int16();`](finslib_memory_area_read_int16.md) 37 | * [`finslib_memory_area_read_int32();`](finslib_memory_area_read_int32.md) 38 | * [`finslib_memory_area_read_uint32();`](finslib_memory_area_read_uint32.md) 39 | * [`finslib_memory_area_write_int16();`](finslib_memory_area_write_int16.md) 40 | * [`finslib_memory_area_write_int32();`](finslib_memory_area_write_int32.md) 41 | * [`finslib_memory_area_write_uint16();`](finslib_memory_area_write_uint16.md) 42 | * [`finslib_memory_area_write_uint32();`](finslib_memory_area_write_uint32.md) 43 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 44 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_uint32.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_uint32( sys, start, data, num_uint32 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`uint32_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_uint32`**|`size_t`|The number of 32 bit unsigned integer values to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_uint32()` can be used to retrieve a block of 32 bit unsigned integer values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_uint32()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of unsigned integer values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_uint32()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_int16();`](finslib_memory_area_read_int16.md) 37 | * [`finslib_memory_area_read_int32();`](finslib_memory_area_read_int32.md) 38 | * [`finslib_memory_area_read_uint16();`](finslib_memory_area_read_uint16.md) 39 | * [`finslib_memory_area_write_int16();`](finslib_memory_area_write_int16.md) 40 | * [`finslib_memory_area_write_int32();`](finslib_memory_area_write_int32.md) 41 | * [`finslib_memory_area_write_uint16();`](finslib_memory_area_write_uint16.md) 42 | * [`finslib_memory_area_write_uint32();`](finslib_memory_area_write_uint32.md) 43 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 44 | -------------------------------------------------------------------------------- /src/fins_03_08.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_03_08.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_03_08.c contains routines to clear the program area 31 | * of a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_program_area_clear( struct fins_sys_tp *sys, bool do_interrupt_tasks ); 38 | * 39 | * The function finslib_program_area_clear() clears the program area of a remote 40 | * PLC with the FINS protocol from the beginning to the final program address. 41 | * If a parameter is set, also the interrupt tasks are cleared. 42 | * 43 | * The function returns a success or error code from the list FINS_RETVAL_... 44 | */ 45 | 46 | int finslib_program_area_clear( struct fins_sys_tp *sys, bool do_interrupt_tasks ) { 47 | 48 | struct fins_command_tp fins_cmnd; 49 | size_t bodylen; 50 | int retval; 51 | 52 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 53 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 54 | 55 | XX_finslib_init_command( sys, & fins_cmnd, 0x03, 0x08 ); 56 | 57 | bodylen = 0; 58 | 59 | fins_cmnd.body[bodylen++] = 0xff; 60 | fins_cmnd.body[bodylen++] = 0xff; 61 | fins_cmnd.body[bodylen++] = (do_interrupt_tasks) ? 0x10 : 0x00; 62 | 63 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 64 | 65 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 66 | 67 | return FINS_RETVAL_SUCCESS; 68 | 69 | } /* finslib_program_area_clear */ 70 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_bcd16.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_bcd16( sys, start, data, num_bcd16 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`uint16_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_bcd16`**|`size_t`|The number of 16 bit BCD values to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_bcd16()` can be used to retrieve a block of 16 bit unsigned BCD values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_bcd16()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of BCD values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_bcd16()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_bcd_to_int();`](finslib_bcd_to_int.md) 37 | * [`finslib_int_to_bcd();`](finslib_int_to_bcd.md) 38 | * [`finslib_memory_area_read_sbcd16();`](finslib_memory_area_read_sbcd16.md) 39 | * [`finslib_memory_area_read_bcd32();`](finslib_memory_area_read_bcd32.md) 40 | * [`finslib_memory_area_read_sbcd32();`](finslib_memory_area_read_sbcd32.md) 41 | * [`finslib_memory_area_write_bcd16();`](finslib_memory_area_write_bcd16.md) 42 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 43 | * [`finslib_memory_area_write_bcd32();`](finslib_memory_area_write_bcd32.md) 44 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 45 | * [`finslib_mutliple_memory_area_read();`](finslib_multiple_memory_area_read.md) 46 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_bcd32.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_read_bcd32( sys, start, data, num_bcd32 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`uint32_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_bcd32`**|`size_t`|The number of 32 bit BCD values to return| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_read_bcd32()` can be used to retrieve a block of 32 bit unsigned BCD values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_bcd32()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The requested number of BCD values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_bcd32()` will automatically use multiple request at the FINS layer if the dataset will be too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_bcd_to_int();`](finslib_bcd_to_int.md) 37 | * [`finslib_int_to_bcd();`](finslib_int_to_bcd.md) 38 | * [`finslib_memory_area_read_bcd16();`](finslib_memory_area_read_bcd16.md) 39 | * [`finslib_memory_area_read_sbcd16();`](finslib_memory_area_read_sbcd16.md) 40 | * [`finslib_memory_area_read_sbcd32();`](finslib_memory_area_read_sbcd32.md) 41 | * [`finslib_memory_area_write_bcd16();`](finslib_memory_area_write_bcd16.md) 42 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 43 | * [`finslib_memory_area_write_bcd32();`](finslib_memory_area_write_bcd32.md) 44 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 45 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 46 | -------------------------------------------------------------------------------- /src/fins_26_03.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_26_03.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_26_03.c contains routines to read the name of a 31 | * SYSMAC NET Link Unit over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_name_read( struct fins_sys_tp *sys, char *name_buffer, size_t name_buffer_len ); 38 | * 39 | * The function finslib_name_read() reads the name of a SYSMAC NET Link Unit 40 | * over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_name_read( struct fins_sys_tp *sys, char *name_buffer, size_t name_buffer_len ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | size_t a; 50 | int retval; 51 | 52 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 53 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 54 | if ( name_buffer == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 55 | if ( name_buffer_len < 9 ) return FINS_RETVAL_NO_DATA_BLOCK; 56 | 57 | XX_finslib_init_command( sys, & fins_cmnd, 0x26, 0x03 ); 58 | 59 | bodylen = 0; 60 | 61 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 62 | 63 | if ( bodylen < 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 64 | 65 | for (a=0; a<8 && a+2sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 54 | 55 | if ( disk != FINS_DISK_MEMORY_CARD && disk != FINS_DISK_EM_FILE_MEMORY ) return FINS_RETVAL_INVALID_DISK; 56 | 57 | XX_finslib_init_command( sys, & fins_cmnd, 0x22, 0x04 ); 58 | 59 | bodylen = 0; 60 | 61 | fins_cmnd.body[bodylen++] = (disk >> 8) & 0xff; 62 | fins_cmnd.body[bodylen++] = (disk ) & 0xff; 63 | 64 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 65 | 66 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 67 | 68 | return FINS_RETVAL_SUCCESS; 69 | 70 | } /* finslib_file_memory_format */ 71 | -------------------------------------------------------------------------------- /doc/finslib_int_to_bcd.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_int_to_bcd( value, type );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`value`**|`int32_t`|The value to convert from binary to BCD| 10 | |**`type`**|`int`|The type of binary to BCD conversion to perform| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`uint32_t`|The binary value converted to BCD or `INT16_MAX` or `INT32_MAX` if an error occured| 17 | 18 | ### Description 19 | 20 | The function `finslib_int_to_bcd()` can be used to convert a binary value to its BCD equivalent. The function can be used to convert 16 and 32 bit input values which may be either signed or unsigned. Signed BCD values can be encoded in four different ways. To guide the function in selecting the proper conversion protocol, a second parameter is provided which tells according to which conversion algorithm the conversion to a BCD value should take place. 21 | 22 | If the input parameter is out of range, the function returns `INT16_MAX` when a 16 bit conversion was requested and `INT32_MAX` otherwise. The following conversion types are supported by the function. 23 | 24 | |Type|Low|High|On error| 25 | |:---|---:|---:|:---:| 26 | |`FINS_DATA_TYPE_BCD16`|0|9999|`INT16_MAX`| 27 | |`FINS_DATA_TYPE_SBCD16_0`|-999|999|`INT16_MAX`| 28 | |`FINS_DATA_TYPE_SBCD16_1`|-7999|7999|`INT16_MAX`| 29 | |`FINS_DATA_TYPE_SBCD16_2`|-999|9999|`INT16_MAX`| 30 | |`FINS_DATA_RTPE_SBCD16_3`|-1999|9999|`INT16_MAX`| 31 | |`FINS_DATA_TYPE_BCD32`|0|99999999|`INT32_MAX`| 32 | |`FINS_DATA_TYPE_SBCD32_0`|-9999999|9999999|`INT32_MAX`| 33 | |`FINS_DATA_TYPE_SBCD32_1`|-79999999|79999999|`INT32_MAX`| 34 | |`FINS_DATA_TYPE_SBCD32_2`|-9999999|99999999|`INT32_MAX`| 35 | |`FINS_DATA_TYPE_SBCD32_3`|-19999999|99999999|`INT32_MAX`| 36 | |*all other*|0|-1|`INT32_MAX`| 37 | 38 | The types **0**, **1**, **2** and **3** are the encoding types as used in Omron PLCs by the functions **`BINS`** and **`BISL`**. More information can be found in the Omron instruction set manuals. 39 | 40 | ### See Also 41 | 42 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 43 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 44 | * [`finslib_bcd_to_int();`](finslib_bcd_to_int.md) 45 | * [`finslib_memory_area_read_bcd16();`](finslib_memory_area_read_bcd16.md) 46 | * [`finslib_memory_area_read_bcd32();`](finslib_memory_area_read_bcd32.md) 47 | * [`finslib_memory_area_read_sbcd16();`](finslib_memory_area_read_sbcd16.md) 48 | * [`finslib_memory_area_read_sbcd32();`](finslib_memory_area_read_sbcd32.md) 49 | * [`finslib_memory_area_write_bcd16();`](finslib_memory_area_write_bcd16.md) 50 | * [`finslib_memory_area_write_bcd32();`](finslib_memory_area_write_bcd32.md) 51 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 52 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 53 | -------------------------------------------------------------------------------- /doc/finslib_bcd_to_int.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_bcd_to_int( value, type );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`value`**|`uint32_t`|The BCD value which must be converted to binary| 10 | |**`type`**|`int`|The type of conversion to perform| 11 | 12 | ### Return Value 13 | 14 | | Type | Description | 15 | | :--- | :--- | 16 | |`int`|The value of the BCD parameter in binary, or `INT16_MAX` or `INT32_MAX` if the parameter was not a valid BCD value| 17 | 18 | ### Description 19 | 20 | The function `finslib_bcd_to_int()` can be used to convert a BCD value to its binary equivalent. The function can be used to convert 16 and 32 bit input values which may be either signed or unsigned. Signed BCD values can be encoded in four different ways. To guide the function in selecting the proper conversion protocol, a second parameter is provided which tells according to which conversion algorithm the conversion to a binary value should take place. 21 | 22 | If a parameter is provided which does not represent a valid BCD value, the function returns `INT16_MAX` when a 16 bit conversion was requested and `INT32_MAX` otherwise. The following conversion types are supported by the function. 23 | 24 | |Type|Low|High|On error| 25 | |:---|---:|---:|:---:| 26 | |`FINS_DATA_TYPE_BCD16`|0|9999|`INT16_MAX`| 27 | |`FINS_DATA_TYPE_SBCD16_0`|-999|999|`INT16_MAX`| 28 | |`FINS_DATA_TYPE_SBCD16_1`|-7999|7999|`INT16_MAX`| 29 | |`FINS_DATA_TYPE_SBCD16_2`|-999|9999|`INT16_MAX`| 30 | |`FINS_DATA_RTPE_SBCD16_3`|-1999|9999|`INT16_MAX`| 31 | |`FINS_DATA_TYPE_BCD32`|0|99999999|`INT32_MAX`| 32 | |`FINS_DATA_TYPE_SBCD32_0`|-9999999|9999999|`INT32_MAX`| 33 | |`FINS_DATA_TYPE_SBCD32_1`|-79999999|79999999|`INT32_MAX`| 34 | |`FINS_DATA_TYPE_SBCD32_2`|-9999999|99999999|`INT32_MAX`| 35 | |`FINS_DATA_TYPE_SBCD32_3`|-19999999|99999999|`INT32_MAX`| 36 | |*all other*|0|-1|`INT32_MAX`| 37 | 38 | The types **0**, **1**, **2** and **3** are the encoding types as used in Omron PLCs by the functions **`BINS`** and **`BISL`**. More information can be found in the Omron instruction set manuals. 39 | 40 | ### See Also 41 | 42 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 43 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 44 | * [`finslib_int_to_bcd();`](finslib_int_to_bcd.md) 45 | * [`finslib_memory_area_read_bcd16();`](finslib_memory_area_read_bcd16.md) 46 | * [`finslib_memory_area_read_bcd32();`](finslib_memory_area_read_bcd32.md) 47 | * [`finslib_memory_area_read_sbcd16();`](finslib_memory_area_read_sbcd16.md) 48 | * [`finslib_memory_area_read_sbcd32();`](finslib_memory_area_read_sbcd32.md) 49 | * [`finslib_memory_area_write_bcd16();`](finslib_memory_area_write_bcd16.md) 50 | * [`finslib_memory_area_write_bcd32();`](finslib_memory_area_write_bcd32.md) 51 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 52 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 53 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_write_int16.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_write_int16( sys, start, data, num_int16 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to write| 11 | |**`data`**|`const int16_t *`|Pointer to the buffer where the data to be written is located| 12 | |**`num_int16`**|`size_t`|The number of signed 16 bit integer values to write| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the command| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_write_int16()` can be used to write a block of signed 16 bit integer values to a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the caller supplied buffer to the FINS data stream. Existence and filling of the dataspace is the responsibility of the calling function, but `finslib_memory_area_write_int16()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The number of signed integer values to be written in one function call is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_write_int16()` will automatically use multiple request at the FINS layer if the dataset is too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case depending on the error message it is not sure if none, some or all of the data has been written to the PLC and additional processing and communication with the PLC may be necessary to know or set the correct state of the memory contents of the PLC. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_int16();`](finslib_memory_area_read_int16.md) 37 | * [`finslib_memory_area_read_int32();`](finslib_memory_area_read_int32.md) 38 | * [`finslib_memory_area_read_uint16();`](finslib_memory_area_read_uint16.md) 39 | * [`finslib_memory_area_read_uint32();`](finslib_memory_area_read_uint32.md) 40 | * [`finslib_memory_area_write_int32();`](finslib_memory_area_write_int32.md) 41 | * [`finslib_memory_area_write_uint16();`](finslib_memory_area_write_uint16.md) 42 | * [`finslib_memory_area_write_uint32();`](finslib_memory_area_write_uint32.md) 43 | * [`finslib_multiple_memory_area_read();`](finslib-multiple_memory_area_read.md) 44 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_write_int32.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `finslib_memory_area_write_int32( sys, start, data, num_int32 );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to write| 11 | |**`data`**|`const int32_t *`|Pointer to the buffer where the data to be written is located| 12 | |**`num_int32`**|`size_t`|The number of signed 32 bit integer values to write| 13 | 14 | ### Return Value 15 | 16 | | Type | Description | 17 | | :--- | :--- | 18 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the command| 19 | 20 | ### Description 21 | 22 | The function `finslib_memory_area_write_int32()` can be used to write a block of signed 32 bit integer values to a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 23 | 24 | Data is transferred unmodified from the caller supplied buffer to the FINS data stream. Existence and filling of the dataspace is the responsibility of the calling function, but `finslib_memory_area_write_int32()` will return an error if a NULL pointer is provided for data storage. 25 | 26 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 27 | 28 | The number of signed integer values to be written in one function call is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_write_int32()` will automatically use multiple request at the FINS layer if the dataset is too large. 29 | 30 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case depending on the error message it is not sure if none, some or all of the data has been written to the PLC and additional processing and communication with the PLC may be necessary to know or set the correct state of the memory contents of the PLC. 31 | 32 | ### See Also 33 | 34 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 35 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 36 | * [`finslib_memory_area_read_int16();`](finslib_memory_area_read_int16.md) 37 | * [`finslib_memory_area_read_int32();`](finslib_memory_area_read_int32.md) 38 | * [`finslib_memory_area_read_uint16();`](finslib_memory_area_read_uint16.md) 39 | * [`finslib_memory_area_read_uint32();`](finslib_memory_area_read_uint32.md) 40 | * [`finslib_memory_area_write_int16();`](finslib_memory_area_write_int16.md) 41 | * [`finslib_memory_area_write_uint16();`](finslib_memory_area_write_uint16.md) 42 | * [`finslib_memory_area_write_uint32();`](finslib_memory_area_write_uint16.md) 43 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 44 | -------------------------------------------------------------------------------- /src/fins_raw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_raw.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_raw.c contains routines to execute raw FINS 31 | * functions and store the result in a buffer for further processing. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_raw( struct fins_sys_tp *sys, uint16_t command, unsigned char *buffer, size_t send_len, size_t *recv_len ); 38 | * 39 | * The function finslib_raw() executes a FINS function and stores the result in 40 | * a caller provided buffer. 41 | */ 42 | 43 | int finslib_raw( struct fins_sys_tp *sys, uint16_t command, unsigned char *buffer, size_t send_len, size_t *recv_len ) { 44 | 45 | struct fins_command_tp fins_cmnd; 46 | size_t a; 47 | size_t bodylen; 48 | int retval; 49 | 50 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 51 | if ( buffer == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 52 | if ( recv_len == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 53 | if ( *recv_len < 1 ) return FINS_RETVAL_NO_DATA_BLOCK; 54 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 55 | 56 | XX_finslib_init_command( sys, & fins_cmnd, (command >> 8) & 0xff, command & 0xff ); 57 | 58 | bodylen = 0; 59 | 60 | for (a=0; a *recv_len ) return FINS_RETVAL_BODY_TOO_LONG; 65 | 66 | for (a=0; asockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 56 | 57 | XX_finslib_init_command( sys, & fins_cmnd, 0x0c, 0x01 ); 58 | 59 | bodylen = 0; 60 | 61 | fins_cmnd.body[bodylen++] = 0xff; 62 | fins_cmnd.body[bodylen++] = 0xff; 63 | 64 | retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ); 65 | 66 | if ( retval == FINS_RETVAL_ACCESS_NO_RIGHTS ) { 67 | 68 | bodylen = 2; 69 | 70 | nodedata->network = fins_cmnd.body[bodylen++]; 71 | nodedata->node = fins_cmnd.body[bodylen++]; 72 | nodedata->unit = fins_cmnd.body[bodylen++]; 73 | } 74 | 75 | return retval; 76 | 77 | } /* finslib_access_right acquire */ 78 | -------------------------------------------------------------------------------- /src/fins_09_20_fal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_09_20_fal.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_09_20_fal.c contains routines to read FAL or FALS 31 | * messages from a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include 35 | #include "fins.h" 36 | 37 | /* 38 | * int finslib_message_fal_fals_read( struct fins_sys_tp *sys, char *faldata, uint16_t fal_number ); 39 | * 40 | * The function finslib_message_fal_fals_read() reads a user program generated 41 | * failure message from the FAL or FALS command from a remote PLC using the 42 | * FINS protocol. 43 | * 44 | * The function returns a success or error code from the list FINS_RETVAL_... 45 | */ 46 | 47 | int finslib_message_fal_fals_read( struct fins_sys_tp *sys, char *faldata, uint16_t fal_number ) { 48 | 49 | struct fins_command_tp fins_cmnd; 50 | size_t bodylen; 51 | size_t a; 52 | int retval; 53 | 54 | if ( fal_number < 1 ) return FINS_RETVAL_NO_READ_ADDRESS; 55 | if ( fal_number > 511 ) return FINS_RETVAL_NO_READ_ADDRESS; 56 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 57 | if ( faldata == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 58 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 59 | 60 | XX_finslib_init_command( sys, & fins_cmnd, 0x09, 0x20 ); 61 | 62 | bodylen = 0; 63 | 64 | fins_cmnd.body[bodylen++] = 0x80 | ((fal_number >> 8) & 0x3f); 65 | fins_cmnd.body[bodylen++] = (fal_number ) & 0xff; 66 | 67 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 68 | 69 | if ( bodylen != 20 ) return FINS_RETVAL_BODY_TOO_SHORT; 70 | 71 | bodylen = 4; 72 | 73 | for (a=0; a<16; a++) faldata[a] = fins_cmnd.body[bodylen++]; 74 | 75 | while ( a > 0 && isspace( faldata[a-1] ) ) a--; 76 | faldata[a] = 0; 77 | 78 | return FINS_RETVAL_SUCCESS; 79 | 80 | } /* finslib_message_fal_fals_read */ 81 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_sbcd16.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_memory_area_read_sbcd16( sys, start, data, num_sbcd16, type );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`int16_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_sbcd16`**|`size_t`|The number of signed 16 bit BCD values to return| 13 | |**`type`**|`int`|The type of BCD conversion needed| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | The function `finslib_memory_area_read_sbcd16()` can be used to retrieve a block of 16 bit signed BCD values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 24 | 25 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_sbcd16()` will return an error if a NULL pointer is provided for data storage. 26 | 27 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 28 | 29 | The requested number of BCD values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_sbcd16()` will automatically use multiple request at the FINS layer if the dataset will be too large. 30 | 31 | The function supports the following four types of signed BCD formats. Please consult the Omron software manuals for more details about these formats. 32 | 33 | |Type|Low|High| 34 | |:---|---:|---:| 35 | |`FINS_DATA_TYPE_SBCD16_0`|-999|999| 36 | |`FINS_DATA_TYPE_SBCD16_1`|-7999|7999| 37 | |`FINS_DATA_TYPE_SBCD16_2`|-999|9999| 38 | |`FINS_DATA_TYPE_SBCD16_3`|-1999|9999| 39 | 40 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 41 | 42 | ### See Also 43 | 44 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 45 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 46 | * [`finslib_bcd_to_int();`](finslib_bcd_to_int.md) 47 | * [`finslib_int_to_bcd();`](finslib_int_to_bcd.md) 48 | * [`finslib_memory_area_read_bcd16();`](finslib_memory_area_read_bcd16.md) 49 | * [`finslib_memory_area_read_bcd32();`](finslib_memory_area_read_bcd32.md) 50 | * [`finslib_memory_area_read_sbcd32();`](finslib_memory_area_read_sbcd32.md) 51 | * [`finslib_memory_area_write_bcd16();`](finslib_memory_area_write_bcd16.md) 52 | * [`finslib_memory_area_write_bcd32();`](finslib_memory_area_write_bcd32.md) 53 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 54 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 55 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 56 | -------------------------------------------------------------------------------- /doc/fins_cpustatus_tp.md: -------------------------------------------------------------------------------- 1 | # Finslib API Reference 2 | 3 | ### `struct fins_cpustatus_tp;` 4 | 5 | ### Fields 6 | 7 | | Field | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`message_exists`**|`bool[8]`|An array of bits indicating if a user generated message is available| 10 | |**`running`**|`bool`|**`true`** if the CPU is currently running| 11 | |**`flash_writing`**|`bool`|**`true`** if the PLC is currently busy writing to flash memory| 12 | |**`battery_present`**|`bool`|**`true`** if a memory backup battery is present in the PLC| 13 | |**`standby`**|`bool`|**`true`** if the CPU is currently in standby mode| 14 | |**`fatal_memory_error`**|`bool`|**`true`** if a fatal memory error in the PLC occured| 15 | |**`fata_io_bus_error`**|`bool`|**`true`** if a fatal I/O bus error occured| 16 | |**`fata_duplication_error`**|`bool`|**`true`** if a fatal duplication error occured| 17 | |**`fatal_inner_board_error`**|`bool`|**`true`** if a fatal inner board error occured| 18 | |**`fatal_io_point_overflow`**|`bool`|**`true`** if a fatal I/O point overflow occured| 19 | |**`fatal_io_setting_error`**|`bool`|**`true`** if a fatal I/O setting error occured| 20 | |**`fatal_program_error`**|`bool`|**`true`** if a fatal program error occured| 21 | |**`fatal_cycle_time_error`**|`bool`|**`true`** if the PLC stopped due to a cycle time overflow| 22 | |**`fatal_fals_error`**|`bool`|**`true`** if the PLC stopped due to a user program generated FALS error| 23 | |**`fal_error`**|`bool`|**`true`** if the user program generated a non-fatal FAL error| 24 | |**`duplex_error`**|`bool`|**`true`** if a non-fatal duplex error occured| 25 | |**`interrupt_task_error`**|`bool`|**`true`** if a non-fatal interrupt task error occured| 26 | |**`basic_io_unit_error`**|`bool`|**`true`** if a non-fatal basic I/O unit error occured| 27 | |**`plc_setup_error`**|`bool`|**`true`** if a non-fatal PLC setup error occured| 28 | |**`io_verification_error`**|`bool`|**`true`** if a non-fatal I/O verification error occured| 29 | |**`inner_board_error`**|`bool`|**`true`** if a non-fatal inner board error occured| 30 | |**`cpu_bus_unit_error`**|`bool`|**`true`** if a non-fatal CPU bus unit error occured| 31 | |**`special_io_unit_error`**|`bool`|**`true`** if a non-fatal special I/O unit error occured| 32 | |**`sysmac_bus_error`**|`bool`|**`true`** if a non-fatal sysmac bus error occured| 33 | |**`battery_error`**|`bool`|**`true`** if a non-fatal battery error occured| 34 | |**`cs1_cpu_bus_unit_setting_error`**|`bool`|**`true`** if a non-fatal error occured in the settings of a CS1 CPU bus unit| 35 | |**`special_io_unit_setting_error`**|`bool`|**`true`** if a non-fatal error occured in the settings of a special I/O unit| 36 | |**`run_mode`**|`uint8_t`|The current operating mode of the CPU| 37 | |**`error_code`**|`uint16_t`|The active error code with the highest priority| 38 | |**`error_message`**|`char[17]`|The current active error message in ASCII text| 39 | 40 | ### Description 41 | 42 | The structure `fins_cpustatus_tp` is used to store the actual status of the CPU of a PLC when the function [`finslib_cpu_unit_status_read()`](finslib_cpu_unit_status.md) is called. The `run_mode` field can have one of the [`FINS_CPU_MODE...`](fins_cpu_mode.md) values. 43 | 44 | ### See Also 45 | 46 | * [`FINS_CPU_MODE_...`](fins_cpu_mode.md) – PLC CPU modes 47 | * [`finslib_cpu_unit_status_read();`](finslib_cpu_unit_status_read.md) 48 | -------------------------------------------------------------------------------- /doc/finslib_memory_area_read_sbcd32.md: -------------------------------------------------------------------------------- 1 | # Libfins API Reference 2 | 3 | ### `finslib_memory_area_read_sbcd32( sys, start, data, num_sbcd32, type );` 4 | 5 | ### Parameters 6 | 7 | | Parameter | Type | Description | 8 | | :--- | :--- | :--- | 9 | |**`sys`**|`struct fins_sys_tp *`|A pointer to a structure with the FINS context| 10 | |**`start`**|`const char *`|An ASCII string describing the first memory element to retrieve| 11 | |**`data`**|`int32_t *`|Pointer to the buffer where the result must be stored| 12 | |**`num_sbcd32`**|`size_t`|The number of signed 32 bit BCD values to return| 13 | |**`type`**|`int`|The type of BCD conversion needed| 14 | 15 | ### Return Value 16 | 17 | | Type | Description | 18 | | :--- | :--- | 19 | |`int`|A return value from the list [`FINS_RETVAL_...`](fins_retval.md) indicating the result of the query| 20 | 21 | ### Description 22 | 23 | The function `finslib_memory_area_read_sbcd32()` can be used to retrieve a block of 32 bit signed BCD values from a memory area in a remote PLC. The connection with the PLC should already be present before this function is called. 24 | 25 | Data is transferred unmodified from the FINS data stream to the caller supplied buffer. Enough dataspace is the responsibility of the calling function, but `finslib_memory_area_read_sbcd32()` will return an error if a NULL pointer is provided for data storage. 26 | 27 | The start of the memory area is provided as an ASCII string which represents the starting address in human readable format. Example formats are **`CIO20`** and **`W100`**. 28 | 29 | The requested number of BCD values is not limited by the amount of data a PLC can send in one FINS packet because `finslib_memory_area_read_sbcd32()` will automatically use multiple request at the FINS layer if the dataset will be too large. 30 | 31 | The function supports the following four types of signed BCD formats. Please consult the Omron software manuals for more details about these formats. 32 | 33 | |Type|Low|High| 34 | |:---|---:|---:| 35 | |`FINS_DATA_TYPE_SBCD32_0`|-9999999|9999999| 36 | |`FINS_DATA_TYPE_SBCD32_1`|-79999999|79999999| 37 | |`FINS_DATA_TYPE_SBCD32_2`|-9999999|99999999| 38 | |`FINS_DATA_TYPE_SBCD32_3`|-19999999|99999999| 39 | 40 | The return value is either **`FINS_RETVAL_SUCCESS`** when the function succeeded, or one of the other **`FINS_RETVAL_`** values if an error occurs. In the latter case the data in the return buffer is unreliable and should not be used. 41 | 42 | ### See Also 43 | 44 | * [`FINS_RETVAL...`](fins_retval.md) – Libfins function return code list 45 | * [`FINS_DATA_TYPE...`](fins_data_type.md) – Libfins data types 46 | * [`finslib_bcd_to_int();`](finslib_bcd_to_int.md) 47 | * [`finslib_int_to_bcd();`](finslib_int_to_bcd.md) 48 | * [`finslib_memory_area_read_bcd16();`](finslib_memory_area_read_bcd16.md) 49 | * [`finslib_memory_area_read_bcd32();`](finslib_memory_area_read_bcd32.md) 50 | * [`finslib_memory_area_read_sbcd16();`](finslib_memory_area_read_sbcd16.md) 51 | * [`finslib_memory_area_write_bcd16();`](finslib_memory_area_write_bcd16.md) 52 | * [`finslib_memory_area_write_bcd32();`](finslib_memory_area_write_bcd32.md) 53 | * [`finslib_memory_area_write_sbcd16();`](finslib_memory_area_write_sbcd16.md) 54 | * [`finslib_memory_area_write_sbcd32();`](finslib_memory_area_write_sbcd32.md) 55 | * [`finslib_multiple_memory_area_read();`](finslib_multiple_memory_area_read.md) 56 | -------------------------------------------------------------------------------- /src/fins_02_03.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_02_03.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_02_03.c contains routines to clear parts of the 31 | * parameter area of a remote PLC using the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_parameter_area_clear( struct fins_sys_tp *sys, uint16_t area_code, size_t num_words ); 38 | * 39 | * The function finslib_parameter_area_clear() clears part of the parameter 40 | * area of a remote PLC with the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_parameter_area_clear( struct fins_sys_tp *sys, uint16_t area_code, size_t num_words ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t bodylen; 49 | int retval; 50 | 51 | if ( num_words == 0 ) return FINS_RETVAL_SUCCESS; 52 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 53 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 54 | 55 | if ( area_code != FINS_PARAM_AREA_PLC_SETUP && 56 | area_code != FINS_PARAM_AREA_IO_TABLE_REGISTRATION && 57 | area_code != FINS_PARAM_AREA_ROUTING_TABLE && 58 | area_code != FINS_PARAM_AREA_CPU_BUS_UNIT_SETUP ) return FINS_RETVAL_INVALID_PARAMETER_AREA; 59 | 60 | XX_finslib_init_command( sys, & fins_cmnd, 0x02, 0x03 ); 61 | 62 | bodylen = 0; 63 | 64 | fins_cmnd.body[bodylen++] = (area_code >> 8) & 0xff; 65 | fins_cmnd.body[bodylen++] = (area_code ) & 0xff; 66 | fins_cmnd.body[bodylen++] = 0x00; 67 | fins_cmnd.body[bodylen++] = 0x00; 68 | fins_cmnd.body[bodylen++] = (num_words >> 8) & 0xff; 69 | fins_cmnd.body[bodylen++] = (num_words ) & 0xff; 70 | fins_cmnd.body[bodylen++] = 0x00; 71 | fins_cmnd.body[bodylen++] = 0x00; 72 | 73 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 74 | 75 | if ( bodylen != 2 ) return FINS_RETVAL_BODY_TOO_SHORT; 76 | 77 | return FINS_RETVAL_SUCCESS; 78 | 79 | } /* finslib_parameter_area_clear */ 80 | -------------------------------------------------------------------------------- /src/fins_03_07.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_03_07.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_03_07.c contains routines to write data to the 31 | * program area of a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_program_area_write( struct fins_sys_tp *sys, const unsigned char *data, uint32_t start_word, size_t num_bytes ); 38 | * 39 | * The function finslib_program_area_write() writes a block of data in the 40 | * program area of a remote PLC over the FINS protocol. 41 | * 42 | * The function returns a success or error code from the list FINS_RETVAL_... 43 | */ 44 | 45 | int finslib_program_area_write( struct fins_sys_tp *sys, const unsigned char *data, uint32_t start_word, size_t num_bytes ) { 46 | 47 | struct fins_command_tp fins_cmnd; 48 | size_t a; 49 | size_t bodylen; 50 | int retval; 51 | 52 | if ( num_bytes == 0 ) return FINS_RETVAL_SUCCESS; 53 | if ( num_bytes > 992 ) return FINS_RETVAL_BODY_TOO_LONG; 54 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 55 | if ( data == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 56 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 57 | 58 | XX_finslib_init_command( sys, & fins_cmnd, 0x03, 0x07 ); 59 | 60 | bodylen = 0; 61 | 62 | fins_cmnd.body[bodylen++] = 0xff; 63 | fins_cmnd.body[bodylen++] = 0xff; 64 | fins_cmnd.body[bodylen++] = (start_word >> 24) & 0xff; 65 | fins_cmnd.body[bodylen++] = (start_word >> 16) & 0xff; 66 | fins_cmnd.body[bodylen++] = (start_word >> 8) & 0xff; 67 | fins_cmnd.body[bodylen++] = (start_word ) & 0xff; 68 | fins_cmnd.body[bodylen++] = (num_bytes >> 8) & 0xff; 69 | fins_cmnd.body[bodylen++] = (num_bytes ) & 0xff; 70 | 71 | for (a=0; a 35 | #include "fins.h" 36 | 37 | static uint8_t mask_array[] = { FINS_MSG_0, FINS_MSG_1, FINS_MSG_2, FINS_MSG_3, FINS_MSG_4, FINS_MSG_5, FINS_MSG_6, FINS_MSG_7 }; 38 | 39 | /* 40 | * int finslib_message_read( struct fins_sys_tp *, struct fins_msgdata_tp *msgdata, uint8_t msg_mask ); 41 | * 42 | * The function finslib_message_read() reads messages from a remote PLC over 43 | * the FINS protocol. 44 | * 45 | * The function returns a success or error code from the list FINS_RETVAL_... 46 | */ 47 | 48 | int finslib_message_read( struct fins_sys_tp *sys, struct fins_msgdata_tp *msgdata, uint8_t msg_mask ) { 49 | 50 | struct fins_command_tp fins_cmnd; 51 | size_t a; 52 | size_t b; 53 | size_t msg_index; 54 | size_t bodylen; 55 | uint8_t recv_mask; 56 | int retval; 57 | 58 | if ( msg_mask == 0x00 ) return FINS_RETVAL_SUCCESS; 59 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 60 | if ( msgdata == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 61 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 62 | 63 | XX_finslib_init_command( sys, & fins_cmnd, 0x09, 0x20 ); 64 | 65 | bodylen = 0; 66 | 67 | fins_cmnd.body[bodylen++] = 0x00; 68 | fins_cmnd.body[bodylen++] = msg_mask; 69 | 70 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 71 | 72 | msg_index = 0; 73 | bodylen = 3; 74 | recv_mask = fins_cmnd.body[bodylen++]; 75 | 76 | for (a=0; a<8; a++) { 77 | 78 | if ( ! (recv_mask & mask_array[a]) ) continue; 79 | 80 | msgdata[msg_index].msg = mask_array[a]; 81 | for (b=0; b<32; b++) msgdata[msg_index].text[b] = fins_cmnd.body[bodylen++]; 82 | 83 | while ( b > 0 && isspace( msgdata[msg_index].text[b-1] ) ) b--; 84 | msgdata[msg_index].text[b] = 0; 85 | 86 | msg_index++; 87 | } 88 | 89 | return FINS_RETVAL_SUCCESS; 90 | 91 | } /* finslib_message_read */ 92 | -------------------------------------------------------------------------------- /src/fins_07_01.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_07_01.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_07_01.c contains the code to execute a FINS 07 01 31 | * command. This is the command to read the clock from a remote PLC. 32 | */ 33 | 34 | #include "fins.h" 35 | 36 | /* 37 | * int finslib_clock_read( fins_sys_tp *sys, fins_datetime_tp *datetime ); 38 | * 39 | * The function finslib_clock_read() reads the clock of a remotely connected PLC 40 | * and returns that information in a structure. The clock is read with the 41 | * FINS command 07 01. 42 | * 43 | * The function returns a success or error code from the list FINS_RETVAL_... 44 | */ 45 | 46 | int finslib_clock_read( struct fins_sys_tp *sys, struct fins_datetime_tp* datetime ) { 47 | 48 | struct fins_command_tp fins_cmnd; 49 | int retval; 50 | size_t bodylen; 51 | 52 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 53 | if ( datetime == NULL ) return FINS_RETVAL_NO_DATA_BLOCK; 54 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 55 | 56 | XX_finslib_init_command( sys, & fins_cmnd, 0x07, 0x01 ); 57 | 58 | bodylen = 0; 59 | 60 | if ( ( retval = XX_finslib_communicate( sys, & fins_cmnd, & bodylen, true ) ) != FINS_RETVAL_SUCCESS ) return retval; 61 | 62 | if ( bodylen != 9 ) return FINS_RETVAL_BODY_TOO_SHORT; 63 | 64 | bodylen = 2; 65 | 66 | datetime->year = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ) + 1900; 67 | datetime->month = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ); 68 | datetime->day = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ); 69 | datetime->hour = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ); 70 | datetime->min = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ); 71 | datetime->sec = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ); 72 | datetime->dow = finslib_bcd_to_int( fins_cmnd.body[bodylen++], FINS_DATA_TYPE_BCD16 ); 73 | 74 | if ( datetime->year < 1998 ) datetime->year += 100; 75 | 76 | return FINS_RETVAL_SUCCESS; 77 | 78 | } /* finslib_clock_read */ 79 | -------------------------------------------------------------------------------- /src/fins_22_08.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libfins 3 | * File: src/fins_22_08.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 2016-2019 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The source file src/fins_22_08.c contains routines to change the name of a 31 | * file in a remote PLC over the FINS protocol. 32 | */ 33 | 34 | #include 35 | #include "fins.h" 36 | 37 | int finslib_file_rename( struct fins_sys_tp *sys, uint16_t disk, const char *path, const char *ofile, const char *nfile ) { 38 | 39 | struct fins_command_tp fins_cmnd; 40 | size_t a; 41 | size_t dirlen; 42 | size_t bodylen; 43 | char filename_83[13]; 44 | int retval; 45 | 46 | if ( sys == NULL ) return FINS_RETVAL_NOT_INITIALIZED; 47 | if ( ofile == NULL ) return FINS_RETVAL_INVALID_FILENAME; 48 | if ( nfile == NULL ) return FINS_RETVAL_INVALID_FILENAME; 49 | if ( sys->sockfd == INVALID_SOCKET ) return FINS_RETVAL_NOT_CONNECTED; 50 | 51 | if ( disk != FINS_DISK_MEMORY_CARD && disk != FINS_DISK_EM_FILE_MEMORY ) return FINS_RETVAL_INVALID_DISK; 52 | if ( ! finslib_valid_directory( path ) ) return FINS_RETVAL_INVALID_PATH; 53 | 54 | if ( path == NULL ) dirlen = 0; 55 | else dirlen = strlen( path ); 56 | 57 | XX_finslib_init_command( sys, & fins_cmnd, 0x22, 0x08 ); 58 | 59 | bodylen = 0; 60 | 61 | fins_cmnd.body[bodylen++] = (disk >> 8) & 0xff; 62 | fins_cmnd.body[bodylen++] = (disk ) & 0xff; 63 | 64 | if ( ( retval = finslib_filename_to_83( ofile, filename_83 ) ) != FINS_RETVAL_SUCCESS ) return retval; 65 | for (a=0; a<12; a++) fins_cmnd.body[bodylen++] = filename_83[a]; 66 | 67 | if ( ( retval = finslib_filename_to_83( nfile, filename_83 ) ) != FINS_RETVAL_SUCCESS ) return retval; 68 | for (a=0; a<12; a++) fins_cmnd.body[bodylen++] = filename_83[a]; 69 | 70 | fins_cmnd.body[bodylen++] = (dirlen >> 8) & 0xff; 71 | fins_cmnd.body[bodylen++] = (dirlen ) & 0xff; 72 | 73 | for (a=0; a