Auto-Find Example
The example has a button and a list box as
follows:
• When the button is clicked function
button1_Click() is called that sends a UDP
broadcast on port 46000 containing
“MonitIR?”.
• The list box is populated with the replies
contents
This could be rejigged to suit a multithreading
app by using non-blocking calls instead of
using the ReceiveTimeout.
// MonitIRfinder note the changed offsets
within ServerResponseData
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace MonitIRfind
{
public partial class MonitIRfinder : Form
{
public MonitIRfinder()
{
InitializeComponent();
}
private void button1_Click(object sender,
EventArgs e)
{
var client = new UdpClient();
var RequestData = Encoding.ASCII.
GetBytes(“MonitIR?”);
var ServerEp = new IPEndPoint(IPAddress.
Any, 0);
client.EnableBroadcast = true;
client.Client.ReceiveTimeout = 3000;
listBox1.Items.Clear();
// send data: “MonitIR?”
client.Send(RequestData, RequestData.Length,
new IPEndPoint(IPAddress.Broadcast, 46000));
// then receive data
while (true)
{
try
{
var ServerResponseData = client.
Receive(ref ServerEp);
var ServerResponse = Encoding.ASCII.Get-
String(ServerResponseData).Substring(0, 24);
var ServerVer = “”;
var ServerMac = “”;
var ServerLocation = “”;
if (ServerResponseData.Length > 25)
{
ServerVer = ServerResponseData[25].
ToString();
ServerMac = BitConverter.ToString(ServerRe
sponseData.Skip(26).Take(6).ToArray());
ServerLocation = Encoding.ASCII.GetString(
ServerResponseData).Substring(32, 16);
}
listBox1.BeginUpdate();
listBox1.Items.Add(ServerRe “ at “ +
ServerEp.Address.ToString() + “ Ver: “ + ServerV-
er + “ MAC: “ + Ser “ Location: “ +
ServerLocation);
listBox1.EndUpdate();
}
catch (Exception exc) { break; }
}
client.Close();
}
}
}
Parse the response as follows
Bytes[0..24] = “MonitIR-“+serial_number,
bytes[25] = hardware_version, bytes[26..31] =
mac address, bytes[32..47] = location
Hardware version identifies the units as
MN4000 / MN4100 and reflects hardware
defined signals.
The hardware signals are PB[15:14] copied as
HWVersion[1:0]
RUGGED
AUTHORITY
MONITIR Series Thermal Imaging Cameras
– User Manual
35
Document Reference MONITIRSERIESUM Rev. A