当前位置: 首页>>代码示例>>C#>>正文


C# CANMessage.setData方法代码示例

本文整理汇总了C#中TrionicCANLib.CAN.CANMessage.setData方法的典型用法代码示例。如果您正苦于以下问题:C# CANMessage.setData方法的具体用法?C# CANMessage.setData怎么用?C# CANMessage.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TrionicCANLib.CAN.CANMessage的用法示例。


在下文中一共展示了CANMessage.setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendTransferData011

        private bool SendTransferData011(int length, int address, uint waitforResponseID)
        {
            CANMessage msg = new CANMessage(0x11, 0, 8); // <GS-24052011> test for ELM327, set length to 16 (0x10)
            ulong cmd = 0x0000000000360010; // 0x36 = transferData
            ulong addressHigh = (uint)address & 0x0000000000FF0000;
            addressHigh /= 0x10000;
            ulong addressMiddle = (uint)address & 0x000000000000FF00;
            addressMiddle /= 0x100;
            ulong addressLow = (uint)address & 0x00000000000000FF;
            ulong len = (ulong)length;

            cmd |= (addressLow * 0x100000000000000);
            cmd |= (addressMiddle * 0x1000000000000);
            cmd |= (addressHigh * 0x10000000000);
            cmd |= (len * 0x100);
            //Console.WriteLine("send: " + cmd.ToString("X16"));
            msg.elmExpectedResponses = 1;
            msg.setData(cmd);
            m_canListener.setupWaitMessage(waitforResponseID);
            if (!canUsbDevice.sendMessage(msg))
            {
                logger.Debug("Couldn't send message");
            }

            CANMessage response = new CANMessage();
            response = new CANMessage();
            response = m_canListener.waitMessage(timeoutP2ct);
            ulong data = response.getData();
            //Console.WriteLine("Received in SendTransferData: " + data.ToString("X16"));
            if (getCanData(data, 0) != 0x30 || getCanData(data, 1) != 0x00)
            {
                return false;
            }
            return true;
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:35,代码来源:Trionic8.cs

示例2: readMessages

 /// <summary>
 /// readMessages is the "run" method of this class. It reads all incomming messages
 /// and publishes them to registered ICANListeners.
 /// </summary>
 public void readMessages()
 {
     int readResult = 0;
     Lawicel.CANUSB.CANMsg r_canMsg = new Lawicel.CANUSB.CANMsg();
     CANMessage canMessage = new CANMessage();
     Console.WriteLine("readMessages started");
     while (true)
     {
         lock (m_synchObject)
         {
             if (m_endThread)
             {
                 Console.WriteLine("readMessages ended");
                 return;
             }
         }
         readResult = Lawicel.CANUSB.canusb_Read(m_deviceHandle, out r_canMsg);
         if (readResult == Lawicel.CANUSB.ERROR_CANUSB_OK)
         {
             if (acceptMessageId(r_canMsg.id))
             {
                 canMessage.setID(r_canMsg.id);
                 canMessage.setLength(r_canMsg.len);
                 canMessage.setTimeStamp(r_canMsg.timestamp);
                 canMessage.setFlags(r_canMsg.flags);
                 canMessage.setData(r_canMsg.data);
                 lock (m_listeners)
                 {
                     AddToCanTrace(string.Format("RX: {0} {1}", canMessage.getID().ToString("X3"), canMessage.getData().ToString("X16")));
                     foreach (ICANListener listener in m_listeners)
                     {
                         listener.handleMessage(canMessage);
                     }
                 }
             }
         }
         else if (readResult == Lawicel.CANUSB.ERROR_CANUSB_NO_MESSAGE)
         {
             Thread.Sleep(1);
         }
     }
 }
开发者ID:josla972,项目名称:Trionic,代码行数:46,代码来源:CANUSBDevice.cs

示例3: sendSessionRequest

        /// <summary>
        /// Send a message that starts a session. This is used to test if there is 
        /// a connection.
        /// </summary>
        /// <returns></returns>
        private bool sendSessionRequest()
        {
            Console.WriteLine("Sending session request");
            // 0x220 is for T7
            // 0x7E0 is for T8
            CANMessage msg1 = new CANMessage(0x220, 0, 8);
            Lawicel.CANUSB.CANMsg msg = new Lawicel.CANUSB.CANMsg();
            msg1.setData(0x000040021100813f);

            if (!sendMessage(msg1))
            {
                Console.WriteLine("Unable to send session request");
                return false;
            }
            if (waitForMessage(0x238, 1000, out msg) == 0x238)
            {
                //Ok, there seems to be a ECU somewhere out there.
                //Now, sleep for 10 seconds to get a session timeout. This is needed for
                //applications on higher level. Otherwise there will be no reply when the
                //higher level application tries to start a session.
                Thread.Sleep(10000);
                Console.WriteLine("sendSessionRequest: TRUE");

                return true;
            }
            Console.WriteLine("sendSessionRequest: FALSE");
            return false;
        }
开发者ID:josla972,项目名称:Trionic,代码行数:33,代码来源:CANUSBDevice.cs

示例4: readMessages

        // int thrdcnt = 0;
        /// <summary>
        /// readMessages is the "run" method of this class. It reads all incomming messages
        /// and publishes them to registered ICANListeners.
        /// </summary>
        public void readMessages()
        {
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        m_endThread = false;
                        return;
                    }
                }
                if (m_serialPort.IsOpen)
                {
                    // read the status?

                    string line = string.Empty;

                    try
                    {
                        line = m_serialPort.ReadLine();
                        if (line.Length > 0)
                        {
                            if (line.Length == 25)
                            {
                                Lawicel.CANUSB.CANMsg r_canMsg = new Lawicel.CANUSB.CANMsg();
                                canMessage = new CANMessage();
                                // three bytes identifier
                                r_canMsg.id = (uint)Convert.ToInt32(line.Substring(1, 3), 16);
                                r_canMsg.len = (byte)Convert.ToInt32(line.Substring(4, 1), 16);
                                ulong data = 0;
                                // add all the bytes
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(5, 2), 16);
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(7, 2), 16) << 1 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(9, 2), 16) << 2 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(11, 2), 16) << 3 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(13, 2), 16) << 4 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(15, 2), 16) << 5 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(17, 2), 16) << 6 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(19, 2), 16) << 7 * 8;
                                r_canMsg.data = data;
                                canMessage.setID(r_canMsg.id);
                                canMessage.setLength(r_canMsg.len);
                                canMessage.setFlags(r_canMsg.flags);
                                canMessage.setData(r_canMsg.data);

                                lock (m_listeners)
                                {
                                    AddToCanTrace(string.Format("RX: {0} {1} {2}", canMessage.getID().ToString("X3"), line.Substring(5, 16), line));
                                    foreach (ICANListener listener in m_listeners)
                                    {
                                        listener.handleMessage(canMessage);
                                    }
                                }
                            }
                            else if(line.Contains("z"))
                            {
                                interfaceBusy = false;
                                //Console.WriteLine("clear");
                            }
                            else if (line.Length == 2 && Convert.ToInt32(line.Substring(1, 2), 16) != 0x07)
                            {
                                //Console.WriteLine("Send error");
                            }
                            else
                            {
                                //Console.WriteLine("Unknown message: " + line);
                            }
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Failed to read frames from CANbus: " + E.Message);
                    }
                }
                //Thread.Sleep(2);
                Thread.Sleep(delayTimespan); // give others some air
            }
        }
