Beispiel #1
0
        public static uint GetWritingResult()
        {
            uint         writenlen = 0;
            KB9API_ERROR result    = (KB9API_ERROR)API_getWriteKB9Result(ref writenlen);

            if (result != KB9API_ERROR.FUNC_SUCCESSFUL)
            {
                return(0);
            }
            return(writenlen);
        }
Beispiel #2
0
 public static KB9API_ERROR EnableDisableLogFile(bool bFlag)
 {
     try
     {
         KB9API_ERROR result = (KB9API_ERROR)API_EnableDisableLogFile(bFlag);
         return(result);
     }
     catch (System.Exception ex)
     {
         return(KB9API_ERROR.FUNC_UNKOWN_ERROR);
     }
 }
Beispiel #3
0
        public static int GetLeftSpaceBytesKB9(string strData)
        {
            //字符串转为 bytes 数组
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(strData);
            int    nlen  = bytes.Length;
            //System.Diagnostics.Debug.Print("data len=" + nlen.ToString());

            int          nleft  = 0;
            KB9API_ERROR result = (KB9API_ERROR)API_getLeftSpaceBytesKB9(bytes, (uint)nlen, ref nleft);

            if (result == KB9API_ERROR.FUNC_SUCCESSFUL)
            {
                return(nleft);
            }
            else
            {
                return((int)result);
            }
        }
Beispiel #4
0
        public static KB9API_ERROR GetDllVersion(KB9_PORT nPortType, ref string dllVersion, ref string firmwareVersion)
        {
            byte[] ver = new byte[256];
            // uint readlen = 0;
            KB9API_ERROR result = (KB9API_ERROR)API_getDllVersionKB9(ver, 256, (int)nPortType);
            // return V1.0.1.14 & Vd8.10
            string s   = Encoding.ASCII.GetString(ver);
            int    n   = s.IndexOf("\0");
            string str = s.Substring(0, n);

            n = str.IndexOf("&");
            if (n < 0)
            {
                dllVersion      = str;
                firmwareVersion = "";
            }
            else
            {
                dllVersion = str.Substring(0, n);
                if (n + 1 < str.Length)
                {
                    firmwareVersion = str.Substring(n + 1);
                }
                else
                {
                    firmwareVersion = "";
                }
                dllVersion.Trim();
                firmwareVersion.Trim();
                dllVersion      = dllVersion.Replace("V", "");
                firmwareVersion = firmwareVersion.Replace("V", "");
            }

            return(result);

            //if (result != KB9API_ERROR.FUNC_SUCCESSFUL)
            //    return result;


            ////convert buffer to  string
            //return KB9API_ERROR.FUNC_SUCCESSFUL;
        }
Beispiel #5
0
        /// <summary>
        /// static KB9ACCESS_API int getReadKB9Data(unsigned char* pData, unsigned long nDataNumberReturned);
        /// </summary>
        /// <param name="nPortType"></param>
        /// <param name="msgReceiver"></param>
        /// <param name="strRead"></param>
        /// <returns></returns>
        public static KB9API_ERROR ReadKB9Data(ref string strRead)
        {
            uint         readlen = 0;
            KB9API_ERROR result  = (KB9API_ERROR)API_getReadKB9Data(ref readlen);

            if (result != KB9API_ERROR.FUNC_SUCCESSFUL)
            {
                return(result);
            }
            if (readlen <= 0)
            {
                return(KB9API_ERROR.FUNC_UNKOWN_ERROR);
            }

            //convert buffer to  string
            string s = Encoding.ASCII.GetString(buffer_read, 0, (int)readlen);

            strRead = s;
            return(KB9API_ERROR.FUNC_SUCCESSFUL);
        }
Beispiel #6
0
        /// <summary>
        /// auto search usb and ps/2 port, finding kb9000 device.
        /// </summary>
        /// <param name="msgReceiver"></param>
        /// <returns></returns>
        public static KB9API_ERROR AutoDetectKB9(ref KB9_PORT kb9Port)
        {
            KB9API_ERROR result = KB9API_ERROR.FUNC_SUCCESSFUL;

            //1. detect usb port first, as usb will take less time than ps/2
            result = DetectKB9(KB9_PORT.USB);
            if (result == KB9API_ERROR.FUNC_SUCCESSFUL)
            {
                kb9Port = KB9_PORT.USB;
                return(result);
            }

            //2. detect ps/2
            result = DetectKB9(KB9_PORT.PS2);
            if (result == KB9API_ERROR.FUNC_SUCCESSFUL)
            {
                kb9Port = KB9_PORT.PS2;
                return(result);
            }

            kb9Port = KB9_PORT.Unknown;
            return(KB9API_ERROR.FUNC_OPENPORT_FAIL);
        }
Beispiel #7
0
        /************************************************************************
        *
        * Function:  EnableDisableLogFile
        * Description:
        *   set enable/disable flag in DLL to enable log file or not.
        *
        * Parameters:
        *   bFlag: true - enable, false - disable
        *
        * return:
        *    0: successful.
        *   < 0: error. (code defined above)
        ************************************************************************/
        public static KB9API_ERROR ClearLogFile()
        {
            KB9API_ERROR result = (KB9API_ERROR)API_ClearLogFile();

            return(result);
        }
Beispiel #8
0
        public static KB9API_ERROR StartReadingKB9(KB9_PORT nPortType)
        {
            KB9API_ERROR result = (KB9API_ERROR)API_startReadKB9(buffer_read, BUFFER_SIZE, (int)nPortType);

            return(result);
        }