Hi!
Can you help me find out why my code doesnt work if I inserted its real application (UART interfacing with RFID reader). Here’s the code.
using System.Threading;
using System;
using Microsoft.SPOT;
using System.IO.Ports;
using Microsoft.SPOT.Input;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Microsoft.SPOT.Touch;
using GHIElectronics.NETMF.Glide;
using GHIElectronics.NETMF.Glide.Display;
using GHIElectronics.NETMF.Glide.UI;
namespace Test
{
public class Program : Microsoft.SPOT.Application
{
static Window window;
static bool ByteArrayCompare(byte[] a1, byte[] a2)
{
//if (a1.Length != a2.Length)
// return false;
for (int i = 0; i < a1.Length; i++)
if (a1[i] != a2[i])
return false;
return true;
}
static int maximum(byte[] numbers)
{
byte m = numbers[0];
int index = 0; int maxint = 0;
for (index = 0; index < numbers.Length; index++)
if (m < numbers[index])
{
m = numbers[index];
maxint = index;
}
return maxint;
}
// This will hold the main window.
static int maxim(byte[] numbers)
{
byte m = numbers[0];
int index = 0; int maxint = 0;
for (index = 0; index < numbers.Length; index++)
if (m < numbers[index])
{
m = numbers[index];
maxint = index;
}
return maxint;
}
private static string ByteArrayToHex(byte[] barray)
{
char[] c = new char[barray.Length * 2];
byte b;
for (int i = 0; i < barray.Length; ++i)
{
b = ((byte)(barray[i] >> 4));
c[i * 2] = (char)(b > 9 ? b + 0x37 : b + 0x30);
b = ((byte)(barray[i] & 0xF));
c[i * 2 + 1] = (char)(b > 9 ? b + 0x37 : b + 0x30);
}
return new string(c);
}
public static void Main()
{
// Load the window
string xml;
xml = "<Glide Version=\"" + Glide.Version + "\">";
xml += "<Window Name=\"window\" Width=\"320\" Height=\"240\" BackColor=\"dce3e7\">";
xml += "<Button Name=\"init\" X=\"240\" Y=\"8\" Width=\"80\" Height=\"32\" Alpha=\"255\" Text=\"init\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
xml += "<Button Name=\"btn\" X=\"4\" Y=\"202\" Width=\"80\" Height=\"32\" Alpha=\"255\" Text=\"Read\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
xml += "<Button Name=\"stopbtn\" X=\"236\" Y=\"202\" Width=\"80\" Height=\"32\" Alpha=\"255\" Text=\"Clear\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
xml += "<TextBlock Name=\"text0\" X=\"5\" Y=\"9\" Width=\"200\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"Frequency\" X=\"10\" Y=\"102\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"Frequency:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"EPC\" X=\"10\" Y=\"73\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"EPC:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"RSSI\" X=\"10\" Y=\"130\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"RSSI(-):\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"Phase\" X=\"9\" Y=\"158\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"Phase:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBox Name=\"text1\" X=\"105\" Y=\"71\" Width=\"200\" Height=\"32\" Alpha=\"255\" Text=\" \" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"2\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBox Name=\"text2\" X=\"107\" Y=\"103\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBox Name=\"text3\" X=\"106\" Y=\"130\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBox Name=\"text4\" X=\"106\" Y=\"157\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"kHz\" X=\"215\" Y=\"104\" Width=\"50\" Height=\"32\" Alpha=\"255\" Text=\"kHz\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"dBm\" X=\"215\" Y=\"130\" Width=\"50\" Height=\"32\" Alpha=\"255\" Text=\"dBm\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"deg\" X=\"215\" Y=\"158\" Width=\"50\" Height=\"32\" Alpha=\"255\" Text=\"deg\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBlock Name=\"tagsdet\" X=\"89\" Y=\"203\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"Tags Detected:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"0\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
xml += "<TextBox Name=\"text5\" X=\"199\" Y=\"200\" Width=\"35\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"0\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
// xml += "<Image Name=\"img1\" X=\"2\" Y=\"6\" Width=\"317\" Height=\"35\" Alpha=\"255\"/>";
// xml += "<Button Name=\"btn\" X=\"100\" Y=\"104\" Width=\"120\" Height=\"32\" Alpha=\"255\" Text=\"Read\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
xml += "</Window>";
xml += "</Glide>";
// SerialPort UART = new SerialPort("COM1", 115200);
// UART.Handshake = Handshake.None;
// Resize any loaded Window to the LCD's size.
Glide.FitToScreen = true;
// Load the Window XML string.
window = GlideLoader.LoadWindow(xml);
// Activate touch
GlideTouch.Initialize();
// Initialize the window.
InitWin();
// Assigning a window to MainWindow flushes it to the screen.
// This also starts event handling on the window.
Glide.MainWindow = window;
Thread.Sleep(-1);
}
static void InitWin()
{
TextBlock freq = (TextBlock)window.GetChildByName("Frequency");
TextBlock epc = (TextBlock)window.GetChildByName("EPC");
TextBlock rssi = (TextBlock)window.GetChildByName("RSSI");
TextBlock phase = (TextBlock)window.GetChildByName("Phase");
TextBlock tagsdet = (TextBlock)window.GetChildByName("tagsdet");
TextBlock kHz = (TextBlock)window.GetChildByName("kHz");
TextBlock dBm = (TextBlock)window.GetChildByName("dBm");
TextBlock deg = (TextBlock)window.GetChildByName("deg");
TextBlock text = (TextBlock)window.GetChildByName("text0");
// Get the Button
Button btn = (Button)window.GetChildByName("btn");
Button stopbtn = (Button)window.GetChildByName("stopbtn");
Button init = (Button)window.GetChildByName("init");
// Listen for tap events
btn.TapEvent += new OnTap(btn_TapEvent);
stopbtn.TapEvent += new OnTap(stopbtn_TapEvent);
init.TapEvent += new OnTap(init_TapEvent);
}
static void init_TapEvent(object sender)
{
SerialPort UART = new SerialPort("COM1", 115200);
UART.Handshake = Handshake.None;
// int read_count = 0;
var rx_data = new byte[1000];
byte[] datarray = new byte[rx_data.Length];
byte[] b = { 0xFF, 0x00, 0x68, 0x1D, 0x67 };
byte[] gp_on;
byte[] boot = { 0xFF, 0x00, 0x03, 0x1D, 0x0C };
byte[] getprog = { 0xFF, 0x00, 0x0C, 0x1D, 0x03 };
byte[] currprog = new byte[] { 0xFF, 0x01, 0x68, 0x00, 0x00, 0x00, 0xA4, 0xBF };
byte[] gpset = new byte[] { 0xFF, 0x04, 0x96, 0x01, 0x03, 0x01, 0x00, 0x0C, 0x2A };
byte[] testgp = { 0xFF, 0x00, 0x96, 0x00, 0x00, 0x67, 0xBF };
gp_on = new byte[] { 0xFF, 0x02, 0x96, 0x02, 0x01, 0x03, 0xDC };
byte[] gp_off = new byte[] { 0xFF, 0x02, 0x96, 0x02, 0x00, 0x03, 0xDB };
byte[] setprot = new byte[] { 0xFF, 0x02, 0x93, 0x00, 0x05, 0x51, 0x7D };
byte[] getprot = new byte[] { 0xFF, 0x00, 0x63, 0x1D, 0x6C };
byte[] currprot = new byte[] { 0xFF, 0x02, 0x63, 0x00, 0x00, 0x00, 0x05, 0x21, 0x46 };
byte[] setreg = new byte[] { 0xFF, 0x01, 0x97, 0xFF, 0x4B, 0x42 }; //North Am Region(FF0197014BBC), OPEN( FF 01 97 FF 4B 42)
// byte[] rec_reg = new byte[] { 0xFF, 0x00, 0x97, 0x00, 0x00, 0x77, 0x9E };
byte[] setant1 = new byte[] { 0xFF, 0x02, 0x91, 0x01, 0x01, 0x70, 0x3B };
byte[] rec_ant1 = new byte[] { 0xFF, 0x00, 0x91, 0x00, 0x00, 0x17, 0x58 };
byte[] setEPClen = new byte[] { 0xFF, 0x03, 0x9A, 0x01, 0x02, 0x01, 0xAD, 0x5C };
byte[] rec_EPClen = new byte[] { 0xFF, 0x00, 0x9A, 0x00, 0x00, 0xA6, 0x33 };
byte[] clrtagbuf = new byte[] { 0xFF, 0x00, 0x2A, 0x1D, 0x25 };
byte[] rec_clrbuf = new byte[] { 0xFF, 0x00, 0x2A, 0x00, 0x00, 0x01, 0xE8 };
byte[] gettagdata = new byte[] { 0xFF, 0x03, 0x29, 0x01, 0xFF, 0x00, 0x1B, 0x03 };
byte[] setbaud = new byte[] { 0xFF, 0x04, 0x06, 0x00, 0x01, 0xC2, 0x00, 0xA4, 0x60 };
byte[] readconfig1 = new byte[] { 0xFF, 0x02, 0x6A, 0x01, 0x12, 0x2E, 0x5C };
byte[] antconfig = new byte[] { 0xFF, 0x01, 0x61, 0x05, 0xBD, 0xB8 };
byte[] readconfig2 = new byte[] { 0xFF, 0x02, 0x6A, 0x01, 0x0C, 0x2E, 0x42 };
byte[] gettagprot = new byte[] { 0xFF, 0x00, 0x63, 0x1D, 0x6C };
byte[] freqtable = new byte[] { 0xFF, 0x6C, 0x95, 0x00, 0x0D, 0xC3, 0x70, 0x00, 0x0D, 0xC7, 0x58, 0x00, 0x0D, 0xCB, 0x40, 0x00, 0x0D, 0xCF, 0x28, 0x00, 0x0D, 0xD3, 0x10, 0x00, 0x0D, 0xD6, 0xF8, 0x00, 0x0D, 0xDA, 0xE0, 0x00, 0x0D, 0xDE, 0xC8, 0x00, 0x0D, 0xE2, 0xB0, 0x00, 0x0D, 0xE6, 0x98, 0x00, 0x0D, 0xEA, 0x80, 0x00, 0x0D, 0xEE, 0x68, 0x00, 0x0D, 0xF2, 0x50, 0x00, 0x0D, 0xF6, 0x38, 0x00, 0x0D, 0xFA, 0x20, 0x00, 0x0D, 0xFE, 0x08, 0x00, 0x0E, 0x01, 0xF0, 0x00, 0x0E, 0x05, 0xD8, 0x00, 0x0E, 0x09, 0xC0, 0x00, 0x0E, 0x0D, 0xA8, 0x00, 0x0E, 0x11, 0x90, 0x00, 0x0E, 0x15, 0x78, 0x00, 0x0E, 0x19, 0x60, 0x00, 0x0E, 0x1D, 0x48, 0x00, 0x0E, 0x21, 0x30, 0x00, 0x0E, 0x25, 0x18, 0x00, 0x0E, 0x29, 0x00, 0xD0, 0x50 };
byte[] staticQ = new byte[] { 0xFF, 0x04, 0x9B, 0x05, 0x12, 0x01, 0x00, 0x80, 0xAF };
byte[] readpower = new byte[] { 0xFF, 0x02, 0x92, 0x06, 0xA4, 0x47, 0xFD };
TextBlock text = (TextBlock)window.GetChildByName("text0");
UART.ReadTimeout = 0;
if (UART.IsOpen)
{
text.Text = "COM Port open!";
text.Invalidate();
}
/* UART.Write(boot, 0, boot.Length);
Thread.Sleep(700);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0))
{
text.Text = "Initializing";
text.Invalidate();
}
else
{
text.Text = "firmware not ok";
text.Invalidate();
}
UART.Write(getprog, 0, getprog.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "get current program not ok";
text.Invalidate();
}
UART.Write(b, 0, b.Length);
Thread.Sleep(650);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if (ByteArrayCompare(currprog, rx_data))
{
text.Text = "initializing";
text.Invalidate();
// lcd.ShowMessage("Full Power Mode");
Thread.Sleep(200);
}
UART.Write(setbaud, 0, setbaud.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "baud set ok";
text.Invalidate();
}
else
{
text.Text = "baudset not ok";
text.Invalidate();
}
UART.Write(readconfig1, 0, readconfig1.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "read config 1 not ok";
text.Invalidate();
}
UART.Write(antconfig, 0, antconfig.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "get antenna config not ok";
text.Invalidate();
}
UART.Write(readconfig2, 0, readconfig2.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "get read config 2 not ok";
text.Invalidate();
}
UART.Write(gettagprot, 0, gettagprot.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "get current tag protocol not ok";
text.Invalidate();
}
UART.Write(gpset, 0, gpset.Length);
Thread.Sleep(650);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if (ByteArrayCompare(testgp, rx_data))
{
text.Text = "initializing";
text.Invalidate();
// lcd.ShowMessage("Correct GPSettings");
}
else
{
text.Text = "Incorrect GPsettings";
text.Invalidate();
}
UART.Write(setprot, 0, setprot.Length);
Thread.Sleep(650);
read_count = UART.Read(rx_data, 0, rx_data.Length);
Thread.Sleep(500);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "set tag protocol not ok";
text.Invalidate();
}
UART.Write(getprot, 0, getprot.Length);
Thread.Sleep(650);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
// lcd.ShowMessage("TagProt is Gen2");
}
else
{
text.Text = "Incorrect TagProt settings";
text.Invalidate();
}
Thread.Sleep(500);
UART.Write(setreg, 0, setreg.Length);
Thread.Sleep(650);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
// lcd.ShowMessage("Region is Open");
}
else
{
text.Text = "region not set properly";
text.Invalidate();
}
UART.Write(antconfig, 0, antconfig.Length);
Thread.Sleep(100);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "get antenna config not ok";
text.Invalidate();
}
UART.Write(clrtagbuf, 0, clrtagbuf.Length);
Thread.Sleep(650);
read_count = UART.Read(rx_data, 0, rx_data.Length);
if ((rx_data[3] == 0x00) && (rx_data[4] == 0x00))
{
text.Text = "initializing";
text.Invalidate();
}
else
{
text.Text = "tag buff not cleared";
text.Invalidate();
} */
text.Text = "initializing";
text.Invalidate();
}
static void stopbtn_TapEvent(object sender)
{
Button btn = (Button)window.GetChildByName("btn");
// Button stopbtn = (Button)window.GetChildByName("stopbtn");
TextBox text1 = (TextBox)window.GetChildByName("text1");
TextBox text2 = (TextBox)window.GetChildByName("text2");
TextBox text3 = (TextBox)window.GetChildByName("text3");
TextBox text4 = (TextBox)window.GetChildByName("text4");
TextBox text5 = (TextBox)window.GetChildByName("text5");
text1.Text = " ";
text1.Invalidate();
text2.Text = " ";
text2.Invalidate();
text3.Text = " ";
text3.Invalidate();
text4.Text = " ";
text4.Invalidate();
text5.Text = " ";
text5.Invalidate();
InitWin();
// btn.TapEvent += new OnTap(btn_TapEvent);
// stopbtn.TapEvent += new OnTap(stopbtn_TapEvent);
}
// Handle tap events
static void btn_TapEvent(object sender)
{
//\ byte e = new byte();
TextBox text1 = (TextBox)window.GetChildByName("text1");
TextBox text2 = (TextBox)window.GetChildByName("text2");
TextBox text3 = (TextBox)window.GetChildByName("text3");
TextBox text4 = (TextBox)window.GetChildByName("text4");
TextBox text5 = (TextBox)window.GetChildByName("text5");
byte[] datarray ={ 0xFF, 0x40, 0x29, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x02, 0x01, 0xD8, 0x11, 0x0E, 0x16,
0x72, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x27, 0x05, 0x00, 0x00, 0x0E, 0x00, 0x40, 0x10, 0x00, 0x24,
0x00, 0x13, 0x98, 0x42, 0x45, 0x03, 0xE8, 0x11, 0x0E, 0x16, 0x72, 0x00,
0x00, 0x00, 0x21, 0x00, 0x35, 0x05,0x00, 0x00, 0x0E, 0x00, 0x80, 0x30, 0x00, 0x30, 0x08, 0x33,
0xB2, 0xDD, 0xD9, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x39, 0xBB, 0x5B, 0xEE};
int e = datarray[8];
int freqbef1 = 0;
byte[] freqbef = new byte[3];
byte[] rssibef = new byte[e];
byte[] phasebef = new byte[e];
int[] EPCflag = new int[e];
byte[] EPCs = new byte[150];
byte[] EPC = new byte[20];
int intc = 0, count = 0, count1 = 0;
int cnt = 9; int tagcnt = 0; int[] tagptr = new int[e + 1];
int m = 0;
int size = 0;
tagptr[0] = cnt; intc++; //int freqaft1 = 0;
freqbef[count1++] = datarray[cnt + 3];
freqbef[count1++] = datarray[cnt + 4];
freqbef[count1] = datarray[cnt + 5];
freqbef1 = freqbef[count1] + (freqbef[count1 - 1] << 8) + (freqbef[count1 - 2] << 16);
int EPCont = 0;
do
{
m = 0;
if (datarray[cnt + 17] == 0x80)
{
// lcd.ShowMessage("EPC length is 0x80 XD"); Thread.Sleep(500);
EPCflag[tagcnt] = 1;
size += 12;
do
{
EPCs[EPCont] = datarray[(cnt + m) + 20];
m++; EPCont++;
} while (m < 12);
cnt += 34;// Thread.Sleep(100);
tagptr[intc++] = cnt;
}
else if (datarray[cnt + 17] == 0x40)
{
// lcd.ShowMessage("EPC length is 0x40"); Thread.Sleep(500);
size += 4;
do
{
EPCs[EPCont] = datarray[(cnt + m) + 20];
m++; EPCont++;
} while (m < 4);
cnt += 26;
EPCflag[tagcnt] = 2;
tagptr[intc++] = cnt;
}
tagcnt++;
} while (tagcnt < e);
cnt = tagcnt = 0; count = 0;
// int n = 0;
/* do
{
lcd.ShowMessage("EPCflag [" + n + "]: " + EPCflag[n]);
Thread.Sleep(1500);
n++;
} while (n < e); */
// n = 0;
/* do
{
lcd.ShowMessage("EPCs [" + n + "]: " + EPCs[n]); Thread.Sleep(100); n++;
} while (n < EPCont); */
tagcnt = 0; int index = 0;
do
{
index = tagptr[tagcnt];
rssibef[count] = datarray[index + 1];
phasebef[count++] = datarray[index + 9];
tagcnt++;
} while (tagcnt < e); int j = 0; cnt = 0; int p = 0; tagcnt = 0;
index = 0;
do
{
if (EPCflag[j] == 2)
{
while (cnt < 4)
{
Array.Copy(EPCs, p, EPC, 0, 4); cnt = 4;
// lcd.ShowMessage("EPC: [" + tagcnt + "] " + EPCs[p++]); Thread.Sleep(1000); cnt++;
} //p += 12;
p = p+ 4;
}
if (EPCflag[j] == 1)
{
while (cnt < 12)
{
Array.Copy(EPCs, p++, EPC, 0, 12); cnt = 12;
// lcd.ShowMessage("EPC: [" + tagcnt + "] " + EPCs[p++]); Thread.Sleep(1000); cnt++;
}// p += 4;
p = p + 12;
}
text1.Text = ByteArrayToHex(EPC);
text1.Invalidate();
text2.Text = freqbef1.ToString();
text2.Invalidate();
// lcd.ShowMessage("Frequency:" + freqbef1); Thread.Sleep(500);
text3.Text = (256 - rssibef[j]).ToString();
text3.Invalidate();
// lcd.ShowMessage("RSSI [" + j + "] -" + (256 - rssibef[j]));
// Thread.Sleep(500);
text4.Text = phasebef[j].ToString();
text4.Invalidate();
text5.Text = e.ToString();
text5.Invalidate();
// lcd.ShowMessage("Phases [" + j + "] " + phasebef[j]);
Thread.Sleep(500);
j++; tagcnt++; cnt = 0;
} while (j < e);
}
}
}
I would really appreciate your help. 

pardon for this…