开发者ID:josla972,项目名称:Trionic,代码行数:84,代码来源:CANUSBDirectDevice.cs

示例5: readMessages

        /// <summary>
        /// readMessages is the "run" method of this class. It reads all incomming messages
        /// and publishes them to registered ICANListeners.
        /// </summary>
        public void readMessages()
        {
            int readResult = 0;
            Lawicel.CANUSB.CANMsg r_canMsg = new Lawicel.CANUSB.CANMsg();
            CANMessage canMessage = new CANMessage();
            logger.Debug("readMessages started");
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        logger.Debug("readMessages thread ended");
                        return;
                    }
                }
                readResult = Lawicel.CANUSB.canusb_Read(m_deviceHandle, out r_canMsg);
                if (readResult == Lawicel.CANUSB.ERROR_CANUSB_OK)
                {
                    if (acceptMessageId(r_canMsg.id))
                    {
                        canMessage.setID(r_canMsg.id);
                        canMessage.setLength(r_canMsg.len);
                        canMessage.setTimeStamp(r_canMsg.timestamp);
                        canMessage.setFlags(r_canMsg.flags);
                        canMessage.setData(r_canMsg.data);

                        receivedMessage(canMessage);
                    }
                }
                else if (readResult == Lawicel.CANUSB.ERROR_CANUSB_NO_MESSAGE)
                {
                    Thread.Sleep(1);
                }
            }
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:40,代码来源:CANUSBDevice.cs

示例6: sendSessionRequest

        /// <summary>
        /// Send a message that starts a session. This is used to test if there is 
        /// a connection.
        /// </summary>
        /// <returns></returns>
        private bool sendSessionRequest()
        {
            CANMessage msg1 = new CANMessage(0x220, 0, 8);
            EASYSYNC.CANMsg msg = new EASYSYNC.CANMsg();
            msg1.setData(0x000040021100813f);

            if (!sendMessage(msg1))
                return false;
            if (waitForMessage(0x238, 1000, out msg) == 0x238)
            {
                //Ok, there seems to be a ECU somewhere out there.
                //Now, sleep for 10 seconds to get a session timeout. This is needed for
                //applications on higher level. Otherwise there will be no reply when the
                //higher level application tries to start a session.
                Thread.Sleep(10000);
                return true;
            }
            return false;
        }
开发者ID:josla972,项目名称:Trionic,代码行数:24,代码来源:EasySyncUSBDevice.cs

示例7: read_messages

        //-------------------------------------------------------------------------
        /**
        Handles incoming messages.
        */
        private void read_messages()
        {
            uint id;
            byte length;
            ulong data;

            CANMessage msg = new CANMessage();
            Debug.Assert(msg != null);

            // main loop
            while (true)
            {
            // check for thread termination request
            Debug.Assert(this.term_mutex != null);
            lock (this.term_mutex)
            {
                if (this.term_requested)
                {
                    return;
                }
            }

            // receive messages
            while (MctAdapter_ReceiveMessage(out id, out length, out data))
            {
                if (acceptMessageId(id))
                {
                    // convert message
                    msg.setID(id);
                    msg.setLength(length);
                    msg.setData(data);

                    // pass message to listeners
                    lock (this.m_listeners)
                    {
                        AddToCanTrace("RX: " + id.ToString("X4") + " " + data.ToString("X16"));
                        foreach (ICANListener listener in this.m_listeners)
                        {
                            listener.handleMessage(msg);
                        }
                    }
                }
            }

            // give up CPU for a moment
            Thread.Sleep(1);
            }
        }
开发者ID:josla972,项目名称:Trionic,代码行数:52,代码来源:MictronicsCanDevice.cs

示例8: InitializeSession

        public void InitializeSession()
        {
            CANMessage response = new CANMessage();

            //101      8 FE 01 3E 00 00 00 00 00
            CANMessage msg = new CANMessage(0x11, 0, 2);
            ulong cmd = 0x0000000000003E01;
            msg.setData(cmd);
            if (!canUsbDevice.sendMessage(msg))
            {
                logger.Debug("Couldn't send message");
            }
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:13,代码来源:Trionic8.cs

示例9: ProgramVIN

        public bool ProgramVIN(string VINNumber)
        {
            CANMessage msg = new CANMessage(0x7E0, 0, 8);
            ulong cmd = 0x00000000903B1310;
            if (VINNumber.Length > 17) VINNumber = VINNumber.Substring(0, 17);// lose more than 17 digits
            if (VINNumber.Length < 17) VINNumber = VINNumber.PadRight(17, '0');
            if (VINNumber.Length != 17) return false;

            cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[0]), 4);
            cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[1]), 5);
            cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[2]), 6);
            cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[3]), 7);

            msg.setData(cmd);

            m_canListener.setupWaitMessage(0x7E8);
            if (!canUsbDevice.sendMessage(msg))
            {
                CastInfoEvent("Couldn't send message", ActivityType.ConvertingFile);
                return false;
            }

            ulong rxdata = m_canListener.waitMessage(timeoutP2ct).getData();
            if (rxdata == 0x0000000000000030)
            {
                //2020202020202021
                //0020202020202022
                cmd = 0x0000000000000021;
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[4]), 1);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[5]), 2);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[6]), 3);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[7]), 4);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[8]), 5);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[9]), 6);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[10]), 7);

                msg.setData(cmd);
                m_canListener.setupWaitMessage(0x7E8);
                canUsbDevice.sendMessage(msg);
                cmd = 0x0000000000000022;
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[11]), 1);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[12]), 2);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[13]), 3);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[14]), 4);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[15]), 5);
                cmd = AddByteToCommand(cmd, Convert.ToByte(VINNumber[16]), 6);
                //msg.setLength(7); // only 7 bytes for the last message
                msg.setData(cmd);
                m_canListener.setupWaitMessage(0x7E8);
                canUsbDevice.sendMessage(msg);
                // wait for ack
                //0000000000907B02

                rxdata = m_canListener.waitMessage(timeoutP2ct).getData();
                if (getCanData(rxdata, 1) == 0x7B && getCanData(rxdata, 2) == 0x90)
                {
                    return true;
                }

            }
            return false;
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:62,代码来源:Trionic8.cs

