コード例 #1
0
        static public void TERM()
        {
            if (m_access)
            {
 #if true//2019.08.23()
                if ((G.AS.DEBUG_MODE & 1) != 0)
                {
                    DBGMODE.HID_CLOSE();
                    m_access = false;
                    return;
                }
#endif
                HID_CLOSE();
                m_access = false;
            }
        }
コード例 #2
0
        /************************************************************/
        static public bool CMDOUT64(int cmd, int par1, int par2, int par3, int par4, byte[] obuf, byte[] ibuf)
        {
            byte[] commandPacket = new byte[64];
            commandPacket[0] = (byte)cmd;
            commandPacket[1] = (byte)par1;
            commandPacket[2] = (byte)par2;
            commandPacket[3] = (byte)par3;
            commandPacket[4] = (byte)par4;
            if (obuf != null)
            {
                for (int i = 0; i < obuf.Length; i++)
                {
                    commandPacket[5 + i] = obuf[i];
                }
            }
#if true//2019.08.23()
            if ((G.AS.DEBUG_MODE & 1) != 0)
            {
                DBGMODE.WRITE_HID(commandPacket);
                if (ibuf != null)
                {
                    DBGMODE.READ_HID(ibuf);
                }
                return(true);
            }
#endif
            if (WRITE_HID(commandPacket, commandPacket.Length) == 0)
            {
                //	return(false);
            }
            if (ibuf != null)
            {
                if (READ_HID(commandPacket, commandPacket.Length) == 0)
                {
                    return(false);
                }
                for (int i = 0; i < commandPacket.Length; i++)
                {
                    if (i >= ibuf.Length)
                    {
                        break;
                    }
                    ibuf[i] = commandPacket[i];
                }
            }
            return(true);
        }
コード例 #3
0
        static private int HID_ENUM(uint vid, uint pid, out int pcnt)
        {
#if true//2019.08.23()
            if ((G.AS.DEBUG_MODE & 1) != 0)
            {
                DBGMODE.HID_ENUM(vid, pid, out pcnt);
                return(1);
            }
#endif
            int    ret;
            IntPtr buf = new IntPtr();

            buf  = Marshal.AllocHGlobal(4);
            ret  = _HID_ENUM(vid, pid, buf);;
            pcnt = Marshal.ReadInt32(buf);
            Marshal.FreeHGlobal(buf);

            return(ret);
        }
コード例 #4
0
        /************************************************************/
        static public bool CMDOUT(int cmd, int par1, int par2, int par3, int par4, byte[] buf)
        {
            byte[] commandPacket = new byte[16];
            commandPacket[0] = (byte)cmd;
            commandPacket[1] = (byte)par1;
            commandPacket[2] = (byte)par2;
            commandPacket[3] = (byte)par3;
            commandPacket[4] = (byte)par4;
#if true//2019.08.23()
            if ((G.AS.DEBUG_MODE & 1) != 0)
            {
                DBGMODE.WRITE_HID(commandPacket);
                if (buf != null)
                {
                    DBGMODE.READ_HID(buf);
                }
                return(true);
            }
#endif
            if (WRITE_HID(commandPacket, commandPacket.Length) == 0)
            {
                //			Toast.makeText(TEST24Activity.this, "USB COMMUNICATION ERROR!!!", Toast.LENGTH_SHORT).show();
                //	return(false);
            }
            if (buf != null)
            {
                if (READ_HID(commandPacket, commandPacket.Length) == 0)
                {
                    return(false);
                }
                for (int i = 0; i < commandPacket.Length; i++)
                {
                    if (i >= buf.Length)
                    {
                        break;
                    }
                    buf[i] = commandPacket[i];
                }
            }
            return(true);
        }
コード例 #5
0
        /************************************************************/
        static public bool CMDOUT02(int cmd, int par1, int par2)
        {
            byte[] commandPacket = new byte[16];
            commandPacket[0] = (byte)cmd;
            commandPacket[1] = (byte)par1;
            commandPacket[2] = (byte)par2;
            commandPacket[3] = 0;
            commandPacket[4] = 0;
            commandPacket[5] = 0;
#if true//2019.08.23()
            if ((G.AS.DEBUG_MODE & 1) != 0)
            {
                DBGMODE.WRITE_HID(commandPacket);
                return(true);
            }
#endif
            if (WRITE_HID(commandPacket, commandPacket.Length) == 0)
            {
                //			Toast.makeText(TEST24Activity.this, "USB COMMUNICATION ERROR!!!", Toast.LENGTH_SHORT).show();
                //	return(false);
            }
            return(true);
        }
コード例 #6
0
        static public bool INIT()
        {
            int cnt_of_mini;
            int cnt_of_gene;
            int ret1, ret2;

            // 0x04D8, // Vendor ID
            // 0x003F, // Product ID(SAMPLE.PROGRAM)
            // 0xEF22, // Product ID(SENSOR.BIG)
            // 0xEED8, // Product ID(SENSOR.MINI)
            ret1 = HID_ENUM(0x04D8, 0xEED8, out cnt_of_mini);
            ret2 = HID_ENUM(0x04D8, 0xEF22, out cnt_of_gene);
            if (ret1 != 0 && cnt_of_mini > 0)
            {
#if true//2019.08.23()
                if ((G.AS.DEBUG_MODE & 1) != 0)
                {
                    if (DBGMODE.HID_OPEN(0x04D8, 0xEED8, 0) == 0)
                    {
                        G.mlog("ERROR @ HID_OPEN");
                        return(false);
                    }
                }
                else
#endif
                if (HID_OPEN(0x04D8, 0xEED8, 0) == 0)
                {
                    G.mlog("ERROR @ HID_OPEN");
                    return(false);
                }
                DEV_TYPE = 0;
            }
            else
            if (ret2 != 0 && cnt_of_gene > 0)
            {
#if true//2019.08.23()
                if ((G.AS.DEBUG_MODE & 1) != 0)
                {
                    if (DBGMODE.HID_OPEN(0x04D8, 0xEF22, 0) == 0)
                    {
                        G.mlog("ERROR @ HID_OPEN");
                        return(false);
                    }
                }
                else
#endif
                if (HID_OPEN(0x04D8, 0xEF22, 0) == 0)
                {
                    G.mlog("ERROR @ HID_OPEN");
                    return(false);
                }
                DEV_TYPE = 1;
            }
            else
            {
                G.mlog("CAN NOT DETECT KOP SENSOR DEVICE");
                return(false);
            }
            m_access = true;
            return(true);
        }