Hello
i am trying to read the DLMS meter data with dynamic IP using Gurux.DLMS.Meter.Listener.Net but i am getting Invalid client i don't know why these are my client setting which are correct
GXDLMSClient client = new GXDLMSClient(true, 0x11, 1, Enums.Authentication.Low, "00000000", Enums.InterfaceType.WRAPPER);
________________________________________________
RESPONSE :
This server is listening port 9090 and waiting incoming connections from the meters.
This server can be used with DLMS meters that are using dynamic IP addresses.
Client 182.191.142.82:47680 is connected.
Send AARQ request
TX: 17:23:28 00 01 00 11 00 01 00 38 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 30 30 30 30 30 30 30 30 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF
Disconnecting from the meter.
Invalid client.
this is the trace.txt file :
TX: 16:19:52 7E A0 07 03 21 93 0F 01 7E
TX: 16:20:41 7E A0 07 03 21 93 0F 01 7E
TX: 16:21:03 7E A0 07 03 21 93 0F 01 7E
TX: 16:21:25 7E A0 07 03 21 93 0F 01 7E
TX: 16:21:48 7E A0 07 03 21 93 0F 01 7E
TX: 16:22:10 7E A0 07 03 21 93 0F 01 7E
TX: 16:22:32 7E A0 07 03 21 93 0F 01 7E
TX: 16:22:54 7E A0 07 03 21 93 0F 01 7E
TX: 16:23:16 7E A0 07 03 21 93 0F 01 7E
TX: 16:31:11 00 01 00 11 00 01 00 38 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 30 30 30 30 30 30 30 30 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF
TX: 16:33:36 00 01 00 11 00 01 00 38 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 30 30 30 30 30 30 30 30 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF
TX: 16:34:26 00 01 00 11 00 01 00 38 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 30 30 30 30 30 30 30 30 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF
TX: 16:50:00 00 01 00 10 00 01 00 1F 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF
Hi, Auto-connect is not…
Hi,
Auto-connect is not tested in DLMS CTT tests and manufacturers have implemented that differently.
Some meters don't expect that AARQ is sent. Try to read e.g. clock after the connection is established. Don't try to establish the connection. Just read the clock like this:
GXDLMSClock clock = new GXDLMSClock();
Read(clock, 2);
BR,
Mikko
This is what i am getting i…
This is what i am getting i am trying to read the Clock directly
______________
private static void OnClientConnected(object sender, Common.ConnectionEventArgs e)
{
GXNet server = (GXNet)sender;
try
{
using (GXNet cl = server.Attach(e.Info))
{
GXDLMSClock clock = new GXDLMSClock();
Console.WriteLine("Date and Time is {0}", clock.Time);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
------------------------
RESPONSE
This server is listening port 9090 and waiting incoming connections from the meters.
This server can be used with DLMS meters that are using dynamic IP addresses.
Date and Time is 01/01/0001 00:00:00
Date and Time is 01/01/0001 00:00:00
Date and Time is 01/01/0001 00:00:00
Date and Time is 01/01/0001 00:00:00
Hi, You must read your clock…
Hi,
You must read your clock from the meter.
BR,
Mikko
Sorry, I didn't understand…
Sorry, I didn't understand. As you mentioned, after the connection in the onClientConnected method, I called the GXDLMSClock clock = new GXDLMSClock(); function, but I don't think it's showing the correct meter time. What might be the issue? Should I call the clock function somewhere else?
i have commented…
i have commented InitializeConnection(); and try to read the other objects other then InitializeConnection i got the same error
public void ReadAll(bool useCache)
{
try
{
InitializeConnection();
GetAssociationView(useCache);
GetScalersAndUnits();
GetProfileGenericColumns();
GetReadOut();
}
finally
{
Close();
}
Response
_____________________________________
This server is listening port 9090 and waiting incoming connections from the meters.
This server can be used with DLMS meters that are using dynamic IP addresses.
Client 116.71.8.48:8064 is connected.
TX: 11:48:53 00 01 00 11 00 01 00 0D C0 01 C1 00 0F 00 00 28 00 00 FF 02 00
Disconnecting from the meter.
Invalid client.
Hi, The meter is not…
Hi,
The meter is not replying. I believe that you need to establish the connection.
Do you have the meter documentation? Does it describe which authentication level you need to use to establish the connection?
Do you have manufacturer application that can be used to read values from the meter? If you do, I'll get the correct settings for you if you can share the WireShark log with me.
BR,
Mikko
These are the correct…
These are the correct settings
Server address 1
Client 17
Password 00000000
Authentication low
These are the correct setting but still i am getting the issue . Can it happened due to i update the project to latest dotnet? I have updated the project to 8 from version 4 it might be an issue or not ?? If not then what can be whay i am getting in valid client
Hi, The meter might use…
Hi,
The meter might use different settings with dynamic IPs than normal connections.
Have you ever been able to read this meter with a dynamic IP address where the meter establishes the connection for the server?
BR,
Mikko
Yes meter is working fine…
Yes meter is working fine with the manufacturer software and these are the settings you found out for me in the last issue when i provide you the logs
Hi, As I told, get me a…
Hi,
As I told, get me a Wireshark log so I can check how meter is working with dynamic IP addresses.
Reading the meter with dynamic IP addresses is totally a different process than reading the meter directly.
BR,
Mikko
These are some logs from the…
These are some logs from the wire sharks using dynamic address
[2024- 05-28 20:13:09] DCU [2898000015] is Online, IP: 154.80.63.141:46369
Receive From Client (2024-05-28 20:14:53) IP[192.168.1.116:55711]
66 0D 00 0D 00 66 21 0A 32 38 39 38 30 30 30 30 31 35 02 C0 01 81 00 01 00 00 2A 00 00 FF 02 00 9B 17
Send (2024-05-28 20:14:53)DCU: 2898000015 [2898000015]
00 01 00 11 00 01 00 38 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 30 30 30 30 30 30 30 30 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 FF FF
FF 28 00
[2024-05-28 20:14:55] [2898000015]Receive dIms data [startIndex:90 ;endIndexNextPosition: 90]
00 01 00 01 00 11 00 38 61 36 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 BE 10 04 0E 08 00 06 5F 1F 04 00 00 18 1D 03
00 00 67
Receive (2024-05-28 20:14:55)DCU: 2898000015 [2898000015]
00 01 00 01 00 11 00 38 61 36 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 BE 10 04 0E 08 00 06 5F 1F 04 00 00 18 1D 03
00 00 07
Send (2024-05- 28 20:14:55)DCU: 2898000015 [2898000015]
00 01 00 11 00 01 00 0D C0 01 81 00 01 00 00 2A 00 00 FF 02 00
[2024-05-28 20:14:561 [2898000015 Receive dlms data [startIndex: 120; endIndexNextPosition:1201
00 01 00 01 00 11 00 16 C4 01 81 00 04 10 56 45 58 32 33 30 32 38 39 38 30 30 30 30 31 35
Receive(2024-05-28 20:14: 56) DCU: 2898000015 [2898000015]
00 01 00 01 00 11 00 16 C4 01 81 00 0A 10 56 45 58 32 33 30 32 38 39 38 30 30 30 30 31 35
Send to Client (2024-05-28 20:14:56) IP[192.168.1.116:557111
66 16 00 16 00 66 21 0A 32 38 39 38 30 30 30 30 31 35 02 00 C4 01 81 00 04 10 56 45 58 32 33 30 32 38 39 38 30 30 30 30 31 35 17 17
[2024-05-28 20:14:56] DCU 2898000015 [2898000015]'s Schedule Completed ********
Schedule Description[Read Client Task by Meter Nol
Receive From Client (2024-05-28 20:14:56) IP[192.168.1.116:557111
66 0D 00 0D 00 66 21 0A 32 38 39 38 30 30 30 30 31 35 02 C0 01 81 00 01 00 00 60 01 00 FF 02 00 D1 17
Send (2024- 05-28 20:14:56) DCU: 2898000015 [2898000015]
00 01 00 11 00 01 00 0D C0 01 81 00 01 00 00 60 01 00 FF 02
these are some logs from the wireshark
0000 00 0c 29 22 42 43 ac 84 c6 09 13 d6 08 00 45 00 ..)"BC........E.
0010 00 53 00 00 40 00 32 06 d6 86 8b 87 24 7b c0 a8 .S..@.2.....${..
0020 01 74 e7 3e 0d 10 0f 3d 56 71 32 15 e5 5c 50 18 .t.>...=Vq2..\P.
0030 fe 8d ec 46 00 00 17 03 03 00 26 0b c2 7d 3e 7a ...F......&..}>z
0040 a2 6b 44 77 73 86 71 a8 1c b2 9c b1 fd 23 bd c4 .kDws.q......#..
0050 2f 85 bd aa 7a 20 78 4d ee 2a 83 ff 1b 0a 2d 07 /...z xM.*....-.
0060 c6 .
Frame 121354: 269 bytes on wire (2152 bits), 269 bytes captured (2152 bits) on interface \Device\NPF_{0FD20B98-6D03-4D35-8F26-DAC1E2B303CF}, id 0
Interface id: 0 (\Device\NPF_{0FD20B98-6D03-4D35-8F26-DAC1E2B303CF})
Interface name: \Device\NPF_{0FD20B98-6D03-4D35-8F26-DAC1E2B303CF}
Interface description: Ethernet0
Encapsulation type: Ethernet (1)
Arrival Time: May 28, 2024 19:36:30.655953000 Pakistan Standard Time
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1716906990.655953000 seconds
[Time delta from previous captured frame: 0.000014000 seconds]
[Time delta from previous displayed frame: 0.000014000 seconds]
[Time since reference or first frame: 1744.522030000 seconds]
Frame Number: 121354
Frame Length: 269 bytes (2152 bits)
Capture Length: 269 bytes (2152 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:tcp:tls]
[Coloring Rule Name: TCP]
[Coloring Rule String: tcp]
Ethernet II, Src: VMware_22:42:43 (00:0c:29:22:42:43), Dst: Tp-LinkT_09:13:d6 (ac:84:c6:09:13:d6)
Destination: Tp-LinkT_09:13:d6 (ac:84:c6:09:13:d6)
Address: Tp-LinkT_09:13:d6 (ac:84:c6:09:13:d6)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Source: VMware_22:42:43 (00:0c:29:22:42:43)
Address: VMware_22:42:43 (00:0c:29:22:42:43)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 192.168.1.116, Dst: 139.135.36.123
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
0000 00.. = Differentiated Services Codepoint: Default (0)
.... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
Total Length: 255
Identification: 0xb341 (45889)
Flags: 0x40, Don't fragment
...0 0000 0000 0000 = Fragment Offset: 0
Time to Live: 128
Protocol: TCP (6)
Header Checksum: 0x0000 [validation disabled]
[Header checksum status: Unverified]
Source Address: 192.168.1.116
Destination Address: 139.135.36.123
Transmission Control Protocol, Src Port: 3344, Dst Port: 59198, Seq: 12126546, Ack: 2697730, Len: 215
Source Port: 3344
Destination Port: 59198
[Stream index: 0]
[Conversation completeness: Incomplete (12)]
[TCP Segment Len: 215]
Sequence Number: 12126546 (relative sequence number)
Sequence Number (raw): 848398845
[Next Sequence Number: 12126761 (relative sequence number)]
Acknowledgment Number: 2697730 (relative ack number)
Acknowledgment number (raw): 257585884
0101 .... = Header Length: 20 bytes (5)
Flags: 0x018 (PSH, ACK)
Window: 63398
[Calculated window size: 63398]
[Window size scaling factor: -1 (unknown)]
Checksum: 0x7310 [unverified]
[Checksum Status: Unverified]
Urgent Pointer: 0
[Timestamps]
[Time since first frame in this TCP stream: 1744.522030000 seconds]
[Time since previous frame in this TCP stream: 0.000014000 seconds]
[SEQ/ACK analysis]
[Bytes in flight: 26586]
[Bytes sent since last PSH flag: 215]
TCP payload (215 bytes)
Transport Layer Security
TLSv1.2 Record Layer: Application Data Protocol: Application Data
Content Type: Application Data (23)
Version: TLS 1.2 (0x0303)
Length: 210
Encrypted Application Data: 00000000000067466694053970c9225edc5033841fd9fca15cbfe51974b803bf3729dbb7
Believe me its been 3 months…
Believe me its been 3 months i am stuck at this communication things please help me out
please help me out with this…
please help me out with this issue
for the debugging purpose i…
I have asked the manufacturer. This is what they have sent me. Will it be helpful?
EXAMPLE TO READ 1.8.0 and 2.8.0
1. Heart Beat:
Send(05-26 16:23:43)
00 01 00 11 00 01 00 12 DA 10 00 00 30 30 30 30 30 30 39 38
38 31 30 30 30 35
(head end send command to meter)
Receive(05-26 16:25:43)
00 01 00 01 00 11 00 12 DD 10 30 30 30 30 30 30 30 30 39 38
38 31 30 30 30 35
(meter responses)
2. Total import active energy(1.8.0):
Send(05-26 16:28:29)
00 01 00 11 00 01 00 3C 60 3A 80 02 02 84 A1 09 06 07 60 85
74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A
80 08 30 30 30 30 30 30 30 30 BE 10 04 0E 01 00 00 00 06 5F
1F 04 00 FF FF FF 28 00
Receive(05-26 16:28:31)
00 01 00 01 00 11 00 2B 61 29 A1 09 06 07 60 85 74 05 08 01
01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06
5F 1F 04 00 00 18 1D 00 F0 00 07
(yellow part is shake hand)
Send(05-26 16:28:32)
00 01 00 11 00 01 00 0D C0 01 81 00 03 01 00 01 08 00 FF 02
00
(head end sends command to ask for 1.8.0)
Receive(05-26 16:28:33)
00 01 00 01 00 11 00 09 C4 01 81 00 06 00 01 15 F2
(meter responses)
3. Total export active energy(2.8.0)
Send(05-26 16:28:53)
00 01 00 11 00 01 00 0D C0 01 81 00 03 01 00 02 08 00 FF 02
00
(head end sends command to ask for 2.8.0)
Receive(05-26 16:28:55)
00 01 00 01 00 11 00 09 C4 01 81 00 06 00 00 00 00
(meter responses 2.8.0)
Hi, Now this starts to make…
Hi,
Now this starts to make sense. Your meter is from Goldcard.
They have implemented a custom auto-connect.
The meter is sending a login message and you must reply for it or the connection is not established.
You need to ask the documentation from Goldcard and generate the reply message and send it. After you have implemented the login, you can establish the connection to the meter.
BR,
Mikko
not i am using Holley meters
not i am using Holley meters
i am using 3phase holley…
i am using 3phase holley meter and also can you please tell me in details what i should ask them which will make the communication
Hi, Everything looks good…
Hi,
Everything looks good and your settings are correct. You need to initialize the connection before reading anything from the meter.
The only thing that I don't know is Heart Beat and do you need to send that before you can read anything from the meter. You need to ask this and the structure of it from the meter vendor.
BR,
Mikko
I asked the vendor to send…
I asked the vendor to send me how they create the login request. They provided the following code snippet:
self.connection_received = client_socket.recv(9924).hex().upper();
To test this, I created a simple service that listens on port 9090. When I run the service, I receive the following response:
Server listening on 0.0.0.0:9090
client_socket connection from <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('172.31.44.127', 9090), raddr=('182.191.138.245', 59904)>
Accepted connection from ('182.191.138.245', 59904)
Connection established from ('182.191.138.245', 59904) to 0.0.0.0:9090
Full received data: 0001000100110012DD1030303030303032383938303030303138
Extracted MSN hex: 30303030303032383938
Decoded MSN: 0000002898
Initializing communication with device at ('182.191.138.245', 59904) with MSN: 0000002898
Received data from ('182.191.138.245', 59904): 0001000100110012DD1030303030303032383938303030303138
The received hex data is very similar to what the vendor provided in their documentation.
Can you tell me what to do next? Specifically, how do I read data from the meter and implement auto-connect? I don't have any experience with this. Are there additional details you need from the vendor?
Full Code that they have provided
import time
import datetime
import logging
import threading
from mdc.models.DeviceScheduledCommand import *
from mdc.models.FactReading import *
from mdc.models.DimDevice import *
from mdc.models.DimObis import *
from mdc.models.DeviceSchedules import *
from mdc.models.DimDate import *
from mdc.models.DimTime import *
from mdc.models.FactDeviceConnection import *
from mdc.models.FactEvent import *
logger = logging.getLogger(__name__)
class DeviceComm:
"""Device Communication Object.
This Class Object will be used to interact with the meter.
This Object will be initialzed through TCP Service which is listening meters.
"""
pwd = '00000000'
timeout = 5
timeout_prev_data = 2
# Convert a String to hex
# '00'.encode('utf-8').hex()
def __init__(self, client_socket, address,bind_ip, port_obj):
"""Initializes Communication Object of Meter"""
self.v_list_response = {}
self.port_obj = port_obj
self.client_socket = client_socket
self.address = address
self.connection_received = client_socket.recv(9924).hex().upper();
self.msn_hex = format(self.connection_received[self.port_obj.msn_start_pos:self.port_obj.msn_end_pos]) # [24:40]
self.msn = bytearray.fromhex(self.msn_hex).decode()
print ('Received1 on {}:{} {}'.format(address[0], address[1], self.connection_received))
self.is_busy = 0
self.locked_session_id = 0
self.priority_wait_count = 0
self.do_listen = False
self.is_alive = True
#Make and entry to message Received and Connection Established.
dataset_device = DimDevice.objects.filter(msn = self.msn, is_active = True)
#Return if not an active device is found
if len(dataset_device) == 0:
fact_device_received = FactDeviceReceived(id=FactDeviceReceived.get_next_id(), date_id=DimDate.get_current_date_key(), time_id=DimTime.get_current_time_key(), command=self.connection_received, send_receive_status = 'Received',
comments='New Connection')
fact_device_received.save()
return
self.device = dataset_device[0]
self.pwd = self.device.device_password.encode('utf-8').hex()
fact_device_received = FactDeviceReceived(id=FactDeviceReceived.get_next_id(), date_id=DimDate.get_current_date_key(), time_id=DimTime.get_current_time_key(), command=self.connection_received, send_receive_status = 'Received',
comments='New Connection', device_id = self.device.id)
fact_device_received.save()
self.device_connection = FactDeviceConnection(id=FactDeviceConnection.get_next_id(), device_id = self.device.id, connection_date_id = DimDate.get_current_date_key(),
connection_time_id = DimTime.get_current_time_key(), client_ip = self.address[0], client_port = self.address[1], server_ip = bind_ip, server_port = self.port_obj.id)
self.device_connection.save()
self.device.last_connection_id = self.device_connection.id
self.device.save()
self.bt_auth = self.device.get_auth_str()
self.heart_send = None # self.device.get_heart_beat_send()
self.heart_receive = self.device.get_heart_beat_receive()
self.event_identifier = self.device.device_model.event_identifier
#self.client_socket.settimeout(self.timeout)
#Authenticate
self.is_authenticated = True
beat_obj = {'obis':'Beat_Str', 'obis_command':self.device.get_heart_beat_send_first(self.connection_received)}
self.send_receive_batch(beat_obj, 1)
self.is_authenticated = False
# self.authenticate()
#Listen for commands For Future Use
listen_handler = threading.Thread(
target=self.fn_keep_listening,
args=()
)
listen_handler.start();
def get_auth_str(self):
return self.device_model.auth_str.replace('_PW_', self.device_password.encode('utf-8').hex())
def get_msn(self):
"""Get the MSN from the object of this class
Returns:
str: The return value. MSN from the object.
"""
return self.msn
def fn_keep_listening(self):
"""Get the status of Meter if it is alive at the time
Returns:
boolean: Returns True if Meter is still responging to this connection and returns False if meter is not responding to this connection.
"""
self.client_socket.settimeout(300.0)
i = 0
while self.is_alive:
# Receive any previous commands in Buffer
try:
v_command_response = None
#print ('receiving str...')
response = self.client_socket.recv(9924).hex().upper()
logger.error('Received : '+response)
#print('received in fucn:'+response)
v_command_id = None
if response != '':
i = 0
if len(response) >= 22 and response[20:22] >= '20' and response.find(self.heart_receive) == -1 and response.find(self.event_identifier) == -1:
v_command_id = response[20:22]
self.v_list_response[v_command_id] = response
fact_device_received = FactDeviceReceived(id=FactDeviceReceived.get_next_id(), date_id=DimDate.get_current_date_key(), time_id=DimTime.get_current_time_key(),
device_id = self.device.id, connection_id = self.device_connection.id, command=response, send_receive_status = 'Received',
command_id = v_command_id, comments=None)
fact_device_received.save()
# sending heart beat
if(response.find(self.heart_receive) > -1):
logger.error('sending heart beat')
if(self.heart_send == None):
self.heart_send = self.device.get_heart_beat_send(response)
fact_device_received = FactDeviceReceived(id=FactDeviceReceived.get_next_id(), date_id=DimDate.get_current_date_key(), time_id=DimTime.get_current_time_key(),
device_id = self.device.id, connection_id = self.device_connection.id, command=self.heart_send, send_receive_status = 'Sent',
command_id = None, comments = 'Sent: heart-beat')
fact_device_received.save()
self.client_socket.send(bytes.fromhex(self.heart_send))
self.is_authenticated = False
elif(self.event_identifier is not None and response.find(self.event_identifier) > -1):
FactEvent.process_event(response, self.device)
else:
i = i + 1
if(i>10):
self.close_connection()
except ConnectionAbortedError as error:
print('Caught this error in send_command command receiving-1-1: ' + repr(error))
self.close_connection()
except ConnectionResetError as error:
print('Caught this error in send_command command receiving-1-2: ' + repr(error))
self.close_connection()
except Exception as error:
print('Caught this error in send_command command receiving-1-3: ' + repr(error))
self.close_connection()
def authenticate(self):
"""Authenticates the connection with the meter with meter password.
Returns:
boolean: Returns True if Meter Password is correct and meter is authenticated, Returns False if Meter password is wrong and meter is not authenticated
"""
if(self.is_authenticated == False):
auth_obj = {'obis':'Auth_Str', 'obis_command':self.bt_auth}
self.send_receive_batch(auth_obj, 1, self.locked_session_id)
self.is_authenticated = True
return self.is_authenticated
def close_connection(self):
try:
print('Close_connection_started')
self.is_alive = False
FactDeviceConnection.close_connection(self.device_connection.id)
if self.is_busy == 0:
self.client_socket.close()
print('Close_connection_ended')
except:
return
def send_receive_batch(self, send_batch, is_on_priority, calling_session_id = 0):
"""This function is used to send the command to meter and return it back.
"""
self.last_comm = time.time()
if self.is_alive == True:
obj = send_batch
send_str = obj['obis_command']
command_id = None
if(not(send_str is None)):
send_str = send_str.upper()
if('ZZ' in send_str):
command_id = self.device.get_next_command_id()
send_str = send_str.replace('ZZ',command_id)
try:
del self.v_list_response[command_id]
except KeyError:
None
v_command_response = None
self.priority_wait_count = self.priority_wait_count + is_on_priority
response = None
# Wait for the Priority Threads to be completed
while (is_on_priority == 0 and self.priority_wait_count > 0 and calling_session_id != self.locked_session_id):
time.sleep(0.1)
# Keep waiting if busy or listening
while (self.is_busy > 0 and calling_session_id != self.locked_session_id):
time.sleep(0.1)
if self.is_alive == True:
self.is_busy = self.is_busy + 1
self.locked_session_id = self.locked_session_id + 1
# Receive any previous commands in Buffer
#self.client_socket.settimeout(self.timeout_prev_data)
#self.client_socket.settimeout(self.timeout)
if(not(send_str is None)):
# Send Command
try:
if(send_str != self.bt_auth and not(self.is_authenticated)):
logger.error('going to be authenticated')
self.authenticate()
#print('sending: '+send_str)
fact_device_received = FactDeviceReceived(id=FactDeviceReceived.get_next_id(), date_id=DimDate.get_current_date_key(), time_id=DimTime.get_current_time_key(),
device_id = self.device.id, connection_id = self.device_connection.id, command=send_str, send_receive_status = 'Sent',
command_id = command_id, comments = 'Sent: ' + obj['obis'] )
fact_device_received.save()
self.client_socket.send(bytes.fromhex(send_str))
except ConnectionAbortedError as error:
print('Caught this error in send_command command receiving-2-1: ' + repr(error))
self.close_connection()
except ConnectionResetError as error:
print('Caught this error in send_command command receiving-2-2: ' + repr(error))
self.close_connection()
except Exception as error:
print('Caught this error in send_command command receiving-2-3: ' + repr(error))
print('Caught this error in send_command command sending: ' + repr(error))
#Receive Response
if(command_id is not None):
i = 0
while (command_id not in self.v_list_response and i < 600):
i = i + 1
time.sleep(0.1)
v_command_response = self.v_list_response.pop(command_id, None)
self.is_busy = self.is_busy - 1
self.priority_wait_count = self.priority_wait_count - is_on_priority
return v_command_response
Hi, You need to send the…
Hi,
You need to send the heartbeat and wait the reply and check it. This is not standard DLMS way, so I don't know what you must send or what the meter replies. You need to implement this as the meter manufacturer describes on the documents.
After that it seems like you can start to communicate with the meter using Gurux DLMS libraries.
BR,
Mikko
this is what they have send…
this is what they have send me
Heart Beat:
Different login mode, different frame structure. This is example of Holley AMI -8 digits address mode.不同登录方式结构不同,这个是华立主站-8位表地址模式
Send (05-26 16:23:43)
00 01 Version
00 11 Source wPort
00 01 Destination wPort
00 12 Length
DA 功能控制字,现在这个DA不符合dlms协议的,当时定义这个结构的时候估计绿皮书里还没有这个控制字,所以将心跳定了这个,目前沿用了。
Function control code, now this DA is not quite follow DLMS, when holley design AMI, old Green book did not define it, holley define by ourselves.
10 Length
00 00 30 30 30 30 30 30 39 38 38 31 30 30 30 35 心跳信息,里面是表号后8位 Heart beat information, it is last 8 digits of serial number.
(head-end sends command to meter)
Receive (05-26 16:25:43)
00 01 Version
00 01 Source wPort
00 11 Destination wPort
00 12 Length
DD 功能控制字 Function Control code.
10 Length
30 30 30 30 30 30 30 30 39 38 38 31 30 30 30 35心跳信息 Heart beat information
(meter responses)
Hi, When the meter…
Hi,
When the meter establishes the connection you can try to send the heartbeat and check if the meter is replying.
This is a manufacturer-specific way of doing this and I can't help you with that.
You have to ask the meter manufacturer about this.
BR,
Mikko