pwitab / iec62056-21

A Python library for IEC62056-21, Local Data Readout of Energy Meters. Former IEC1107
BSD 3-Clause "New" or "Revised" License
67 stars 21 forks source link

Implementing protocol to my client file. #25

Closed shamithvemula closed 2 years ago

shamithvemula commented 2 years ago

Hi I want to read a single value from my smart meter, I did the code for basic server.py and client,py, I need to use this iec62056-21 for local data exchange.

*

from iec62056_21.client import Iec6205621Client

client = Iec6205621Client.with_tcp_transport(address=('192.168.0.1', 8000), device_address='12345678', password='00000000')

password_challange = client.access_programming_mode()

client.send_password('00000000') # Common standard password

data_answer = client.read_value('1.8.0')

I'm not getting any lead to assign this protocol to my client.py file. *

MY SERVER.PY FILE

import socket

SMGW = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #socket created

""" socket.AF_INET corresponds to the internet address family for IPv4 and socket.SOCK_STREAM is the socket type for TCP i.e connection oriented. """

print("socket created")

host = 'localhost' port = 9999 address = (host, port)

SMGW.bind(address) SMGW.listen(5) #waiting for connections

print("waiting for connections")

while True: SM, addr = SMGW.accept()

name = SM.recv(1024) name.decode('utf-8')

print("connected with", addr, name)

SM.send(bytes("welcome to smart meter gateway"))

data_exchange = SM.recv(1024) print(data_exchange.decode('utf-8'))

SM.close

print("SM disconnected")

* MY CLIENT.PY FILE

import socket

SM = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

""" socket.AF_INET corresponds to the internet address family for IPv4 and socket.SOCK_STREAM is the socket type for TCP i.e connection oriented. """

print("socket created")

host = 'localhost' port = 9999

SM.connect((host, port))

SM.send(bytes('smart meter'))

data = SM.recv(1024) print(data.decode('utf-8'))

SM.send(bytes("This is smart meter"))

Any lead's will be helpful !!

Krolken commented 2 years ago

So are you using trying to simulate a meter or communicate with a real meter? Which kind of meter?

shamithvemula commented 2 years ago

My task is to build the communication between the smart meter and smart meter gateway using protocol iec62056-21. so its communication with a real meter.

Krolken commented 2 years ago

Of what I can see from above you only have a socket pair that connects to each other in the client/server file. You will need to use the library separately from these sockets and pass data between them.

If you need assistance in implementing a solution based on this library I would recommend our paid services. Email henrik.wahlgren@utilitarian.io for more information.

shamithvemula commented 2 years ago

Of what I can see from above you only have a socket pair that connects to each other in the client/server file. You will need to use the library separately from these sockets and pass data between them.

If you need assistance in implementing a solution based on this library I would recommend our paid services. Email henrik.wahlgren@utilitarian.io for more information.

I mailed the id you mentioned, but I couldn’t get any response !!

Krolken commented 2 years ago

Closing due to inactivity