Ejemplo n.º 1
0
        private byte[] Seq_read(UInt16 Data_addr, ushort len)
        {
            Viewer.UpadateLogColorInvoke UpdateLog = LogUpdatewColor;

            byte Dev_addr = byte.Parse("49", System.Globalization.NumberStyles.HexNumber);
            byte Dev_Ack;

            byte[]    Data_pac;
            ErrorCode ret = Viewer.fingerPrint.FP_I2CRead(Dev_addr, Data_addr, len, out Dev_Ack, out Data_pac);

            if (ret != ErrorCode.FP_STATUS_OK)
            {
                UpdateLog("[E] FP_I2CRead - ErrorCode = " + ret.ToString(), true, Color.Red);
            }
            else if (Dev_Ack == 0)
            {
                UpdateLog("[E] FP_I2CRead - DeviceACK = " + Dev_Ack.ToString(), true, Color.Red);
            }
            else
            {
                UpdateLog("I2C SRead : " + Dec2Hex(Data_addr) + " Success!", true, Color.Green);
                if (cb_detail_log.Checked)
                {
                    UpdateLog("[Detail] Value :", false, Color.Black);
                    for (int i = 0; i < Data_pac.Length; i++)
                    {
                        UpdateLog(Data_pac[i].ToString(), false, Color.Black);
                    }
                    UpdateLog("", true, Color.Black);
                }
            }

            return(Data_pac);
        }
Ejemplo n.º 2
0
        private byte Byte_read(UInt16 Data_addr)
        {
            Viewer.UpadateLogColorInvoke UpdateLog = LogUpdatewColor;

            byte Dev_addr = byte.Parse("49", System.Globalization.NumberStyles.HexNumber);
            byte Dev_Ack;

            byte[]    Data_pac;
            ErrorCode ret = Viewer.fingerPrint.FP_I2CRead(Dev_addr, Data_addr, 1, out Dev_Ack, out Data_pac);

            if (ret != ErrorCode.FP_STATUS_OK)
            {
                UpdateLog("[E] FP_I2CRead - ErrorCode = " + ret.ToString(), true, Color.Red);
            }
            else if (Dev_Ack == 0)
            {
                UpdateLog("[E] FP_I2CRead - DeviceACK = " + Dev_Ack.ToString(), true, Color.Red);
            }
            else
            {
                UpdateLog("I2C Read : " + Dec2Hex(Data_addr) + " Success!", true, Color.Green);
            }

            return(Data_pac[0]);
        }
Ejemplo n.º 3
0
        private bool Seq_write(UInt16 Data_addr, ushort len, byte[] Data)
        {
            Viewer.UpadateLogColorInvoke UpdateLog = LogUpdatewColor;

            byte      Dev_addr = byte.Parse("49", System.Globalization.NumberStyles.HexNumber);
            byte      Dev_Ack;
            ErrorCode ret = Viewer.fingerPrint.FP_I2CWrite(Dev_addr, Data_addr, len, Data, out Dev_Ack);

            if (ret != ErrorCode.FP_STATUS_OK)
            {
                UpdateLog("[E] FP_I2CWrite - ErrorCode = " + ret.ToString(), true, Color.Red);
            }
            else if (Dev_Ack == 0 || Dev_Ack == 81)
            {
                UpdateLog("[S] FP_I2CWrite - DeviceACK = " + Dev_Ack.ToString(), true, Color.Red);
            }
            else
            {
                UpdateLog("I2C SWrite : " + Dec2Hex(Data_addr) + ", Len : " + len + " Success!", true, Color.Red);
                if (cb_detail_log.Checked)
                {
                    UpdateLog("[Detail] Value :", false, Color.Black);
                    for (int i = 0; i < Data.Length; i++)
                    {
                        UpdateLog(Data[i].ToString("X2"), false, Color.Black);
                    }
                    UpdateLog("", true, Color.Black);
                }
            }

            return(ret == ErrorCode.FP_STATUS_OK && Dev_Ack == 1);
        }
Ejemplo n.º 4
0
        private bool Byte_write(UInt16 Data_addr, byte Data)
        {
            Viewer.UpadateLogColorInvoke UpdateLog = LogUpdatewColor;

            byte Dev_addr = byte.Parse("49", System.Globalization.NumberStyles.HexNumber);
            byte Dev_Ack;

            byte[] Data_pac = new byte[1] {
                Data
            };
            ErrorCode ret = Viewer.fingerPrint.FP_I2CWrite(Dev_addr, Data_addr, 1, Data_pac, out Dev_Ack);

            if (ret != ErrorCode.FP_STATUS_OK)
            {
                UpdateLog("[E] FP_I2CWrite - ErrorCode = " + ret.ToString(), true, Color.Red);
            }
            else if (Dev_Ack == 0 || Dev_Ack == 81)
            {
                UpdateLog("[S] FP_I2CWrite - DeviceACK = " + Dev_Ack.ToString(), true, Color.Red);
            }
            else
            {
                UpdateLog("I2C Write : " + Dec2Hex(Data_addr) + ", Value : " + Data + " Success!", true, Color.Red);
            }

            return(ret == ErrorCode.FP_STATUS_OK && Dev_Ack == 1);
        }
Ejemplo n.º 5
0
        private void Communication_LogReceived(LogMessage.Type type, string Log)
        {
            Viewer.UpadateLogColorInvoke UpdateLogwColor = LogUpdatewColor;
            // 根據 type 改變 Log 文字的顏色
            Color tans_color = SystemColors.ControlText;

            switch (type)
            {
            case LogMessage.Type.Normal:
                break;

            case LogMessage.Type.Infomation:
                tans_color = Color.Blue;
                break;

            case LogMessage.Type.Successful:
                tans_color = Color.Green;
                break;

            case LogMessage.Type.Warning:
                tans_color = Color.Yellow;
                break;

            case LogMessage.Type.Error:
                tans_color = Color.Red;
                break;

            default:
                break;
            }

            // 印出至 RichTextBox
            if (Log != "")
            {
                Invoke(UpdateLogwColor, new Object[] { Log, true, tans_color });
            }
        }