public static string PrettifyHPModePage_3B(HP_ModePage_3B?modePage) { if (!modePage.HasValue) { return(null); } HP_ModePage_3B page = modePage.Value; StringBuilder sb = new StringBuilder(); sb.AppendLine("HP Serial Number Override Mode Page:"); if (page.PS) { sb.AppendLine("\tParameters can be saved"); } switch (page.MSN) { case 1: sb.AppendLine("\tSerial number is the manufacturer's default value"); break; case 3: sb.AppendLine("\tSerial number is not the manufacturer's default value"); break; } sb.AppendFormat("\tSerial number: {0}", StringHandlers.CToString(page.SerialNumber)).AppendLine(); return(sb.ToString()); }
public static HP_ModePage_3B?DecodeHPModePage_3B(byte[] pageResponse) { if ((pageResponse?[0] &0x40) == 0x40) { return(null); } if ((pageResponse?[0] &0x3F) != 0x3B) { return(null); } if (pageResponse[1] + 2 != pageResponse.Length) { return(null); } if (pageResponse.Length != 16) { return(null); } HP_ModePage_3B decoded = new HP_ModePage_3B(); decoded.PS |= (pageResponse[0] & 0x80) == 0x80; decoded.MSN = (byte)(pageResponse[2] & 0x03); decoded.SerialNumber = new byte[10]; Array.Copy(pageResponse, 6, decoded.SerialNumber, 0, 10); return(decoded); }