Exemple #1
0
        public void wirteData(string size, string address, string writeVal)
        {
            List <byte> frame   = new List <byte>();
            List <byte> addData = new List <byte>();

            byte seqCode = ctrlMasCnt();

            seqCode = (byte)(seqCode + RmInstr.Write);
            frame.Add(seqCode);

            addData = BinaryEditor.HexStringToBytes(size);
            frame.AddRange(addData);

            if (myComponents.SelectByte == Components.RmAddr.Byte4)
            {
            }
            else
            {
                address = address.Substring(address.Length - 4);
            }

            addData = BinaryEditor.HexStringToBytes(address);
            addData = BinaryEditor.Swap(addData);
            frame.AddRange(addData);
            addData = BinaryEditor.HexStringToBytes(writeVal);
            addData = BinaryEditor.Swap(addData);
            frame.AddRange(addData);

            TxDataStream.Enqueue(frame);
        }
Exemple #2
0
        public List <string> interpretRxFrameToHexChars(List <byte> tmp, List <string> listSize, out bool validflg)
        {
            List <string> listValue = new List <string>();

            validflg = true;

            foreach (var size in listSize)
            {
                int intSize = int.Parse(size);

                if (tmp.Count >= intSize)
                {
                    List <byte> buff = tmp.GetRange(0, intSize);
                    tmp.RemoveRange(0, intSize);
                    buff = BinaryEditor.Swap(buff);
                    listValue.Add(BinaryEditor.BytesToHexString(buff.ToArray()));
                }
                else
                {
                    //Invalid data
                    validflg = false;
                }
            }

            return(listValue);
        }
Exemple #3
0
        public void readVersion(string password)
        {
            List <byte> frame   = new List <byte>();
            List <byte> addData = new List <byte>();

            byte seqCode = ctrlMasCnt();

            seqCode = (byte)(seqCode + RmInstr.ReadInfo);
            frame.Add(seqCode);

            addData = BinaryEditor.HexStringToBytes(password);
            addData = BinaryEditor.Swap(addData);
            frame.AddRange(addData);

            TxDataStream.Enqueue(frame);
        }
Exemple #4
0
        public void setTiming(string timing)
        {
            List <byte> frame   = new List <byte>();
            List <byte> addData = new List <byte>();

            byte seqCode = ctrlMasCnt();

            seqCode = (byte)(seqCode + RmInstr.SetTiming);
            frame.Add(seqCode);

            addData = BinaryEditor.HexStringToBytes(timing);

            if (addData.Count == 1)
            {
                addData.Add((byte)0);
            }

            addData = BinaryEditor.Swap(addData);
            frame.AddRange(addData);

            TxDataStream.Enqueue(frame);
        }
Exemple #5
0
        public void readDumpData(string address, string size)
        {
            int payload_max = 128;
            int frame_num;
            int last_frame_contents;

            int total_size = int.Parse(size);
            int payload_size;

            frame_num           = total_size / payload_max;
            last_frame_contents = total_size - (frame_num * payload_max);

            if (last_frame_contents != 0)
            {
                frame_num++;
            }
            else if (last_frame_contents == 0)
            {
                last_frame_contents = payload_max;
            }

            Int64 intAddress = 0;
            Int64 intOffset  = 0;

            bool err_flg = false;

            for (int i = 0; i < frame_num; i++)
            {
                List <byte> frame   = new List <byte>();
                List <byte> addData = new List <byte>();

                byte seqCode = ctrlMasCnt();
                seqCode = (byte)(seqCode + RmInstr.ReadDump);
                frame.Add(seqCode);

                intOffset = payload_max * i;

                if (i == (frame_num - 1))
                {
                    payload_size = last_frame_contents;
                }
                else
                {
                    payload_size = payload_max;
                }

                try
                {
                    intAddress = Convert.ToInt64(address, 16);
                }
                catch (Exception ex)
                {
                    err_flg = true;
                    break;
                }

                var value = Convert.ToInt64(intAddress + intOffset);
                var bytes = BitConverter.GetBytes(value);

                var list = bytes.ToList();
                list.RemoveRange(4, (list.Count - 4));
                bytes = list.ToArray();
                Array.Reverse(bytes, 0, bytes.Length);
                string byteStrings = BitConverter.ToString(bytes);

                address = byteStrings.Replace("-", "");

                if (myComponents.SelectByte == Components.RmAddr.Byte4)
                {
                }
                else
                {
                    address = address.Substring(address.Length - 4);
                }


                addData = BinaryEditor.HexStringToBytes(address);
                addData = BinaryEditor.Swap(addData);
                frame.AddRange(addData);
                byte bdata = (byte)payload_size;
                frame.Add(bdata);

                if (err_flg != true)
                {
                    TxDataStream.Enqueue(frame);
                }
            }
        }
Exemple #6
0
        public void setLogData(List <SetLogParam> argParam)
        {
            int factor_max;
            int frame_num;
            int last_frame_contents;

            if (myComponents.SelectByte == Components.RmAddr.Byte4)
            {
                factor_max = 4;
            }
            else
            {
                factor_max = 8;
            }

            frame_num           = argParam.Count / factor_max;
            last_frame_contents = argParam.Count - (frame_num * factor_max);

            if (last_frame_contents != 0)
            {
                frame_num++;
            }
            else if (last_frame_contents == 0)
            {
                last_frame_contents = factor_max;
            }

            int dataIndex      = 0;
            int frame_contents = 0;

            for (int i = 0; i < frame_num; i++)
            {
                List <byte> frame   = new List <byte>();
                List <byte> addData = new List <byte>();

                byte seqCode = ctrlMasCnt();
                seqCode = (byte)(seqCode + RmInstr.SetAddr);
                frame.Add(seqCode);

                byte flgCode = 0x00;

                frame_contents = factor_max;

                if (i == 0)
                {
                    flgCode |= 0x10;
                }

                if (i == (frame_num - 1))
                {
                    flgCode |= 0x20;

                    frame_contents = last_frame_contents;
                }

                flgCode |= (byte)i;

                frame.Add(flgCode);

                bool err_flg = false;

                for (int j = 0; j < frame_contents; j++)
                {
                    addData = BinaryEditor.HexStringToBytes(argParam[dataIndex].Size);
                    frame.AddRange(addData);

                    string address = argParam[dataIndex].Address;

                    if (myComponents.SelectByte == Components.RmAddr.Byte4)
                    {
                    }
                    else
                    {
                        address = address.Substring(address.Length - 4);
                    }

                    addData = BinaryEditor.HexStringToBytes(address);
                    addData = BinaryEditor.Swap(addData);
                    frame.AddRange(addData);

                    dataIndex++;
                }

                if (err_flg != true)
                {
                    TxDataStream.Enqueue(frame);
                }
            }
        }