示例#1
0
        public App()
        {
            int    status     = 0;
            ushort bytes2read = 2;

            byte[] readbuff = new byte[61];
            byte[] valData  = new byte[bytes2read];

            var i = SLABHIDDevice_DLL.HidDevice_GetNumHidDevices(0x10C4, 0xEA90);

            if (i == 0)
            {
                throw new Exception("CP2112 not present");
            }


            status = SLAB_HID_TO_SMBUS.CP2112_DLL.HidSmbus_Open(ref connectedDevice, 0, vid, pid);
            status = SLAB_HID_TO_SMBUS.CP2112_DLL.HidSmbus_SetSmbusConfig(connectedDevice, 20000, SlaveAddress, 0, 10, 10, 0, 2);
            status = SLAB_HID_TO_SMBUS.CP2112_DLL.HidSmbus_SetGpioConfig(connectedDevice, 0x20, 0x20, 0x13, 0xFF);

            //MakeReport();

            //Console.WriteLine("Mnf AverageVoltage:" + BitConverter.ToUInt16(ManufactureAcessRead(MNFA_AVERAGE_VOLTAGE, 2), 0).ToString("d") + "mV");
            //Console.WriteLine("SBS AverageVoltage:" + BitConverter.ToUInt16(SbsRead(SBS_AVERAGE_VOLTAGE, 2), 0).ToString("d") + "mV");
            //Console.WriteLine("Device Type:" + BitConverter.ToUInt16(ManufactureAcessRead(MNFA_DEVICE_TYPE, 2), 0).ToString("X4"));

            //SbsWrite(SBS_CYCLE_COUNT, new byte[] { 0x01, 0x00 });
            //System.Threading.Thread.Sleep(100);  /*Kritikus*/
            //Console.WriteLine("CycleCount:" + BitConverter.ToUInt16(SbsRead(SBS_CYCLE_COUNT, 2), 0).ToString("D5"));

            SbsStringWrite(SBS_MANUFACTURER_NAME, "PowerWorkshop");
            System.Threading.Thread.Sleep(100);
            Close();
        }
示例#2
0
        public void BQ20Z45_first()
        {
            if (SLABHIDDevice_DLL.HidDevice_GetNumHidDevices(vid, pid) == 0)
            {
                throw new Exception("CP2112 not present");
            }
            status = SLAB_HID_TO_SMBUS.CP2112_DLL.HidSmbus_Open(ref connectedDevice, 0, vid, pid);
            status = SLAB_HID_TO_SMBUS.CP2112_DLL.HidSmbus_SetSmbusConfig(connectedDevice, 20000, SlaveAddress, 0, 10, 10, 0, 2);

            string str = "DesignCapacity:" + BitConverter.ToUInt16(ParameterRead(0x18, 2), 0).ToString() + "mAh";

            Assert.AreEqual("DesignCapacity:5100mAh", str);
        }