한국어 English Chinese Russian
bannerbar

Q&A



Your information is protected by SSL.
No. 609 Re: Re: Broadcasting CIE-H10 2011-04-18

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 GetModbusClients() {
List clients = new 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 Goos van Beek Company GBSD