Metadata-Version: 2.4
Name: kvhostlink-udp
Version: 0.1.2
Summary: KEYENCE HostLink UDP communication library
Author: Okita Systam Design
License: 
        ---
        
        # ■ ⑥ LICENSE（MIT）
        
        ```text
        MIT License
        
        Copyright (c) 2026 OkitaSystemDesign
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://osdes.com
Project-URL: Repository, https://github.com/OkitaSystemDesign/kvhostlink
Keywords: PLC,KEYENCE,HostLink,UDP,industrial
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# kvhostlink.py
KEYENCE HostLink Communication for UDP/IP

# Install
pip install kvhostlink-udp

# Constructor
kvhostlink(host, timeout)

# Functions
### mode(mode)
Change Mode  
0 = PROGRAM  
1 = RUN  
Retrun: EtherNet/IP Unit Response

### unittype()
Checks PLC model  
Retrun: EtherNet/IP Unit Response

### errclr()
Removes the error in CPU unit  
Retrun: EtherNet/IP Unit Response

### er()
Confirm Error No  
Retrun: EtherNet/IP Unit Response

### settime()
Set up time of the CPU unit  
Send the date and time of your computer
Retrun: EtherNet/IP Unit Response

### set(address)
Forced Set
address = R0-199915, B0-7FFF, MR0-399915, LR0-99915, CR0-7915, T0-3999, C0-3999, CTC0-3, VB0-F9FF  
Retrun: EtherNet/IP Unit Response

### reset(address)
Forced Reset  
address = R0-199915, B0-7FFF, MR0-399915, LR0-99915, CR0-7915, T0-3999, C0-3999, CTC0-3, VB0-F9FF  
Retrun: EtherNet/IP Unit Response

### sts(address)
Continuous Forced Set  
address = R0-199915, B0-7FFF, MR0-399915, LR0-99915, CR0-7915, VB0-F9FF  
num = number of written data  
Retrun: EtherNet/IP Unit Response

### rss(address, num)
Continuous Forced Reset  
address = R0-199915, B0-7FFF, MR0-399915, LR0-99915, CR0-7915, VB0-F9FF  
num = number of written data  
Retrun: EtherNet/IP Unit Response

### read(addresssuffix)
Data Read  
addresssuffix = DeviceType + DeviceNo + DataFormat  
 .e.g. MR0, DM0.U  
Return: EtherNet/IP Unit Response

### reads(addresssuffix, num)
Consecutive Data Read  
addresssuffix = DeviceType + DeviceNo + DataFormat  
 .e.g. MR0, DM0.U  
num = number of read data  
Return: EtherNet/IP Unit Response (Data1 + 0x20 + Data2 + 0x20 ...)  

### write(addresssuffix, data)
Write Data  
addresssuffix = DeviceType + DeviceNo + DataFormat  
 .e.g. MR0, DM0.U  
data = byte()  
Return: EtherNet/IP Unit Response

### writes(addresssuffix, data)
Write Consecutive Data  
addresssuffix = DeviceType + DeviceNo + DataFormat  
 .e.g. MR0, DM0.U  
data = byte() (data1 + 0x20 + data2 + 0x20 ...) 
Return: EtherNet/IP Unit Response  

### mws(addresses)
Register monitor
addresses = DeviceType + DeviceNo + DataFormat  
 .e.g. 'DM0.H DM1.S DM2.L DM4.U DM5.D'  
Return: EtherNet/IP Unit Response  

### mwr()
Read monitor  
Return: EtherNet/IP Unit Response (Data1 + 0x20 + Data2 + 0x20 ...)  

# Example
```
from kvhostlink import kvHostLink

kv = kvHostLink('192.168.250.10')
data = kv.mode('1')
print(data)						# b'OK\r\n'
data = kv.unittype()
print(data)						# b'57\r\n'
data = kv.errclr()
print(data)						# b'OK\r\n'
data = kv.er()
print(data)						# b'000\r\n'
data = kv.settime()
print(data)						# b'OK\r\n'
data = kv.set('MR0')
print(data)						# b'OK\r\n'
data = kv.reset('MR1')
print(data)						# b'OK\r\n'
data = kv.sts('MR10', 5)
print(data)						# b'OK\r\n'
data = kv.rss('MR10', 4)
print(data)						# b'OK\r\n'
data = kv.read('DM0.U')
print(data)						# b'00002\r\n'
data = kv.reads('DM0.S', 4)
print(data)						# b'+00002 +00001 +00002 +00003\r\n'
data = kv.write('DM0.U', '2')
print(data)						# b'OK\r\n'
data = kv.writs('DM1.S', 4, '1 2 3 4')
print(data)						# b'OK\r\n'
data = kv.mws('DM0.H DM1.S DM2.L DM4.U DM5.D')
print(data)						# b'OK\r\n'
data = kv.mwr()
print(data)						# b'0002 +00001 +0000196610 00004 0605955594\r\n'

```
