예제 #1
0
 private void raiseAppSerialDataEvent(byte[] buf)
 {
     _state = State_Emul.WAIT_REQUEST;
     read   = buf.Length;
     //WAIT_REQUEST(buf.Length);
     Buffer.BlockCopy(buf, 0, readData, 0, buf.Length);
 }
예제 #2
0
 private void WAIT_REQUEST_ID()
 {
     if (readData[3] == 0x00 && readData[4] == 0x00)
     {
         if (readData[6] == CSStuff.calculateCS(readData, 6))
         {
             type_msg[1]  = readData[1];
             type_msg[2]  = readData[2];
             type_msg[13] = CSStuff.calculateCS(type_msg, 13);
             Thread.Sleep(10);
             StreamWriter(type_msg, 0, 14);
         }
     }
     _state = State_Emul.WAIT;
 }
예제 #3
0
 private void WAIT_REQUEST_2K()
 {
     if (readData[3] == 0x0F && readData[4] == 0x01)
     {
         //Console.WriteLine("*");
         if (readData[9] == CSStuff.calculateCS(readData, 9))
         {
             //Console.WriteLine("!");
             int len = 7 + Convert.ToInt32(readData[8]);
             Array.Copy(byteBlock, dataSend, len);
             dataSend[1]       = readData[1];
             dataSend[2]       = readData[2];
             dataSend[5]       = readData[8];
             dataSend[len - 1] = CSStuff.calculateCS(dataSend, len - 1);
             Thread.Sleep(10);
             StreamWriter(dataSend, 0, len);
             //Console.Write("-----");
         }
     }
     _state = State_Emul.WAIT;
     //_port.DiscardInBuffer();
     //_port.DiscardOutBuffer();
 }
예제 #4
0
        private void WAIT_REQUEST()
        {
            switch (read)
            {
            case 7:
                _state = State_Emul.WAIT_REQUEST_ID;
                break;

            case 10:
                _state = State_Emul.WAIT_REQUEST_2K;
                //_state = State_Emul.WAIT;
                break;

            case 12:
                _state = State_Emul.WAIT_REQUEST_FLASH;
                //_state = State_Emul.WAIT;
                break;

            default:
                _state = State_Emul.WAIT;
                break;
            }
        }
예제 #5
0
 private void WAIT_REQUEST_FLASH()
 {
     _state = State_Emul.WAIT;
     //_port.DiscardInBuffer();
     //_port.DiscardOutBuffer();
 }
예제 #6
0
 private void CLOSE()
 {
     _state = State_Emul.WAIT;
     //_port.DiscardInBuffer();
     //_port.DiscardOutBuffer();
 }