blob: 91b84c3f1267822ae0b67cb2d53c2b5967fcdbda [file] [log] [blame]
Tim Windelschmidt6d33a432025-02-04 14:34:25 +01001// Copyright The Monogon Project Authors.
2// SPDX-License-Identifier: Apache-2.0
3
Lorenz Brunbffdda82023-01-10 05:00:36 +00004package scsi
5
6import "errors"
7
8type InformationalExceptions struct {
9 InformationalSenseCode AdditionalSenseCode
10 Temperature uint8
11}
12
13func (d *Device) GetInformationalExceptions() (*InformationalExceptions, error) {
14 raw, err := d.LogSenseParameters(LogSenseRequest{PageCode: 0x0b})
15 if err != nil {
16 return nil, err
17 }
18 if len(raw[0x1]) == 0 {
19 return nil, errors.New("mandatory parameter 0001h missing")
20 }
21 param1 := raw[0x01][0]
22 if len(param1.Data) < 3 {
23 return nil, errors.New("parameter 0001h too short")
24 }
25 return &InformationalExceptions{
26 InformationalSenseCode: AdditionalSenseCode(uint16(param1.Data[0])<<8 | uint16(param1.Data[1])),
27 Temperature: param1.Data[2],
28 }, nil
29}