1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2015 Richard Hughes <richard@hughsie.com> 4 * 5 * Licensed under the GNU General Public License Version 2 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 */ 21 #include "config.h" 22 23 #include <glib.h> 24 25 #include "osp-enum.h" 26 27 /** 28 * osp_cmd_to_string: 29 * 30 * Since: 1.2.11 31 **/ 32 const gchar * osp_cmd_to_string(OspCmd cmd)33osp_cmd_to_string (OspCmd cmd) 34 { 35 if (cmd == OSP_CMD_RESET) 36 return "reset"; 37 if (cmd == OSP_CMD_RESET_TO_DEFAULTS) 38 return "reset-to-defaults"; 39 if (cmd == OSP_CMD_GET_HARDWARE_VERSION) 40 return "get-hardware-version"; 41 if (cmd == OSP_CMD_GET_FIRMWARE_VERSION) 42 return "get-firmware-version"; 43 if (cmd == OSP_CMD_GET_SERIAL_NUMBER) 44 return "get-serial-number"; 45 if (cmd == OSP_CMD_GET_SERIAL_NUMBER_LENGTH) 46 return "get-serial-number-length"; 47 if (cmd == OSP_CMD_GET_DEVICE_ALIAS) 48 return "get-device-alias"; 49 if (cmd == OSP_CMD_GET_DEVICE_ALIAS_LENGTH) 50 return "get-device-alias-length"; 51 if (cmd == OSP_CMD_SET_DEVICE_ALIAS) 52 return "set-device-alias"; 53 if (cmd == OSP_CMD_GET_NUMBER_OF_AVAILABLE_USER_STRINGS) 54 return "get-number-of-available-user-strings"; 55 if (cmd == OSP_CMD_GET_USER_STRING_LENGTH) 56 return "get-user-string-length"; 57 if (cmd == OSP_CMD_GET_USER_STRING) 58 return "get-user-string"; 59 if (cmd == OSP_CMD_SET_USER_STRING) 60 return "set-user-string"; 61 if (cmd == OSP_CMD_SET_LED) 62 return "configures-status-led"; 63 if (cmd == OSP_CMD_PUT_DEVICE_IN_REPROGRAMMING_MODE) 64 return "put-device-in-reprogramming-mode"; 65 if (cmd == OSP_CMD_GET_AND_SEND_CORRECTED_SPECTRUM) 66 return "get-and-send-corrected-spectrum"; 67 if (cmd == OSP_CMD_GET_AND_SEND_RAW_SPECTRUM) 68 return "get-and-send-raw-spectrum"; 69 if (cmd == OSP_CMD_GET_PARTIAL_SPECTRUM_MODE) 70 return "get-partial-spectrum-mode"; 71 if (cmd == OSP_CMD_SET_PARTIAL_SPECTRUM_MODE) 72 return "set-partial-spectrum-mode"; 73 if (cmd == OSP_CMD_GET_AND_SEND_PARTIAL_CORRECTED_SPECTRUM) 74 return "get-and-send-partial-corrected-spectrum"; 75 if (cmd == OSP_CMD_SET_INTEGRATION_TIME) 76 return "set-integration-time"; 77 if (cmd == OSP_CMD_GET_PIXEL_BINNING_FACTOR) 78 return "get-pixel-binning-factor"; 79 if (cmd == OSP_CMD_GET_MAXIMUM_BINNING_FACTOR) 80 return "get-maximum-binning-factor"; 81 if (cmd == OSP_CMD_GET_DEFAULT_BINNING_FACTOR) 82 return "get-default-binning-factor"; 83 if (cmd == OSP_CMD_SET_PIXEL_BINNING_FACTOR) 84 return "set-pixel-binning-factor"; 85 if (cmd == OSP_CMD_SET_DEFAULT_BINNING_FACTOR) 86 return "set-default-binning-factor"; 87 if (cmd == OSP_CMD_SET_TRIGGER_DELAY_MS) 88 return "set-trigger-delay-ms"; 89 if (cmd == OSP_CMD_GET_SCANS_TO_AVERAGE) 90 return "get-scans-to-average"; 91 if (cmd == OSP_CMD_SET_SCANS_TO_AVERAGE) 92 return "set-scans-to-average"; 93 if (cmd == OSP_CMD_GET_BOXCAR_WIDTH) 94 return "get-boxcar-width"; 95 if (cmd == OSP_CMD_SET_BOXCAR_WIDTH) 96 return "set-boxcar-width"; 97 if (cmd == OSP_CMD_GET_WAVELENGTH_COEFFICIENT_COUNT) 98 return "get-wavelength-coefficient-count"; 99 if (cmd == OSP_CMD_GET_WAVELENGTH_COEFFICIENT) 100 return "get-wavelength-coefficient"; 101 if (cmd == OSP_CMD_SET_WAVELENGTH_COEFFICIENT) 102 return "set-wavelength-coefficient"; 103 if (cmd == OSP_CMD_GET_NONLINEARITY_COEFFICIENT_COUNT) 104 return "get-nonlinearity-coefficient-count"; 105 if (cmd == OSP_CMD_GET_NONLINEARITY_COEFFICIENT) 106 return "get-nonlinearity-coefficient"; 107 if (cmd == OSP_CMD_SET_NONLINEARITY_COEFFICIENT) 108 return "set-nonlinearity-coefficient"; 109 if (cmd == OSP_CMD_GET_IRRADIANCE_CALIBRATION) 110 return "get-irradiance-calibration"; 111 if (cmd == OSP_CMD_GET_IRRADIANCE_CALIBRATION_COUNT) 112 return "get-irradiance-calibration-count"; 113 if (cmd == OSP_CMD_GET_IRRADIANCE_CALIBRATION_COLLECTION_AREA) 114 return "get-irradiance-calibration-collection-area"; 115 if (cmd == OSP_CMD_SET_IRRADIANCE_CALIBRATION) 116 return "set-irradiance-calibration"; 117 if (cmd == OSP_CMD_SET_IRRADIANCE_CALIBRATION_COLLECTION_AREA) 118 return "set-irradiance-calibration-collection-area"; 119 if (cmd == OSP_CMD_GET_NUMBER_OF_STRAY_LIGHT_COEFFICIENTS) 120 return "get-number-of-stray-light-coefficients"; 121 if (cmd == OSP_CMD_GET_STRAY_LIGHT_COEFFICIENT) 122 return "get-stray-light-coefficient"; 123 if (cmd == OSP_CMD_SET_STRAY_LIGHT_COEFFICIENT) 124 return "set-stray-light-coefficient"; 125 if (cmd == OSP_CMD_GET_HOT_PIXEL_INDICES) 126 return "get-hot-pixel-indices"; 127 if (cmd == OSP_CMD_SET_HOT_PIXEL_INDICES) 128 return "set-hot-pixel-indices"; 129 if (cmd == OSP_CMD_GET_BENCH_ID) 130 return "get-bench-id"; 131 if (cmd == OSP_CMD_GET_BENCH_SERIAL_NUMBER) 132 return "get-bench-serial-number"; 133 if (cmd == OSP_CMD_GET_SLIT_WIDTH_MICRONS) 134 return "get-slit-width-microns"; 135 if (cmd == OSP_CMD_GET_FIBER_DIAMETER_MICRONS) 136 return "get-fiber-diameter-microns"; 137 if (cmd == OSP_CMD_GET_GRATING) 138 return "get-grating"; 139 if (cmd == OSP_CMD_GET_FILTER) 140 return "get-filter"; 141 if (cmd == OSP_CMD_GET_COATING) 142 return "get-coating"; 143 if (cmd == OSP_CMD_GET_GET_TEMPERATURE_SENSOR_COUNT) 144 return "get-temperature-sensor-count"; 145 if (cmd == OSP_CMD_GET_READ_TEMPERATURE_SENSOR) 146 return "read-temperature-sensor"; 147 if (cmd == OSP_CMD_GET_READ_ALL_TEMPERATURE_SENSORS) 148 return "read-all-temperature-sensors"; 149 return NULL; 150 } 151 152 /** 153 * osp_error_code_to_string: 154 * 155 * Since: 1.2.11 156 **/ 157 const gchar * osp_error_code_to_string(OspErrorCode error_code)158osp_error_code_to_string (OspErrorCode error_code) 159 { 160 if (error_code == OSP_ERROR_CODE_SUCCESS) 161 return "success"; 162 if (error_code == OSP_ERROR_CODE_UNSUPPORTED_PROTOCOL) 163 return "unsupported-protocol"; 164 if (error_code == OSP_ERROR_CODE_UNKNOWN_MESSAGE_TYPE) 165 return "unknown-message-type"; 166 if (error_code == OSP_ERROR_CODE_BAD_CHECKSUM) 167 return "bad-checksum"; 168 if (error_code == OSP_ERROR_CODE_MESSAGE_TOO_LARGE) 169 return "message-too-large"; 170 if (error_code == OSP_ERROR_CODE_PAYLOAD_LENGTH_INVALID) 171 return "payload-length-invalid"; 172 if (error_code == OSP_ERROR_CODE_PAYLOAD_DATA_INVALID) 173 return "payload-data-invalid"; 174 if (error_code == OSP_ERROR_CODE_DEVICE_NOT_READY) 175 return "device-not-ready"; 176 if (error_code == OSP_ERROR_CODE_UNKNOWN_CHECKSUM_TYPE) 177 return "unknown-checksum-type"; 178 if (error_code == OSP_ERROR_CODE_DEVICE_RESET) 179 return "device-reset"; 180 if (error_code == OSP_ERROR_CODE_TOO_MANY_BUSES) 181 return "too-many-busses"; 182 if (error_code == OSP_ERROR_CODE_OUT_OF_MEMORY) 183 return "out-of-memory"; 184 if (error_code == OSP_ERROR_CODE_COMMAND_DATA_MISSING) 185 return "command-data-missing"; 186 if (error_code == OSP_ERROR_CODE_INTERNAL_ERROR) 187 return "internal-error"; 188 if (error_code == OSP_ERROR_CODE_COULD_NOT_DECRYPT) 189 return "could-not-decrypt"; 190 if (error_code == OSP_ERROR_CODE_FIRMWARE_LAYOUT_INVALID) 191 return "firmware-layout-invalid"; 192 if (error_code == OSP_ERROR_CODE_DATA_PACKET_INVALID_SIZE) 193 return "packet-invalid-size"; 194 if (error_code == OSP_ERROR_CODE_HW_REVISION_INVALID) 195 return "hardware-revision-invalid"; 196 if (error_code == OSP_ERROR_CODE_FLASH_MAP_INVALID) 197 return "flash-map-invalid"; 198 if (error_code == OSP_ERROR_CODE_RESPONSE_DEFERRED) 199 return "response-deferred"; 200 return NULL; 201 } 202