Skip to main content

Utilities for OMRON FINS protocol

Project description

OmronFinsEthernet

Utility functions for FINS protocol used by omron's PLCs

This library can read and write memory area of PLC via FINS protocol. It is confirmed that this can work with NX series PLC.

Usage

Please refer to documents created by doxygen for the details. When you access structs' data in PLC, please set memory offset 'CJ' mode. And please notice that offset of structure is shown as number of bytes, on the other hand, the number of address is defined as number of 16bit segments. So, the address of data in a struct can be calculated by adding half number of the offset to the initial address of the struct.

It's a sample code.

import omronfins.finsudp as finsudp
from omronfins.finsudp import datadef

fins = finsudp.FinsUDP(0, 170)
ret = fins.open('192.168.2.13', 9600)  # Please change according to your PLC's address.
fins.set_destination(dst_net_addr=0, dst_node_num=13, dst_unit_addr=0)

# Writing a word to Extended memory area's address 0.
ret = fins.write_mem_area(datadef.EM0_WORD, 0, 0, 1, (20, datadef.USHORT))

# Reading a word from Extended memory area's address 0.
ret, value = fins.read_mem_area(datadef.EM0_WORD, 0, 0, 1, datadef.USHORT)
print(value)  # the value becomes '20'

# Writing four bits to Extended memory area's address 5.
ret = fins.write_mem_area(datadef.EM0_BIT, 5, 0, 4,
    [(1, datadef.BIT), (0, datadef.BIT), (1, datadef.BIT), (0, datadef.BIT)])

# Reading four bits from Extended memory area's address 5.
ret, values = fins.read_mem_area(datadef.EM0_BIT, 5, 0, 4, datadef.BIT)
print(values)  # values become a tuple like (1, 0, 1, 0).

# Writing a string to Extended memory area's address 6.
# Fourth argument '4' means size of 16bit element and it becomes half of length of the string.
ret = fins.write_mem_area(datadef.EM0_WORD, 6, 0, 4, ("testtest", datadef.STR))

# Reading a string from Extended memory area's address 6.
ret, value = fins.read_mem_area(datadef.EM0_WORD, 6, 0, 4, datadef.STR)
print(value)  # value become "testtest"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omronfins-1.0.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omronfins-1.0.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file omronfins-1.0.3.tar.gz.

File metadata

  • Download URL: omronfins-1.0.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for omronfins-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d90217d6701caeec071619d4bd772d48ebc5fd3c2bd01f8cda071ec4ffde3b26
MD5 63531fe03097013bff5a04bf2ff4ae1c
BLAKE2b-256 c4de47577514fa0f281daccde8c8b24f63402c1d200e032f3f122843055d5eb9

See more details on using hashes here.

File details

Details for the file omronfins-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: omronfins-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for omronfins-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ec14e1b2be2721d03b9709ec096f281bac6a40d097521fe28a49e67b276863fe
MD5 94d36c212de737779d037b5aa7d2b4cc
BLAKE2b-256 4b004681f8c79bf1fd1b20ffa1ba33aeef7db78f57bca8b9f8ad70b6a6483319

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page