| Tim Windelschmidt | 6d33a43 | 2025-02-04 14:34:25 +0100 | [diff] [blame^] | 1 | // Copyright The Monogon Project Authors. |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| Lorenz Brun | bffdda8 | 2023-01-10 05:00:36 +0000 | [diff] [blame] | 4 | package scsi |
| 5 | |
| 6 | import "errors" |
| 7 | |
| 8 | type InformationalExceptions struct { |
| 9 | InformationalSenseCode AdditionalSenseCode |
| 10 | Temperature uint8 |
| 11 | } |
| 12 | |
| 13 | func (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 | } |