No. 610 | Re: Re: Re: Broadcasting CIE-H10 | 2011-04-19 | ||
---|---|---|---|---|
Hello again. This is technical support team of sollae systems. I'm so sorry. unfortunatelly you can't use it like this code. (byte[] value = { 0x2a, 0x76, 0x4e, 0x01, 0x10, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };) You can receive the response from CIE-H10. But It is packed with our technical solution. It is not a BigEndian encoding. There are so many procedure to search or manage. So we can't open the source. I'm sorry again. I recommend you use a library of ezManager. (C++, VB) Library Have a nice day. Thank you. > Goos van Beek wrote: > ------------------------------------ > Dear madam or Sir, > > Thank you very much for responding. > > My CIE-H10 units are in a DHCP network. I use my own application to detect the units. > I've written a (C#) class to broadcast the units. > > The response from an unit is a byte array. I was wondering if there is useful information in that response, which I can use to identify the unit. > Now I get the mac address to identify the unit (from the ARP table), but that is an extra action on the network. > > I get the response from the unit, but I can not read the response. Maybe I use the wrong encoding. Or maybe the encoding is right and there is no info in the response. > > I use this C# code to read the response buffer: > var enc = Encoding.BigEndianUnicode; > string response = enc.GetString(recvBuffer); > (see complete code below) > > This is the encoded response I get from the unit: > "⩶丁ʁĀ賩0龜衧ခ̄钶Ā0龜衧船㧆⩗朲㢳�頻೨묍S䠮驉䆑㗴햢≠�宮킍⦖踣ⅷॱ䋏ᦌ뱷完㝿㤛颍뤚䓓빞뽠Ȃ푏乭鎯糖⾷賤껴畣螩တ抮聾旵웴됞�쓮ꏘ잓卩傷攩০랳⡝渝ⱨ䡛因⣔봲똁ॷӉ⼞籲乱杼⮕衷棶⊥諛夀趽⺸菐糮䲮賈⬤㗍訏ʬ㔼쬮汦�槎⋦怊煙뒣擓�婝㠇砣娚䩶⹜虾㝕虿㺛㚁톗⢠♂卝㾦肏⧅黛共⍱䂴㏌㶄뚜趺卖颋韒࣋앣ᥳ痮ᴧ덿⦅ى填躌⍶꒙跋ॗ奼ၻ선㤰糆⺷䑬肃霱഼寚쀇坤붚�瞺ল⥫탳Ⱞᣨ參苝靹庨뫗�̨轁茵酑Ⲷ㙗锈槥멚岨풃왯ǯ叫帏ⵁ⸐層晤符╯ি팖폫暣碸ߙ曃櫖⍊ⷹ쉨찺ඃ囻㌍估伶留⠏ꔾ︋웬ᘀ옛돵㫀憞刈蟩ɏ碷⟺틁禡똙链胙䆜ⶂꖳ⺆恻갅諶�ᾒ샖⥑�῍뺎毪븐훚䰠�㌮ᗦ裛मⓩ㿏㮮ᣘ륻東뵇ﵜ푎ᝄ贆ା뿶옘秄牝鑥렲圻״涴ڽ�ᶾ겠ﰡԘ톙ﱼ䃒氱劇鯮둹ꦃ풷㱰솦ⱚḪ崔໗ஈ仦축�㿝礞佯뭂煮嗳㴬ꈧ睛�䔕卄ᄱ箼㊽�꒫밻䪚ꢖ䗰庠㬙㼋臱囶縺랼䋾픭罃⽕渡忥ꠕᢜ졧ᙐ㡜滇宝莭價廵粀酐寮ꬣ땏폞䷣鎨롂굣ए⯳ᇑ띋擓琉ƚ認�ﭣ횇ే㙾㲍㬋鷅槦ꗳ㑬芤뜣ᛁ柃Ꝁহ�߉�빎㼒㊴譵褲뚣迱絵ᇔ쪁奜덏將댅䨈귍⺁�勣୰擈�ᆲ謔䱁슖尵絾쫘찻닣ꆢ↫‒嗧⧑渗腆㴦笂뚷⊯놯糦ﲬⰗ㸁⨡Ɜ꾹ల䪭霭累㮍愎Ἶ巈鑙顤嫽揋窒뀐榠鐅⩒ᴑ檱ꋖ푢鱊䄉珫믑쒏迕乺宏䧛죗ꁏ鶭戋㮄廀赏甦냟ᬡ顱悙괰꿣䠽鶥ϺP샰ጸDZ揾�슖ꪯﴭ㱣ዪ쎮鸗乌启咿䣈巹䔜ƚㄇ즿◓盙�姡萻頻稓ﯦ貕㇔鑵⫥⛬᫄䪠滍歱㜚乎ᮯ�矅㿷峪࠶底↉℻版넝硒⾝愺㼦닂㉫䏗ꠓ좿❯↸ࠉ䆟ྌ뢖鼜賡驗䞎ダ꾇⁝耶췾敞䀀밑愳렁ꏜ蜑X沣゙�嘯頰藆굦른⌜(ꅚ뉔抉蠔䔌쏢䗸䔀톅쐏繇퍷㭋䨶쌮職脂ۍ촔ꕌ焓ಠ萩ُ媀ज़ㆹआ꾱⌋ጃ즉ཡ⠋狿냿澒踷ẅ灙⬘繗미" > > > //This is my broadcast class: > namespace Gbsd.Modbus.Test { > #region > > using System; > using System.Collections.Generic; > using System.Net; > using System.Net.Sockets; > using System.Runtime.InteropServices; > using System.Text; > > #endregion > > internal struct ModbusAddress { > internal string IpAddress; > internal string MacAddress; > } > > internal static class IpFromBroadCast { > internal static List > List > > const int RemotePort = 50005; > const int LocalPort = 50005; > byte[] recvBuffer = new byte[1428]; > > var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) { > EnableBroadcast = true > }; > > EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Broadcast, RemotePort); > > socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); > socket.Bind(new IPEndPoint(IPAddress.Any, LocalPort)); > > byte[] value = { 0x2a, 0x76, 0x4e, 0x01, 0x10, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; > try { > socket.SendTo(value, new IPEndPoint(IPAddress.Broadcast, RemotePort)); > } > catch (Exception exeption) { > Console.WriteLine(exeption.StackTrace); > } > > socket.SendTimeout = 100; > socket.ReceiveTimeout = 1000; > > try { > while (true) { > int bytesReceived = socket.ReceiveFrom(recvBuffer, ref remoteEndPoint); > > // CIE-H10 response is 1428 bytes > if (bytesReceived != 1428) { > continue; > } > > /////////////////////////////////////////////// > var enc = Encoding.BigEndianUnicode; // > string response = enc.GetString(recvBuffer); // > /////////////////////////////////////////////// > > remoteEndPoint.Serialize(); > var ipEndPoint = (IPEndPoint)remoteEndPoint; > string ipAddress = ipEndPoint.Address.ToString(); > string macAddress = string.Empty; > if (ipAddress.Length > 10) { > macAddress = GetMacAddressFromIp(ipAddress); > } > > ModbusAddress modbusAddress; > modbusAddress.IpAddress = ipAddress; > modbusAddress.MacAddress = macAddress; > clients.Add(modbusAddress); > } > } > catch (Exception exeption) { > Console.WriteLine(exeption.StackTrace); > } > finally { > socket.Close(); > } > > return clients; > } > > [DllImport("iphlpapi.dll", ExactSpelling = true)] > public static extern int SendARP(int destIp, int srcIP, byte[] macAddr, ref uint physicalAddrLen); > > private static string GetMacAddressFromIp(string address) { > var dst = IPAddress.Parse(address); > var macAddr = new byte[6]; > uint macAddrLen = (uint)macAddr.Length; > > if (SendARP(BitConverter.ToInt32(dst.GetAddressBytes(), 0), 0, macAddr, ref macAddrLen) != 0) { > throw new InvalidOperationException("SendARP failed."); > } > > var str = new string[(int)macAddrLen]; > for (int i = 0; i < macAddrLen; i++) { > str[i] = macAddr[i].ToString("x2"); > } > > string output = string.Join(":", str); > return output; > } > } > } > > > > Best regards, > Goos van Beek. > > > > Sollae Systems wrote: > > ------------------------------------ > > Hello. > > > > This is technical support team of Sollae Systems. > > > > I'm sorry, but I am not sure what you exactly want. > > > > Do you receive the return messege from ezManager or not? > > > > Unless you use ezManager, what do you use for that? > > > > Please, send us screenshots and more information about that. > > > > It can be helpful to support your inquiry. > > > > Have a good day. > > > > Thank you. > > > > > Goos van Beek wrote: > > > ------------------------------------ > > > Dear Madam or Sir, > > > > > > I'm using the CIE-H10 in a DHCP network. While the unit has no host name I'm detecting it by a broadcast op port 50005. > > > This returns the IPAddress, but I can't decipher the response result from the unit. For me it looks like Korean. I use BigEndianUniCode to encode the response. > > > Is there another way to encode the response in readable language, or is it really Korean? > > > Or is there no useful information in the broadcast response, like the mac address? > > > > > > Regards, > > > Goos van Beek. > > > > > >'>Hello again. This is technical support team of sollae systems. I'm so sorry. unfortunatelly you can't use it like this code. (byte[] value = { 0x2a, 0x76, 0x4e, 0x01, 0x10, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };) You can send the receive the response from CIE-H10. But It is packed with our technical solution. It is not a BigEndian encoding. There are so many procedure to search or manage. So we can't open the source. I'm sorry again. I recommend you use a library of ezManager. (C++, VB) Library Have a nice day. Thank you. > Goos van Beek wrote: > ------------------------------------ > Dear madam or Sir, > > Thank you very much for responding. > > My CIE-H10 units are in a DHCP network. I use my own application to detect the units. > I've written a (C#) class to broadcast the units. > > The response from an unit is a byte array. I was wondering if there is useful information in that response, which I can use to identify the unit. > Now I get the mac address to identify the unit (from the ARP table), but that is an extra action on the network. > > I get the response from the unit, but I can not read the response. Maybe I use the wrong encoding. Or maybe the encoding is right and there is no info in the response. > > I use this C# code to read the response buffer: > var enc = Encoding.BigEndianUnicode; > string response = enc.GetString(recvBuffer); > (see complete code below) > > This is the encoded response I get from the unit: > "⩶丁ʁĀ賩0龜衧ခ̄钶Ā0龜衧船㧆⩗朲㢳�頻೨묍S䠮驉䆑㗴햢≠�宮킍⦖踣ⅷॱ䋏ᦌ뱷完㝿㤛颍뤚䓓빞뽠Ȃ푏乭鎯糖⾷賤껴畣螩တ抮聾旵웴됞�쓮ꏘ잓卩傷攩০랳⡝渝ⱨ䡛因⣔봲똁ॷӉ⼞籲乱杼⮕衷棶⊥諛夀趽⺸菐糮䲮賈⬤㗍訏ʬ㔼쬮汦�槎⋦怊煙뒣擓�婝㠇砣娚䩶⹜虾㝕虿㺛㚁톗⢠♂卝㾦肏⧅黛共⍱䂴㏌㶄뚜趺卖颋韒࣋앣ᥳ痮ᴧ덿⦅ى填躌⍶꒙跋ॗ奼ၻ선㤰糆⺷䑬肃霱഼寚쀇坤붚�瞺ল⥫탳Ⱞᣨ參苝靹庨뫗�̨轁茵酑Ⲷ㙗锈槥멚岨풃왯ǯ叫帏ⵁ⸐層晤符╯ি팖폫暣碸ߙ曃櫖⍊ⷹ쉨찺ඃ囻㌍估伶留⠏ꔾ︋웬ᘀ옛돵㫀憞刈蟩ɏ碷⟺틁禡똙链胙䆜ⶂꖳ⺆恻갅諶�ᾒ샖⥑�῍뺎毪븐훚䰠�㌮ᗦ裛मⓩ㿏㮮ᣘ륻東뵇ﵜ푎ᝄ贆ା뿶옘秄牝鑥렲圻״涴ڽ�ᶾ겠ﰡԘ톙ﱼ䃒氱劇鯮둹ꦃ풷㱰솦ⱚḪ崔໗ஈ仦축�㿝礞佯뭂煮嗳㴬ꈧ睛�䔕卄ᄱ箼㊽�꒫밻䪚ꢖ䗰庠㬙㼋臱囶縺랼䋾픭罃⽕渡忥ꠕᢜ졧ᙐ㡜滇宝莭價廵粀酐寮ꬣ땏폞䷣鎨롂굣ए⯳ᇑ띋擓琉ƚ認�ﭣ횇ే㙾㲍㬋鷅槦ꗳ㑬芤뜣ᛁ柃Ꝁহ�߉�빎㼒㊴譵褲뚣迱絵ᇔ쪁奜덏將댅䨈귍⺁�勣୰擈�ᆲ謔䱁슖尵絾쫘찻닣ꆢ↫‒嗧⧑渗腆㴦笂뚷⊯놯糦ﲬⰗ㸁⨡Ɜ꾹ల䪭霭累㮍愎Ἶ巈鑙顤嫽揋窒뀐榠鐅⩒ᴑ檱ꋖ푢鱊䄉珫믑쒏迕乺宏䧛죗ꁏ鶭戋㮄廀赏甦냟ᬡ顱悙괰꿣䠽鶥ϺP샰ጸDZ揾�슖ꪯﴭ㱣ዪ쎮鸗乌启咿䣈巹䔜ƚㄇ즿◓盙�姡萻頻稓ﯦ貕㇔鑵⫥⛬᫄䪠滍歱㜚乎ᮯ�矅㿷峪࠶底↉℻版넝硒⾝愺㼦닂㉫䏗ꠓ좿❯↸ࠉ䆟ྌ뢖鼜賡驗䞎ダ꾇⁝耶췾敞䀀밑愳렁ꏜ蜑X沣゙�嘯頰藆굦른⌜(ꅚ뉔抉蠔䔌쏢䗸䔀톅쐏繇퍷㭋䨶쌮職脂ۍ촔ꕌ焓ಠ萩ُ媀ज़ㆹआ꾱⌋ጃ즉ཡ⠋狿냿澒踷ẅ灙⬘繗미" > > > //This is my broadcast class: > namespace Gbsd.Modbus.Test { > #region > > using System; > using System.Collections.Generic; > using System.Net; > using System.Net.Sockets; > using System.Runtime.InteropServices; > using System.Text; > > #endregion > > internal struct ModbusAddress { > internal string IpAddress; > internal string MacAddress; > } > > internal static class IpFromBroadCast { > internal static List > List > > const int RemotePort = 50005; > const int LocalPort = 50005; > byte[] recvBuffer = new byte[1428]; > > var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) { > EnableBroadcast = true > }; > > EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Broadcast, RemotePort); > > socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); > socket.Bind(new IPEndPoint(IPAddress.Any, LocalPort)); > > byte[] value = { 0x2a, 0x76, 0x4e, 0x01, 0x10, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; > try { > socket.SendTo(value, new IPEndPoint(IPAddress.Broadcast, RemotePort)); > } > catch (Exception exeption) { > Console.WriteLine(exeption.StackTrace); > } > > socket.SendTimeout = 100; > socket.ReceiveTimeout = 1000; > > try { > while (true) { > int bytesReceived = socket.ReceiveFrom(recvBuffer, ref remoteEndPoint); > > // CIE-H10 response is 1428 bytes > if (bytesReceived != 1428) { > continue; > } > > /////////////////////////////////////////////// > var enc = Encoding.BigEndianUnicode; // > string response = enc.GetString(recvBuffer); // > /////////////////////////////////////////////// > > remoteEndPoint.Serialize(); > var ipEndPoint = (IPEndPoint)remoteEndPoint; > string ipAddress = ipEndPoint.Address.ToString(); > string macAddress = string.Empty; > if (ipAddress.Length > 10) { > macAddress = GetMacAddressFromIp(ipAddress); > } > > ModbusAddress modbusAddress; > modbusAddress.IpAddress = ipAddress; > modbusAddress.MacAddress = macAddress; > clients.Add(modbusAddress); > } > } > catch (Exception exeption) { > Console.WriteLine(exeption.StackTrace); > } > finally { > socket.Close(); > } > > return clients; > } > > [DllImport("iphlpapi.dll", ExactSpelling = true)] > public static extern int SendARP(int destIp, int srcIP, byte[] macAddr, ref uint physicalAddrLen); > > private static string GetMacAddressFromIp(string address) { > var dst = IPAddress.Parse(address); > var macAddr = new byte[6]; > uint macAddrLen = (uint)macAddr.Length; > > if (SendARP(BitConverter.ToInt32(dst.GetAddressBytes(), 0), 0, macAddr, ref macAddrLen) != 0) { > throw new InvalidOperationException("SendARP failed."); > } > > var str = new string[(int)macAddrLen]; > for (int i = 0; i < macAddrLen; i++) { > str[i] = macAddr[i].ToString("x2"); > } > > string output = string.Join(":", str); > return output; > } > } > } > > > > Best regards, > Goos van Beek. > > > > Sollae Systems wrote: > > ------------------------------------ > > Hello. > > > > This is technical support team of Sollae Systems. > > > > I'm sorry, but I am not sure what you exactly want. > > > > Do you receive the return messege from ezManager or not? > > > > Unless you use ezManager, what do you use for that? > > > > Please, send us screenshots and more information about that. > > > > It can be helpful to support your inquiry. > > > > Have a good day. > > > > Thank you. > > > > > Goos van Beek wrote: > > > ------------------------------------ > > > Dear Madam or Sir, > > > > > > I'm using the CIE-H10 in a DHCP network. While the unit has no host name I'm detecting it by a broadcast op port 50005. > > > This returns the IPAddress, but I can't decipher the response result from the unit. For me it looks like Korean. I use BigEndianUniCode to encode the response. > > > Is there another way to encode the response in readable language, or is it really Korean? > > > Or is there no useful information in the broadcast response, like the mac address? > > > > > > Regards, > > > Goos van Beek. > > > > > > |
Writer | Sollae Systems | Company | |
|
|||