public void Receive(MPacketReceived packetIn)
        {
            packetIn.isGood = false;
            int tries = 0;

            while (!packetIn.isGood && tries++ <= 3)
            {
                //log("Receive() - waiting... try " + tries);
                packetIn.m_string = base.Receive();
                //log("received: " + packetIn.m_string);
                if (packetIn.m_string.StartsWith("$PMGNCSM"))
                {
                    log("received astray CSM: " + packetIn.m_string);
                    tries--;
                    continue;
                }
                if (m_handshake)
                {
                    string     cs     = NmeaPacket.checksumReceived(packetIn.m_string);
                    MPacketCsm packet = new MPacketCsm(cs);
                    string     str    = packet.ToString() + NmeaPacket.checksum(packet.ToString());
                    log("sending handshake response: " + str);
                    base.Send(str);
                }
                if (!NmeaPacket.checksumVerify(packetIn.m_string))
                {
                    packetIn.isGood = false;
                    if (m_handshake)
                    {
                        logError("bad checksum, waiting for resent packet");
                    }
                    else
                    {
                        logError("bad checksum, returning bad packet");
                        break;                          // just report the received package, isGood = false
                    }
                }
                else
                {
                    packetIn.isGood = packetIn.basicParse(packetIn.m_string);
                    // packet is good and parsed, so the fields array is filled
                }
            }
            logPacket("received " + (packetIn.isGood?"good":"bad") + " packet=" + packetIn);
        }
 public void Receive(MPacketReceived packetIn)
 {
     packetIn.isGood = false;
     int tries = 0;
     while(!packetIn.isGood && tries++ <= 3)
     {
         //log("Receive() - waiting... try " + tries);
         packetIn.m_string = base.Receive();
         //log("received: " + packetIn.m_string);
         if(packetIn.m_string.StartsWith("$PMGNCSM"))
         {
             log("received astray CSM: " + packetIn.m_string);
             tries--;
             continue;
         }
         if(m_handshake)
         {
             string cs = NmeaPacket.checksumReceived(packetIn.m_string);
             MPacketCsm packet = new MPacketCsm(cs);
             string str = packet.ToString() + NmeaPacket.checksum(packet.ToString());
             log("sending handshake response: " + str);
             base.Send(str);
         }
         if (!NmeaPacket.checksumVerify(packetIn.m_string))
         {
             packetIn.isGood = false;
             if(m_handshake)
             {
                 logError("bad checksum, waiting for resent packet");
             }
             else
             {
                 logError("bad checksum, returning bad packet");
                 break;	// just report the received package, isGood = false
             }
         }
         else
         {
             packetIn.isGood = packetIn.basicParse(packetIn.m_string);
             // packet is good and parsed, so the fields array is filled
         }
     }
     logPacket("received " + (packetIn.isGood?"good":"bad") + " packet=" + packetIn);
 }