Commit 92f2c104 authored by yogesh.m's avatar yogesh.m

update removing pickle

parent 11d28112
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (pythonProject)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9 (pythonProject)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -4,6 +4,7 @@ from asyncua import ua, Server
import socket
import threading
import json
import struct
server_up=False
......@@ -188,8 +189,9 @@ def hash_receive(udp_receiver_ip,udp_receiver_port):
while (True):
bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
message = bytesAddressPair[0]
hierarchy=pickle.loads(message)
hierarchy=json.loads(hierarchy)
string_length = struct.unpack("!I", message[:4])[0]
json_string = message[4:].decode('utf-8')
hierarchy=json.loads(json_string)
if(prev_hash!=hierarchy["hash"] and asr.idx):
analyse_hierarchy(hierarchy)
prev_hash=hierarchy["hash"]
......
......@@ -2,7 +2,7 @@ from asyncua import Client
import asyncio
import socket
from time import sleep
import pickle
import struct
import json
nm_no = None
......@@ -50,8 +50,12 @@ async def get_send_hash(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_po
node_hierarchy["hash"] = hash(str(node_hierarchy))
node_hierarchy["namespace_idx"]=nm_no
json_hierarchy = json.dumps(node_hierarchy)
hierarchy=pickle.dumps(json_hierarchy)
UDPClientSocket.sendto(hierarchy, serverAddressPort)
hierarchy=json.dumps(json_hierarchy)
utf8_encoded_string = hierarchy.encode('utf-8')
string_length = len(utf8_encoded_string)
length_bytes = struct.pack("!I", string_length)
binary_data = length_bytes + utf8_encoded_string
UDPClientSocket.sendto(binary_data, serverAddressPort)
def send_hash(Endpoint,Namespace,server_hash_udp_ip,server_hash_udp_port):
asyncio.run(get_send_hash(Endpoint,Namespace,server_hash_udp_ip,server_hash_udp_port))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment