Beispiel #1
0
        /// <summary>
        /// Send a SDO packet, with command and payload, should be only called from SDO state machine
        /// </summary>
        /// <param name="cmd">SDO command byte</param>
        /// <param name="payload">Data payload to send</param>
        private void sendpacket(byte cmd, byte[] payload)
        {
            canpacket p = new canpacket();

            p.cob     = (UInt16)(0x600 + node);
            p.len     = 8;
            p.data    = new byte[8];
            p.data[0] = cmd;
            p.data[1] = (byte)index;
            p.data[2] = (byte)(index >> 8);
            p.data[3] = subindex;

            int sendlength = 4;

            if (payload.Length < 4)
            {
                sendlength = payload.Length;
            }

            for (int x = 0; x < sendlength; x++)
            {
                p.data[4 + x] = payload[x];
            }

            if (dbglevel == debuglevel.DEBUG_ALL)
            {
                Console.WriteLine(String.Format("Sending a new SDO packet: {0}", p.ToString()));
            }

            if (can.isopen())
            {
                can.SendPacket(p);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Segmented transfer update function, should be only called from SDO state machine
        /// </summary>
        /// <param name="cmd">SDO command byte</param>
        /// <param name="payload">Data payload</param>
        private void sendpacketsegment(byte cmd, byte[] payload)
        {
            canpacket p = new canpacket();

            p.cob     = (UInt16)(0x600 + node);
            p.len     = 8;
            p.data    = new byte[8];
            p.data[0] = cmd;

            for (int x = 0; x < payload.Length; x++)
            {
                p.data[1 + x] = payload[x];
            }

            if (dbglevel == debuglevel.DEBUG_ALL)
            {
                Console.WriteLine(String.Format("Sending a new segmented SDO packet: {0}", p.ToString()));
            }

            can.SendPacket(p);
        }
Beispiel #3
0
 private static void Lco_nmtevent(libCanopenSimple.canpacket p)
 {
     Console.WriteLine("NMT :" + p.ToString());
 }
Beispiel #4
0
 private static void Lco_sdoevent(libCanopenSimple.canpacket p, DateTime dt)
 {
     Console.WriteLine("SDO :" + p.ToString());
 }