public void ReadFrame() { uint handle = 0; var rxMsg = new NiCan.NCTYPE_CAN_STRUCT(); /*** Config ***/ uint[] AttrIdList = { NiCan.NC_ATTR_BAUD_RATE, NiCan.NC_ATTR_START_ON_OPEN }; uint[] AttrValueList = { Baudrate, NiCan.NC_FALSE }; uint NumAttrs = 2; int status = NiCan.ncConfig(new StringBuilder(Interface), NumAttrs, AttrIdList, AttrValueList); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); /*** Open Object ***/ status = NiCan.ncOpenObject(new StringBuilder(Interface), ref handle); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); /*** Start ***/ status = NiCan.ncAction(handle, NiCan.NC_OP_START, 0); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); var timestamp = System.DateTime.Now; bool flag = false; int tryCount = 0; do { /*** Get NC_ATTR_READ_PENDING ***/ uint msgspending = 0; status = NiCan.ncGetAttribute(handle, NiCan.NC_ATTR_READ_PENDING, 4, ref msgspending); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); if (msgspending != 0) { /*** Read ***/ status = NiCan.ncRead(handle, NiCan.CanStructSize, ref rxMsg); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); /*** Msg Write Console ***/ Debug.WriteLine("Timestamp:" + rxMsg.TimeStamp.ToString("X")); Debug.WriteLine("ArbitrationId:" + rxMsg.ArbitrationId.ToString("X")); Debug.WriteLine("FrameType:" + rxMsg.FrameType.ToString()); Debug.WriteLine("DataLength:" + rxMsg.DataLength.ToString()); Debug.WriteLine("Data64:" + rxMsg.Data64.ToString("X")); Debug.WriteLine("Data7:" + rxMsg.Data7.ToString()); flag = true; } tryCount++; } while ((System.DateTime.Now - timestamp).Seconds < 10); if (!flag) { Debug.WriteLine("I did not received any messages..."); } Debug.WriteLine("I checked:" + tryCount.ToString() + " times."); /*** Stop ***/ status = NiCan.ncAction(handle, NiCan.NC_OP_STOP, 0); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); /*** Close ***/ status = NiCan.ncCloseObject(handle); Assert.AreEqual(0, status, NiCanTools.StatusToString(status)); }