Exemplo n.º 1
0
        protected bool IsVoltageAdd(int seat, out bool enable, out string msg)
        {
            var status = new byte[0x100];

            enable = false;
            if (!IsSeatValid(seat, out msg))
            {
                return(false);
            }

            var chipAddr    = DriverAddr.GetChipAddr();
            var subChipAddr = DriverAddr.GetSubChipAddr(seat);
            var ctrlAddr    = DriverAddr.GetCtrlAddr(seat);
            var volAddr     = DriverAddr.GetAddVolAddr();
            var ctrlByte    = DriverAddr.GetCtrlByte(seat);

            //Select Chip
            if (1 != eDriver_IO.Cls_edriverdll.i2c_write(chipAddr, 0x01, 1, 0, new[] { subChipAddr }, status))
            {
                msg = Encoding.ASCII.GetString(status);
                return(false);
            }
            //Set Control Bit
            var data = new byte[1];

            if (1 == eDriver_IO.Cls_edriverdll.i2c_read(volAddr, ctrlAddr, 1, 0, data, status))
            {
                enable = (0 != (byte)((~data[0]) & ctrlByte));
                return(true);
            }
            msg = Encoding.ASCII.GetString(status);
            return(false);
        }
Exemplo n.º 2
0
 public void TestGetChipAddr()
 {
     Assert.AreEqual(_vbmsDriverAddr.GetChipAddr(), 0x44);
 }