Thanks for at least reading this. Quick overview: I am new to object oriented programming (go FORTRAN) and have jumped into developing a C#.NET application that allows a user to input some values in a GUI, confirm it, and then transmit over a RF Modem while displaying received data. I am using two Xbee-PRO USB modems from Digi in a pseudo null modem test. I am using C# Express 2008 on a Dell Laptop with XP OS.
My current problem (that I have been Googleing and reading forums for two days now) is there is and issue with receiving the data. By adding in some IO, I dumped a copy of my Xmit structure into some log.txt and it was perfect every time with the entire 128 byte structure. On the other end I dumped the Incoming buffer into some log.txt and there would only be 110-124 bytes on a single structure. I thought this could just be chopping off the end but after multiple packets the entire receive structure gets jumbled. The Int16 Sync word starts in mid structure of a prior transmission structure. I should note that the 128 byte structure only has ~70 useful bytes in it with byte[70:128] = 0.
My current efforts on resolving this issue is to look at data control. IE I think I am not controlling my memory and the errors are induced by how I handle SerialPortDataReceived events. There is some error checking and locating that I am doing with the TestSync() function but this locks on to the first two 85 sync bytes everytime. I have deleted some other erroneous junk that I added to try and fix this problem. I think I have disabled FIFO on the modems so that it writes data as it comes (90% sure).
BreakupIncomingAttitude() is the main point where the Class "STB" takes the 128 byte[] structure and populates the encapsulated properties. Don't stone me but to pass data between Forms I made the STB Class public. This was how I first got it working and have not messed with it, yet.
serialPort1 Properties:
Baud 11520
Byte Threshold 128
No flow control - Another beast I have not tried to tackle but probably next
-
-
public Main()
-
{
-
serialPort1.DataReceived +=new System.IO.Ports.SerialDataReceivedEventHandler(serialPort1_DataReceived);
-
}
-
-
void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
-
{
-
serialPort1.Read(buff_RecivedData, 0, serialPort1.BytesToRead);
-
-
if (Array.Exists(buff_RecivedData, TestSync))
-
{
-
int PossibleSync = Array.FindIndex(buff_RecivedData, TestSync);
-
Buffer.BlockCopy(buff_RecivedData, PossibleSync, adjust_RecivedData, 0, 128);
-
-
this.STB1.BreakupIncomingAttitude(adjust_RecivedData); // Main Data
-
-
UpdateIN(adjust_RecivedData); // File IO
-
-
var d = new Update_Text(update_TEL); // GUI Display
-
this.BeginInvoke(d);
-
-
}
-
}
-
-
You|Help|Please
Sam T.