-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.py
55 lines (40 loc) · 1.09 KB
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
import asyncio
import logging
import os
import struct
from examples.helper import get_commandline
from pymodbus.datastore import (
ModbusSequentialDataBlock,
ModbusServerContext,
ModbusSlaveContext,
ModbusSparseDataBlock,
)
from pymodbus.device import ModbusDeviceIdentification
# --------------------------------------------------------------------------- #
# import the various client implementations
# --------------------------------------------------------------------------- #
from pymodbus.server import (
StartAsyncSerialServer,
StartAsyncTcpServer,
StartAsyncTlsServer,
StartAsyncUdpServer,
)
from pymodbus.version import version
import codecs
#hex = codecs.encode(b"S", "hex")
_logger = logging.getLogger()
#hex = hex(ord("S"))
char = "SI"
#result = char.encode()
#"I%ds" % (len(s),)
#dataExport = struct.pack("c", hex)
if (isinstance(char, str)):
dataExport = struct.pack(">%s" % (len(char),), char.encode())
else:
dataExport = struct.pack(">B", char)
#b = bytes("S",'utf-8')
#print(result)
#print(b)
print(dataExport)
#print(hex)