Пример #1
0
        static public EnOceanPacket MakePacket_CO_RD_VERSION()
        {
            var pkt = new EnOceanPacket(PacketType.COMMON_COMMAND, new byte[] { 0x03 }, null);

            pkt.BuildPacket();
            return(pkt);
        }
Пример #2
0
        public bool Send(EnOceanPacket packet, IReceiveHandler handler, int retries = 3, int timeout = 1000)
        {
            var rawPacket = packet.BuildPacket();
            var pl        = new PacketListener(handler);

            PacketListeners.Add(pl);
AGAIN:
            // TESTING
            SendFrame(rawPacket);
            pl.waitHandle.WaitOne(timeout);
            if (pl.succeeded)
            {
                PacketListeners.Remove(pl);
                return(true);
            }
            else
            {
                if (retries-- > 0)
                {
                    goto AGAIN;
                }
                PacketListeners.Remove(pl);
                return(false);
                // Packet not what he wanted.. wait for next!
            }
        }
Пример #3
0
 public static EnOceanPacket MakePacket_CO_RD_VERSION()
 {
     var pkt = new EnOceanPacket(PacketType.COMMON_COMMAND, new byte[] { 0x03 }, null);
     pkt.BuildPacket();
     return pkt;
 }
Пример #4
0
 public bool Send(EnOceanPacket packet, IReceiveHandler handler, int retries = 3, int timeout = 1000)
 {
     var rawPacket = packet.BuildPacket();
     var pl = new PacketListener(handler);
     PacketListeners.Add(pl);
     AGAIN:
     // TESTING
     SendFrame(rawPacket);
     pl.waitHandle.WaitOne(timeout);
     if (pl.succeeded)
     {
         PacketListeners.Remove(pl);
         return true;
     }
     else
     {
         if (retries-- > 0)
             goto AGAIN;
         PacketListeners.Remove(pl);
         return false;
         // Packet not what he wanted.. wait for next!
     }
 }