Beispiel #1
0
        public void TestI2cBoardSerialBad()
        {
            I2cBoard brd = new I2cBoard();
            brd.SetSerial("0xxx");

            Assert.AreEqual(0, brd.SerialNum, "Serial number is incorrect.");
            Assert.AreEqual("", brd.Revision, "Revision is incorrect.");
            Assert.AreEqual(I2cBoardId.UNKNOWN, brd.ID, "Board ID is incorrect.");
        }
Beispiel #2
0
 /// <summary>
 /// Constructor.
 /// 
 /// Initialize lists.
 /// </summary>
 public I2cMemDevs()
 {
     // Initialize lits
     RvcrRegs = new List<I2cRegister>();
     RtcRegs = new List<I2cRegister>();
     IoBoard = new I2cBoard();
     LowPwrRegBoard = new I2cBoard();
     XmitterBoard = new I2cBoard();
     VirtualGndBoard = new I2cBoard();
     RcvrBoard = new I2cBoard();
     BackPlaneBoard = new I2cBoard();
 }
Beispiel #3
0
        public void TestI2cBoardSerial()
        {
            I2cBoard brd = new I2cBoard();
            brd.SetSerial("011");

            Assert.AreEqual(11, brd.SerialNum);
            Assert.AreEqual("", brd.Revision, "Revision is incorrect.");
            Assert.AreEqual(I2cBoardId.UNKNOWN, brd.ID, "Board ID is incorrect.");
        }
Beispiel #4
0
            /// <summary>
            /// Try to decode the board values.
            /// 
            /// If there is an error parsing the board ID,
            /// the ID will be left as Unknown.
            /// 
            /// Ex:
            /// id = 50007 or 50007-06
            /// rev = REV:XD1  
            /// serial = SER#010
            /// </summary>
            /// <param name="id">ID string.</param>
            /// <param name="rev">Revision string.</param>
            /// <param name="serial">Serial string.</param>
            /// <returns>Information about the board.</returns>
            private static I2cBoard DecodeBoardValues(string id, string rev, string serial)
            {
                I2cBoard board = new I2cBoard();

                // Do nothing with the board frequency yet
                string boardFreq = "";

                // Try to parse the Board ID
                // If there is an error return NULL
                int boardId = 0;

                // Newer boards will have a board ID and frequency
                // This will convert the id if it contains the frequency also
                if (id.Contains("-"))
                {
                    char[] delimiter = new char[]{'-'};
                    string[] boardIdFreq = id.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                    if (boardIdFreq.Length >= 2)
                    {
                        id = boardIdFreq[0];                // Board ID
                        boardFreq = boardIdFreq[1];         // Board Freq
                    }
                }

                // Convert the board ID to int
                if (int.TryParse(id, out boardId))
                {
                    board.ID = (I2cBoardId)boardId;
                }

                // Parse the Revision
                // Split by semicolon (:)
                char[] delimiters = new char[] { ':' };
                string[] revision = rev.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                if (revision.Length >= 2)
                {
                    board.Revision = revision[1];
                }

                // Parse the Serial Number
                // Split by pound sign (#)
                delimiters = new char[] { '#' };
                string[] serialNum = serial.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                if (serialNum.Length >= 2)
                {
                    board.SetSerial(serialNum[1]);
                }

                return board;
            }