コード例 #1
0
        public void UpdateEpoData(byte[] fileData) //TODO: try and use https://github.com/f5eng/mt3339-utils/blob/gps/epoloader as this fails.
        {
            this.failCount = 0;
            this.epoCount = 0;
            this.epoFileData = fileData;
            //this.flagAGPS = false;
            this.finalEpoPacketRequired = false;
            this.flagStop = false;
            //this.totEPOcnt = epoFileData.Length / SatSetSize; // = 32

            if (this.epoFileData.Length % 1920 != 0)
            {
                Debug.WriteLine("EPO File is corrupt");
            }
            else
            {
                var b = UTF8Encoding.UTF8.GetBytes(ENTER_BINARY_MODE);
                outputDataWriter.WriteBytes(b); // GPS chipset from nmea- to bin-mode at 57600bps
                Thread.Sleep(500);
                //serialPort.Close();

                currentProtocol = CommsProtocol.Binary;

                serialPort.BaudRate = 57600;
                //serialPort.Open();

                this.SendEpoPacket();
                Debug.WriteLine("Starting to send epo packets");
            }

        }
コード例 #2
0
        private bool validateArgs(Dictionary <string, string> cmdLineArgs)
        {
            protocol = CommsProtocol.NONE;

            if (cmdLineArgs[reqArgs[0]].ToUpper().Equals("RTU"))
            {
                //this is not supported yey only ethernet is supported
                logger.Debug("Using RTU Protocol");
                protocol = CommsProtocol.RTU;
            }
            else if (cmdLineArgs[reqArgs[0]].ToUpper().Equals("IP"))
            {
                logger.Debug("Using ETHERNET Protocol");
                protocol = CommsProtocol.ETHERNET;
            }
            else
            {
                logger.Debug("Inavlid protocol specified : " + cmdLineArgs[reqArgs[0]].ToUpper());
                this.lastError = "Unknown protocol " + cmdLineArgs[reqArgs[0]].ToUpper();
                return(false);
            }

            if (protocol == CommsProtocol.NONE)
            {
                return(false);
            }

            //get interface if specified
            if (cmdLineArgs.ContainsKey(optArgs[0]))
            {
                interfaceName = cmdLineArgs[optArgs[0]];
                logger.Debug("Interface is specified : " + interfaceName);
            }
            else
            {
                interfaceName = null;
            }

            return(true);
        }
コード例 #3
0
        private void SetModeNMEA(uint baudRate)
        {
            byte[] NemaPacket = new byte[14];
            NemaPacket[0] = 0x04; NemaPacket[1] = 0x24;                    // Preamble
            NemaPacket[2] = 0x0E; NemaPacket[3] = 0x00;                    // Length
            NemaPacket[4] = 0xFD; NemaPacket[5] = 0x00;                    // Command: Change UART packet protocol
            NemaPacket[6] = 0x00;                                          // PMTK protocol
            NemaPacket[7] = (byte)(baudRate & 0xFF);                       // Set UART baudrate (4 bytes)
            NemaPacket[8] = (byte)((baudRate >> 8) & 0xFF);
            NemaPacket[9] = (byte)((baudRate >> 16) & 0xFF);
            NemaPacket[10] = (byte)((baudRate >> 24) & 0xFF);
            NemaPacket[11] = GenerateChecksum(NemaPacket);                  // Checksum
            NemaPacket[12] = 0x0D; NemaPacket[13] = 0x0A;                   // End word

            outputDataWriter.WriteBytes(NemaPacket);
            //Thread.Sleep(500);
            //serialPort.Close();
            serialDevice.BaudRate = baudRate;
            currentProtocol = CommsProtocol.ASCII;
            //serialDevice.Open();
            Debug.WriteLine("Set to NEMA mode");
        }