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); }
public void TestGetChipAddr() { Assert.AreEqual(_vbmsDriverAddr.GetChipAddr(), 0x44); }