Main Site Documentation

Com trouble. Need help Please…


#1

I am new to micro framework and I have been ask to design a high speed serial logger. So I start with panda II. When receiving I am missing some of the RX data. My data packet is 92 bytes long and I am getting 32 packets in 1 second and I have 3 of these channels coming to the system at same time.

My simple code as follows
public static void Comm2_Thread()
{
SerialPort UART = new SerialPort(“COM4”, 57600);
byte[] rx_byte = new byte[2000];
int read_count = 0;
UART.Open();

        while (true)
        {
            Debug.GC(false);
            // Thread.Sleep(1000);
           
            read_count = UART.Read(rx_byte, 0, 2000);
            string pk1 = "";

            if (read_count > 0)// do we have data?
            {
                int xx_cou = 0;
                while (xx_cou < read_count)
                {




                    try
                    {
                        byte[] a1 = new byte[1];
                        a1[0] = rx_byte[xx_cou];
                        string a2 = new     string((Encoding.UTF8.GetChars(a1)));

                        pk1 = pk1 + a2;
                    }
                    catch { }
   


                    xx_cou = xx_cou + 1;
                }



            }
            Debug.Print("--------------------------------------------------------------------");
            Debug.Print("COM4  " + pk1);
        }  
    }

I am getting overlap of packets in 256th to ~ 266th byte, but next 1744 is perfect. My first thought was my TX data stream too fast and I set to transmit only 2 packets per second but error is still there. Then I try to get only first 200 bytes at a time but in some times I get few data missing in the middle. I know at the moment I am not synchronize the incoming data but it should not be a problem when I am interested in reading the buffer.

Sample of incoming data
0.07798058_A,000,001.09,-001.70,M,+344.22,+021.01,00,+0.0001,+0.0002,+0.0004,+0.0004,-50.00C,
Packet overlapping due to error
0.1786935_Y,360,236.25,-025.23,M,+F,090,002.10,+005.67,M,-345.21,+021.01,02,+0.0001,+0.0002,+0.0004,+0.0004,-45.21C,

Am I expecting too much from Panda II or I am missing some thing?
I really need a solution quickly
Thanks
:’(


#2

Why post multiple times? Why ask us to answer asap?

We always respond asap and answer every question!!