Ejemplo n.º 1
0
        public static byte[] BuildCommand(MTRFMode mode, MTRFAction action, MTRFRepeatCount repeatCount, byte channel,
                                          MTRFCommand command, MTRFDataFormat format, byte[] data, UInt32 target = 0)
        {
            byte actionAndRepeatCount = (byte)((byte)action | ((byte)repeatCount << 6));

            var res = new byte[]
            {
                START_MARKER,         // 0: start marker
                (byte)mode,           // 1: device mode
                actionAndRepeatCount, // 2: action & repeat count
                0,                    // 3: reserved
                channel,              // 4: channel
                (byte)command,        // 5: command
                (byte)format,         // 6: data format
                0, 0, 0, 0,           // 7..10: data
                0, 0, 0, 0,           // 11..14: target device id
                0,                    // 15: checksum
                STOP_MARKER           // 16: stop marker
            };

            for (int i = 0; i < 15; i++)
            {
                res[15] += res[i];
            }

            return(res);
        }
Ejemplo n.º 2
0
        public void SendCommand(MTRFMode mode, MTRFAction action, byte channel, MTRFCommand command,
                                MTRFRepeatCount repeatCount = MTRFRepeatCount.NoRepeat, MTRFDataFormat format = MTRFDataFormat.NoData,
                                byte[] data = null, UInt32 target = 0)
        {
            var cmd = BuildCommand(mode, action, repeatCount, channel, command, format, data, target);

            device.Write(cmd);
        }