/// <summary> /// Send SNRM Request to the meter. /// </summary> public void SNRMRequest() { GXReplyData reply = new GXReplyData(); byte[] data; data = Client.SNRMRequest(); if (data != null) { if (Trace > TraceLevel.Info) { Console.WriteLine("Send SNRM request." + GXCommon.ToHex(data, true)); } ReadDataBlock(data, reply); if (Trace == TraceLevel.Verbose) { Console.WriteLine("Parsing UA reply." + reply.ToString()); } //Has server accepted client. Client.ParseUAResponse(reply.Data); if (Trace > TraceLevel.Info) { Console.WriteLine("Parsing UA reply succeeded."); } } }
public void InitializeConnection(GXManufacturer man) { Manufacturer = man; UpdateManufactureSettings(man.Identification); if (Media is GXSerial) { Console.WriteLine("Initializing serial connection."); InitSerial(); } else if (Media is GXNet) { Console.WriteLine("Initializing Network connection."); InitNet(); //Some Electricity meters need some time before first message can be send. System.Threading.Thread.Sleep(500); } else { throw new Exception("Unknown media type."); } GXReplyData reply = new GXReplyData(); byte[] data; data = Client.SNRMRequest(); if (data != null) { if (Trace) { Console.WriteLine("Send SNRM request." + GXCommon.ToHex(data, true)); } ReadDLMSPacket(data, reply); if (Trace) { Console.WriteLine("Parsing UA reply." + reply.ToString()); } //Has server accepted client. Client.ParseUAResponse(reply.Data); Console.WriteLine("Parsing UA reply succeeded."); } //Generate AARQ request. //Split requests to multiple packets if needed. //If password is used all data might not fit to one packet. reply.Clear(); ReadDataBlock(Client.AARQRequest(), reply); try { //Parse reply. Client.ParseAAREResponse(reply.Data); reply.Clear(); } catch (Exception Ex) { reply.Clear(); ReadDLMSPacket(Client.DisconnectRequest(), reply); throw Ex; } //Get challenge Is HLS authentication is used. if (Client.IsAuthenticationRequired) { foreach (byte[] it in Client.GetApplicationAssociationRequest()) { reply.Clear(); ReadDLMSPacket(it, reply); } Client.ParseApplicationAssociationResponse(reply.Data); } Console.WriteLine("Parsing AARE reply succeeded."); }
public void ParseUAResponse(GXByteBuffer data) { client.ParseUAResponse(data); }