Ejemplo n.º 1
0
        private string GetReturnValue(object source, string method)
        {
            switch (method.ToLower())
            {
            case "tobinary":
                string holder = CommonFunctions.ByteArrayToString(CommonFunctions.ObjectToBinary(source, false));
                return(holder);

            case "tojson":
                return(null);

            case "toxml":
                return(null);

            default:
                return(source.ToString());
            }
        }
Ejemplo n.º 2
0
        public async Task <byte> ReadSectorData(object param)
        {
            recievedData.Clear();
            dataBuf.Clear();
            dataBuf.Add(0x02);
            dataBuf.Add(0x00);
            dataBuf.Add(0x04);
            dataBuf.Add(0x34);
            dataBuf.Add(0x33);
            dataBuf.Add(0x05);                   //Sector
            dataBuf.Add(0x01);                   //Block
            dataBuf.Add(0x03);
            dataBuf.Add(Crc(dataBuf.ToArray())); //BCC

            ResponseLength = 26;                 //Response linght
            Port.Write(dataBuf.ToArray(), 0, dataBuf.Count);
            await Task.Delay(DelayTymeout);

            byte[] buffer = recievedData.ToArray();
            if (CheckCrc(buffer))
            {
                switch (buffer[7])
                {
                case 0x59:
                {
                    byte[] dt = new byte[16];
                    Array.Copy(buffer, 8, dt, 0, 16);
                    data = CommonFunctions.ByteArrayToString(dt);
                    return(0x59);
                };

                case 0x31: return(0x31);

                case 0x34: return(0x34);

                default: return(0xFA);
                }
            }
            else
            {
                return(0xFF);
            }
        }