示例10: UploadBootloaderWrite

        private bool UploadBootloaderWrite()
        {
            int startAddress = 0x102400;
            #if (DEBUG)
            BootloaderFromFile btloaderdata = new BootloaderFromFile();
            #else
            Bootloader btloaderdata = new Bootloader();
            #endif
            int txpnt = 0;
            byte iFrameNumber = 0x21;
            int saved_progress = 0;
            if (requestDownload())
            {
                for (int i = 0; i < 0x46; i++)
                {
                    iFrameNumber = 0x21;
                    //10 F0 36 00 00 10 24 00
                    //Console.WriteLine("Sending bootloader: " + startAddress.ToString("X8"));
                    // cast event
                    int percentage = (int)(((float)i * 100) / 70F);
                    if (percentage > saved_progress)
                    {
                        CastProgressWriteEvent(percentage);
                        saved_progress = percentage;
                    }

                    if (SendTransferData(0xF0, startAddress, 0x7E8))
                    {
                        canUsbDevice.RequestDeviceReady();
                        // send 0x22 (34) frames with data from bootloader
                        CANMessage msg = new CANMessage(0x7E0, 0, 8);
                        for (int j = 0; j < 0x22; j++)
                        {
                            var cmd = BitTools.GetFrameBytes(iFrameNumber, btloaderdata.BootloaderProgBytes, txpnt);
                            msg.setData(cmd);
                            txpnt += 7;
                            iFrameNumber++;

                            if (iFrameNumber > 0x2F) iFrameNumber = 0x20;
                            msg.elmExpectedResponses = j == 0x21 ? 1 : 0;//on last command (iFrameNumber 22 expect 1 message)
                            if (j == 0x21)
                                m_canListener.ClearQueue();

                            if (!canUsbDevice.sendMessage(msg))
                            {
                                logger.Debug("Couldn't send message");
                            }
                            Thread.Sleep(m_sleepTime);
                        }
                        // now wait for 01 76 00 00 00 00 00 00
                        ulong data = m_canListener.waitMessage(timeoutP2ct, 0x7E8).getData();
                        if (getCanData(data, 0) != 0x01 || getCanData(data, 1) != 0x76)
                        {
                            return false;
                        }
                        canUsbDevice.RequestDeviceReady();
                        SendKeepAlive();
                        startAddress += 0xEA;

                    }
                    else
                    {
                        Console.WriteLine("Did not receive correct response from SendTransferData");
                    }
                }

                iFrameNumber = 0x21;
                if (SendTransferData(0x0A, startAddress, 0x7E8))
                {
                    // send 0x22 (34) frames with data from bootloader
                    CANMessage msg = new CANMessage(0x7E0, 0, 8);
                    var cmd = BitTools.GetFrameBytes(iFrameNumber, btloaderdata.BootloaderBytes, txpnt);
                    msg.setData(cmd);
                    txpnt += 7;
                    iFrameNumber++;
                    if (iFrameNumber > 0x2F) iFrameNumber = 0x20;
                    if (!canUsbDevice.sendMessage(msg))
                    {
                        logger.Debug("Couldn't send message");
                    }
                    if (m_sleepTime > 0)
                        Thread.Sleep(m_sleepTime);

                    ulong data = m_canListener.waitMessage(timeoutP2ct, 0x7E8).getData();
                    if (getCanData(data, 0) != 0x01 || getCanData(data, 1) != 0x76)
                    {
                        return false;
                    }
                    SendKeepAlive();
                    startAddress += 0x06;
                }
                else
                {
                    Console.WriteLine("Did not receive correct response from SendTransferData");
                }

                CastProgressWriteEvent(100);
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:ChrisPea,项目名称:Trionic,代码行数:101,代码来源:Trionic8.cs

示例11: WriteFlashRecover

        private bool WriteFlashRecover(BlockManager bm)
        {
            int startAddress = 0x020000;
            int saved_progress = 0;
            for (int blockNumber = 0; blockNumber <= 0xF50; blockNumber++)
            {
                int percentage = (int)(((float)blockNumber * 100) / 3920F);
                if (percentage > saved_progress)
                {
                    CastProgressWriteEvent(percentage);
                    saved_progress = percentage;
                }
                byte[] data2Send = bm.GetNextBlock();
                int length = 0xF0;
                if (blockNumber == 0xF50) length = 0xE6;
                if (SendTransferData(length, startAddress + (blockNumber * 0xEA), 0x311))
                {
                    //canUsbDevice.RequestDeviceReady();
                    // send the data from the block
                    // calculate number of frames
                    int numberOfFrames = (int)data2Send.Length / 7; // remnants?
                    if (((int)data2Send.Length % 7) > 0) numberOfFrames++;
                    byte iFrameNumber = 0x21;
                    int txpnt = 0;
                    CANMessage msg = new CANMessage(0x7E0, 0, 8);
                    for (int frame = 0; frame < numberOfFrames; frame++)
                    {
                        var cmd = BitTools.GetFrameBytes(iFrameNumber, data2Send, txpnt);
                        msg.setData(cmd);
                        txpnt += 7;
                        iFrameNumber++;
                        if (iFrameNumber > 0x2F) iFrameNumber = 0x20;
                        msg.elmExpectedResponses = frame == numberOfFrames - 1 ? 1 : 0;

                        if (frame == numberOfFrames - 1)
                            m_canListener.ClearQueue();
                        if (!canUsbDevice.sendMessage(msg))
                        {
                            logger.Debug("Couldn't send message");
                        }
                        if (m_sleepTime > 0)
                            Thread.Sleep(m_sleepTime);
                    }
                    // now wait for 01 76 00 00 00 00 00 00
                    ulong data = m_canListener.waitMessage(timeoutP2ct, 0x7E8).getData();
                    if (getCanData(data, 0) != 0x01 || getCanData(data, 1) != 0x76)
                    {
                        _stallKeepAlive = false;
                        return false;
                    }
                    //canUsbDevice.RequestDeviceReady();
                    BroadcastKeepAlive();

                }
            }
            return true;
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:57,代码来源:Trionic8.cs

示例12: StartSession20

 private bool StartSession20()
 {
     CANMessage msg = new CANMessage(0x7E0, 0, 2);
     ulong cmd = 0x0000000000002001; // 0x02 0x10 0x02
     msg.setData(cmd);
     m_canListener.setupWaitMessage(0x7E8);
     if (!canUsbDevice.sendMessage(msg))
     {
         CastInfoEvent("Couldn't send message", ActivityType.ConvertingFile);
         return false;
     }
     CANMessage response = new CANMessage();
     response = new CANMessage();
     response = m_canListener.waitMessage(timeoutP2ct);
     ulong data = response.getData();
     if (getCanData(data, 0) != 0x01 || getCanData(data, 1) != 0x60)
     {
         return false;
     }
     return true;
 }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:21,代码来源:Trionic8.cs

示例13: StartBootloader011

 private bool StartBootloader011()
 {
     CANMessage msg = new CANMessage(0x11, 0, 7);
     ulong cmd = 0x0060241000803606;
     msg.setData(cmd);
     m_canListener.setupWaitMessage(0x311);
     if (!canUsbDevice.sendMessage(msg))
     {
         CastInfoEvent("Couldn't send message", ActivityType.ConvertingFile);
         return false;
     }
     CANMessage response = new CANMessage();
     response = new CANMessage();
     response = m_canListener.waitMessage(timeoutP2ct);
     ulong data = response.getData();
     if (getCanData(data, 0) != 0x01 || getCanData(data, 1) != 0x76)
     {
         return false;
     }
     return true;
 }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:21,代码来源:Trionic8.cs

示例14: SendTransferDataME96

        private bool SendTransferDataME96(int length, int address, uint waitforResponseID, byte firstByteToSend )
        {
            CANMessage msg = new CANMessage(0x7E0, 0, 8); // <GS-24052011> test for ELM327, set length to 16 (0x10)
            ulong cmd = 0x0000000000360010; // 0x36 = transferData
            ulong addressHigh = (uint)address & 0x0000000000FF0000;
            addressHigh /= 0x10000;
            ulong addressMiddle = (uint)address & 0x000000000000FF00;
            addressMiddle /= 0x100;
            ulong addressLow = (uint)address & 0x00000000000000FF;
            ulong len = (ulong)length + 5;  // The extra 5 comes from the Service ID plus the sub-function parameter byte plus the 3 byte startingAddress.
            ulong payload = (ulong)firstByteToSend;

            cmd |= (payload * 0x100000000000000);
            cmd |= (addressLow * 0x1000000000000);
            cmd |= (addressMiddle * 0x10000000000);
            cmd |= (addressHigh * 0x100000000);
            cmd |= (len * 0x100);

            Console.WriteLine("send: " + cmd.ToString("X16"));

            msg.setData(cmd);
            msg.elmExpectedResponses = 1;
            m_canListener.setupWaitMessage(waitforResponseID);
            if (!canUsbDevice.sendMessage(msg))
            {
                logger.Debug("Couldn't send message");
            }

            CANMessage response = new CANMessage();
            response = new CANMessage();
            response = m_canListener.waitMessage(timeoutP2ct);
            ulong data = response.getData();
            Console.WriteLine("Received in SendTransferData: " + data.ToString("X16"));
            if (getCanData(data, 0) != 0x30 || getCanData(data, 1) != 0x00)
            {
                return false;
            }
            return true;
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:39,代码来源:Trionic8.cs

示例15: readMessages

 /// <summary>
 /// readMessages is the "run" method of this class. It reads all incomming messages
 /// and publishes them to registered ICANListeners.
 /// </summary>
 public void readMessages()
 {
     int readResult = 0;
     EASYSYNC.CANMsg r_canMsg = new EASYSYNC.CANMsg();
     CANMessage canMessage = new CANMessage();
     while (true)
     {
         lock (m_synchObject)
         {
             if (m_endThread)
                 return;
         }
         readResult = EASYSYNC.canusb_Read(m_deviceHandle, out r_canMsg);
         if (readResult == EASYSYNC.ERROR_CANUSB_OK)
         {
             canMessage.setID(r_canMsg.id);
             canMessage.setLength(r_canMsg.len);
             canMessage.setTimeStamp(r_canMsg.timestamp);
             canMessage.setFlags(r_canMsg.flags);
             canMessage.setData(r_canMsg.data);
             lock (m_listeners)
             {
                 foreach (ICANListener listener in m_listeners)
                 {
                     listener.handleMessage(canMessage);
                 }
             }
         }
         else if (readResult == EASYSYNC.ERROR_CANUSB_NO_MESSAGE)
         {
             Thread.Sleep(1);
         }
     }
 }
开发者ID:josla972,项目名称:Trionic,代码行数:38,代码来源:EasySyncUSBDevice.cs


注:本文中的TrionicCANLib.CAN.CANMessage.setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。