Get queries a single named parameter via "{get, }" and returns the parsed value. Device errors ("[!N]") are surfaced as errors wrapping ErrDeviceError. Callers should Drain() on non-device-error failures before retrying so a wedged port doesn't stay wedged.
(param string)
| 175 | // ErrDeviceError. Callers should Drain() on non-device-error failures |
| 176 | // before retrying so a wedged port doesn't stay wedged. |
| 177 | func (m *Mac) Get(param string) (string, error) { |
| 178 | if _, err := m.port.Write([]byte("{get," + param + "}")); err != nil { |
| 179 | return "", fmt.Errorf("write: %w", err) |
| 180 | } |
| 181 | resp, err := m.ReadResponse() |
| 182 | if err != nil { |
| 183 | return "", err |
| 184 | } |
| 185 | return ParseValue(resp) |
| 186 | } |
| 187 | |
| 188 | // ParseValue extracts the value from a "[=value]" response. "[!N]" replies |
| 189 | // are surfaced as errors wrapping ErrDeviceError with the numeric code. |