I am trying to read Profile Generic parameters from L & T , I am able to read Events 1, 2,3,4,5 using Gurux.DLMS.Client.Example.Net without any changes. but can't able to read 1.0.94.91.0.255 , 1.0.99.1.0.255 either by range or read by range or by index.
Where as i can read it through GuruxDirect, using Indian stand, lnt1 as password, Client add =20, but in this case also if i read 1.0.94.91.0.255 using read by index or range then it does not read it again with normal way ie All option.
Also same for 1.0.99.1.0.255 OBIS code, It can be read by range. but if read this OBIS code by Index and then again tried with range then it doesn't read again by range.
Please, don't add trace if there is nothing wrong. I believe that read by entry is not implemented to the meter. That is a quite common. Try to set start and end time so minutes and seconds are zero.
Like: 01:00:00
Some meters are expecting that start and end times are hourly based.
As suggested, Still I am not able to read real time profile Generic 1.0.94.91.0.255 code this has only one row .
But now I am able to read block data 1.0.99.1.0.255 ie 15 minutes interval.
code sample for reading last 4 days
object[] rows = ReadRowsByRange(it as GXDLMSProfileGeneric, DateTime.Now.Date.AddDays(-4), DateTime.Now.Date.AddHours(11));
I am able to read it now. but it returns object and can see data values in collection. So I tried to loop it as below code sample. But unable to get data. Can you Please share code/ logic to retrieve data from collection.
object rows = Read(it, 3);
foreach (GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject> row in (IEnumerable<Gurux.DLMS.GXKeyValuePair<Gurux.DLMS.Objects.GXDLMSObject, Gurux.DLMS.Objects.GXDLMSCaptureObject>>)rows)
{
code to find data.
}
Instead of reading like Read(it, 3) I read by Read(it, 2) post this
I did like below code it gives me data. i just wanted to confirm it is correct way? if not suggest me
object[] rows = (object[])Read(it, 2);
StringBuilder sb = new StringBuilder();
if (Trace > TraceLevel.Warning)
{
//StringBuilder sb = new StringBuilder();
foreach (object[] row in rows)
{
foreach (object cell in row)
{
if (cell is byte[])
{
sb.Append(GXCommon.ToHex((byte[])cell, true));
}
else
{
sb.Append(Convert.ToString(cell));
}
sb.Append(" | ");
}
sb.Append("\r\n");
}
Console.WriteLine(sb.ToString());
can below code work correctly for reading 1.0.94.91.0.255 ? if not please suggest.
GXDLMSProfileGeneric it = new GXDLMSProfileGeneric("1.0.94.91.0.255");
Read(it, 3);
GXDLMSObject[] cols = (it as GXDLMSProfileGeneric).GetCaptureObject();
object[] rows = (object[])Read(it, 2);
foreach (object[] DrRow in rows)
{
value = DrRow[rowIndex];
get data by index.
}
thanks it is working now.. But now port hang issue occurred after first successful data fetch, I need to unplug Ethernet cable and plug it again in meter. post that again it block after one request.
I am currently building multi thread application so in each read i am doing below steps in while loops. but after first while it says connection disallowed. Where as when i follow same step through gurux director then it works without hang issue.
1 Create new media
2. assign ip and port
3. create client object.
4. create reader object
5. open media
6. then InitializeConnection();
7. read Generic Profile by index 3 and then by 2
8 collect data
9 call reader.Close()
secondly When I put while loop only for step 7 & 8 then it works correctly but after application close it through same error. I tried this only to find out issue. i have to go with first option .
Check are ReleaseRequest and DisconnectRequest called.
If connection is not closed correctly meter waits until inactivity timeout is elapsed before you can connect again.
All Indian meter doesn't support protected release. Try to change cl_releaseRequest to cl_releaseRequest2, where useProtectedRelease parameter is false.
I have tried both cases but did not worked. same issue persist.
A request to send or receive data was disallowed because the socket is not conne
cted and (when sending on a datagram socket using a sendto call) no address was
supplied
System.Net.Sockets.SocketException (0x80004005): A request to send or receive da
ta was disallowed because the socket is not connected and (when sending on a dat
agram socket using a sendto call) no address was supplied
at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at Gurux.Net.GXNet.ClientConnect(EndPoint ep) in C:\vsts-agent-win7-x64-2.124
.0\_work\6\s\development\GXNet.cs:line 1010
at Gurux.Net.GXNet.Open() in C:\vsts-agent-win7-x64-2.124.0\_work\6\s\develop
ment\GXNet.cs:line 894
at Gurux.DLMS.Client.Example.Program.Main(String[] args)
I need to check this. In your email, you were saying that you are making a multi-thread application. Are you trying to read the same meter from multiple threads? There can be only one connection to the meter at the time.
Can you read the meter with -t Verbose parameter and send the log file to me by email.
You can get my email address from here: https://www.gurux.fi/AboutUs
The release is called as should be and meter reply as should be. Try to wait 10 seconds and try to connect again. Some meters are needing a small delay between the connections.
GXDLMSDirector and trace file are equal. There is no reason why you can't connect the second time.
GXDLMSDirector and client example work exactly the same way. Make sure that you call Media.Close(); when you close the connection.
Hi,
Hi,
Please, don't add trace if there is nothing wrong. I believe that read by entry is not implemented to the meter. That is a quite common. Try to set start and end time so minutes and seconds are zero.
Like: 01:00:00
Some meters are expecting that start and end times are hourly based.
BR,
Mikko
Hi Mikko,
Hi Mikko,
As suggested, Still I am not able to read real time profile Generic 1.0.94.91.0.255 code this has only one row .
But now I am able to read block data 1.0.99.1.0.255 ie 15 minutes interval.
code sample for reading last 4 days
object[] rows = ReadRowsByRange(it as GXDLMSProfileGeneric, DateTime.Now.Date.AddDays(-4), DateTime.Now.Date.AddHours(11));
Kindly suggest.
Hi,
Hi,
1.0.94.91.0.255 is Instantaneous Profile. There should be only current values and there is only one row.
BR,
Mikko
yes Mikko,
yes Mikko,
but i am not able to read it as per suggestion .
Hi Sachin,
Hi Sachin,
Try to read it using normal read. Like this:
Read(it, 3);
I don't believe that ReadRowsByRange is implemented for 1.0.94.91.0.255.
Try to read it using GXDLMSDirector first.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I am able to read it now. but it returns object and can see data values in collection. So I tried to loop it as below code sample. But unable to get data. Can you Please share code/ logic to retrieve data from collection.
object rows = Read(it, 3);
foreach (GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject> row in (IEnumerable<Gurux.DLMS.GXKeyValuePair<Gurux.DLMS.Objects.GXDLMSObject, Gurux.DLMS.Objects.GXDLMSCaptureObject>>)rows)
{
code to find data.
}
Hi Sachin,
Hi Sachin,
You are looping captured objects (columns), not the buffer. Find GetProfileGenerics-method from the client example. It does what you want to do.
BR,
Mikko
Hi Mikko,
Hi Mikko,
Instead of reading like Read(it, 3) I read by Read(it, 2) post this
I did like below code it gives me data. i just wanted to confirm it is correct way? if not suggest me
object[] rows = (object[])Read(it, 2);
StringBuilder sb = new StringBuilder();
if (Trace > TraceLevel.Warning)
{
//StringBuilder sb = new StringBuilder();
foreach (object[] row in rows)
{
foreach (object cell in row)
{
if (cell is byte[])
{
sb.Append(GXCommon.ToHex((byte[])cell, true));
}
else
{
sb.Append(Convert.ToString(cell));
}
sb.Append(" | ");
}
sb.Append("\r\n");
}
Console.WriteLine(sb.ToString());
Hi Sachin,
Hi Sachin,
When you read #2 you read capture object (columns). You need to read it first, but data is in attribute #3.
If you read only #2, buffer is empty.
BR,
Mikko
Hi Mikko,
Hi Mikko,
can below code work correctly for reading 1.0.94.91.0.255 ? if not please suggest.
GXDLMSProfileGeneric it = new GXDLMSProfileGeneric("1.0.94.91.0.255");
Read(it, 3);
GXDLMSObject[] cols = (it as GXDLMSProfileGeneric).GetCaptureObject();
object[] rows = (object[])Read(it, 2);
foreach (object[] DrRow in rows)
{
value = DrRow[rowIndex];
get data by index.
}
Hi Sachin,
Hi Sachin,
It looks correct. You have all the column items in DrRow. Now you just loop them.
BR,
Mikko
Hi Mikko,
Hi Mikko,
thanks it is working now.. But now port hang issue occurred after first successful data fetch, I need to unplug Ethernet cable and plug it again in meter. post that again it block after one request.
I am currently building multi thread application so in each read i am doing below steps in while loops. but after first while it says connection disallowed. Where as when i follow same step through gurux director then it works without hang issue.
1 Create new media
2. assign ip and port
3. create client object.
4. create reader object
5. open media
6. then InitializeConnection();
7. read Generic Profile by index 3 and then by 2
8 collect data
9 call reader.Close()
secondly When I put while loop only for step 7 & 8 then it works correctly but after application close it through same error. I tried this only to find out issue. i have to go with first option .
Kindly suggest.
Hi,
Hi,
Check are ReleaseRequest and DisconnectRequest called.
If connection is not closed correctly meter waits until inactivity timeout is elapsed before you can connect again.
BR,
Mikko
Hi Mikko,
Hi Mikko,
yes, both request are send to close and release port. I am using Interface type as InterfaceType.WRAPPER.
sill issue persist
Hi,
Hi,
All Indian meter doesn't support protected release. Try to change cl_releaseRequest to cl_releaseRequest2, where useProtectedRelease parameter is false.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I am using .net client code. I did not find suggested option in reader.close() to try it.
Kindly Suggest or provide sample code if possible.
Hi,
Hi,
Set UseProtectedRelease to False. If it doesn't help try to comment ReleaseRequest. Some (older) meters can't handle it.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I have tried both cases but did not worked. same issue persist.
A request to send or receive data was disallowed because the socket is not conne
cted and (when sending on a datagram socket using a sendto call) no address was
supplied
System.Net.Sockets.SocketException (0x80004005): A request to send or receive da
ta was disallowed because the socket is not connected and (when sending on a dat
agram socket using a sendto call) no address was supplied
at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at Gurux.Net.GXNet.ClientConnect(EndPoint ep) in C:\vsts-agent-win7-x64-2.124
.0\_work\6\s\development\GXNet.cs:line 1010
at Gurux.Net.GXNet.Open() in C:\vsts-agent-win7-x64-2.124.0\_work\6\s\develop
ment\GXNet.cs:line 894
at Gurux.DLMS.Client.Example.Program.Main(String[] args)
Hi,
Hi,
I need to check this. In your email, you were saying that you are making a multi-thread application. Are you trying to read the same meter from multiple threads? There can be only one connection to the meter at the time.
BR,
Mikko
Hi ,
Hi ,
no currently i am using .net client with single meter no threading involve. just put IP, port and password.
i can share my remote if required .
Hi,
Hi,
If you run the client example app twice is this same thing happening?
BR,
Mikko
Hi,
Hi,
yes, first time it run, on second time onward it throe above error.
Hi,
Hi,
Can you read the meter with -t Verbose parameter and send the log file to me by email.
You can get my email address from here:
https://www.gurux.fi/AboutUs
BR,
Mikko
Hi,
Hi,
i have sent mail to [Email address removed].
Hi,
Hi,
The release is called as should be and meter reply as should be. Try to wait 10 seconds and try to connect again. Some meters are needing a small delay between the connections.
BR,
Mikko
Hi Mikko,
Hi Mikko,
i am connecting after 1, 2 ,4 and 5 minutes also it through same error. after first request.
Hi,
Hi,
Can you send GXDLMSDirector log to me using same email address?
Check the verbose mode.
BR,
Mikko
Hi mikko,
Hi mikko,
i have sent file. i can't able to on verbose mode. kindly let me know how to on it.
Hi Mikko,
Hi Mikko,
did you find any solution ?
Hi Mikko,
Hi Mikko,
any update on this issue. I can see there is difference in release and disconnect bytes in client and Director app.
Just an update when i connect RJ 11 port to rs 485 using interface device it is working ie interface type as HDLc .
kindly advise.
Hi,
Hi,
GXDLMSDirector and trace file are equal. There is no reason why you can't connect the second time.
GXDLMSDirector and client example work exactly the same way. Make sure that you call Media.Close(); when you close the connection.
BR,
Mikko
Hi ,
Hi ,
it is already called after release and disconnect in Close method.
in shared logs , i can see some difference of bytes in request sent to release and disconnect command.
Hi,
Hi,
Try to set UseProtectedRelease = True. Let me know what happened.
BR,
Mikko
Hi Mikko, It does not work.
Hi Mikko,
It does not work.