1use super::{PicoError, PicoResult};
2use num_derive::*;
3use std::convert::From;
4use thiserror::Error;
5
6#[allow(non_camel_case_types)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11#[derive(Debug, Clone, Copy, Eq, PartialEq, FromPrimitive, ToPrimitive, Error)]
12pub enum PicoStatus {
13 #[error("The PicoScope is functioning correctly")]
14 OK = 0,
15 #[error("An attempt has been made to open more than to allowed max units")]
16 MAX_UNITS_OPENED = 1,
17 #[error("Not enough memory could be allocated on the host machine")]
18 MEMORY_FAIL = 2,
19 #[error("No matching device could be found")]
20 NOT_FOUND = 3,
21 #[error("Unable to download firmware")]
22 FW_FAIL = 4,
23 #[error("The driver is busy opening a device")]
24 OPEN_OPERATION_IN_PROGRESS = 5,
25 #[error("An unspecified failure occurred")]
26 OPERATION_FAILED = 6,
27 #[error("The PicoScope is not responding to commands from the PC")]
28 NOT_RESPONDING = 7,
29 #[error("The configuration information in the PicoScope is corrupt or missing")]
30 CONFIG_FAIL = 8,
31 #[error("The picopp.sys file is too old to be used with the device driver")]
32 KERNEL_DRIVER_TOO_OLD = 9,
33 #[error("The EEPROM has become corrupt, so the device will use a default setting")]
34 EEPROM_CORRUPT = 10,
35 #[error("The operating system on the PC is not supported by this driver")]
36 OS_NOT_SUPPORTED = 11,
37 #[error("There is no device with the handle value passed")]
38 INVALID_HANDLE = 12,
39 #[error("A parameter value is not valid")]
40 INVALID_PARAMETER = 13,
41 #[error("The timebase is not supported or is invalid")]
42 INVALID_TIMEBASE = 14,
43 #[error("The voltage range is not supported or is invalid")]
44 INVALID_VOLTAGE_RANGE = 15,
45 #[error("The channel is not valid for this device")]
46 INVALID_CHANNEL = 16,
47 #[error("The channel set for a trigger is not available on this device")]
48 INVALID_TRIGGER_CHANNEL = 17,
49 #[error("The channel set for a condition is not available on this device")]
50 INVALID_CONDITION_CHANNEL = 18,
51 #[error("The device does not have a signal generator")]
52 NO_SIGNAL_GENERATOR = 19,
53 #[error("Streaming has failed to start or has stopped without user request")]
54 STREAMING_FAILED = 20,
55 #[error("Block failed to start - a parameter may have been set wrongly")]
56 BLOCK_MODE_FAILED = 21,
57 #[error("A parameter that was required is NULL")]
58 NULL_PARAMETER = 22,
59 #[error("The current functionality is not available while using ETS capture mode")]
60 ETS_MODE_SET = 23,
61 #[error("No data is available from a run block call")]
62 DATA_NOT_AVAILABLE = 24,
63 #[error("The buffer passed for the information was too small")]
64 STRING_BUFFER_TO_SMALL = 25,
65 #[error("ETS is not supported on this device")]
66 ETS_NOT_SUPPORTED = 26,
67 #[error(
68 "The auto trigger time is less than the time it will take to collect the pre-trigger data"
69 )]
70 AUTO_TRIGGER_TIME_TO_SHORT = 27,
71 #[error("The collection of data has stalled as unread data would be overwritten")]
72 BUFFER_STALL = 28,
73 #[error("Number of samples requested is more than available in the current memory segment")]
74 TOO_MANY_SAMPLES = 29,
75 #[error("Not possible to create number of segments requested")]
76 TOO_MANY_SEGMENTS = 30,
77 #[error("A null pointer has been passed in the trigger function or one of the parameters is out of range"
78 )]
79 PULSE_WIDTH_QUALIFIER = 31,
80 #[error("One or more of the hold-off parameters are out of range")]
81 DELAY = 32,
82 #[error("One or more of the source details are incorrect")]
83 SOURCE_DETAILS = 33,
84 #[error("One or more of the conditions are incorrect")]
85 CONDITIONS = 34,
86 #[error("The driver's thread is currently in the Ready callback function and therefore the action cannot be carried out"
87 )]
88 USER_CALLBACK = 35,
89 #[error("An attempt is being made to get stored data while streaming. Either stop streaming by calling Stop, or use <API>GetStreamingLatestValues"
90 )]
91 DEVICE_SAMPLING = 36,
92 #[error("Data is unavailable because a run has not been completed")]
93 NO_SAMPLES_AVAILABLE = 37,
94 #[error("The memory segment index is out of range")]
95 SEGMENT_OUT_OF_RANGE = 38,
96 #[error("The device is busy so data cannot be returned yet")]
97 BUSY = 39,
98 #[error("The start time to get stored data is out of range")]
99 STARTINDEX_INVALID = 40,
100 #[error("The information number requested is not a valid number")]
101 INVALID_INFO = 41,
102 #[error("The handle is invalid so no information is available about the device. Only PICO_DRIVER_VERSION is available"
103 )]
104 INFO_UNAVAILABLE = 42,
105 #[error("The sample interval selected for streaming is out of range")]
106 INVALID_SAMPLE_INTERVAL = 43,
107 #[error("ETS is set but no trigger has been set. A trigger setting is required for ETS")]
108 TRIGGER_ERROR = 44,
109 #[error("Driver cannot allocate memory")]
110 MEMORY = 45,
111 #[error("Incorrect parameter passed to the signal generator")]
112 SIG_GEN_PARAM = 46,
113 #[error("Conflict between the shots and sweeps parameters sent to the signal generator")]
114 SHOTS_SWEEPS_WARNING = 47,
115 #[error("A software trigger has been sent but the trigger source is not a software trigger")]
116 SIGGEN_TRIGGER_SOURCE = 48,
117 #[error("An SetTrigger call has found a conflict between the trigger source and the AUX output enable"
118 )]
119 AUX_OUTPUT_CONFLICT = 49,
120 #[error("ETS mode is being used and AUX is set as an input")]
121 AUX_OUTPUT_ETS_CONFLICT = 50,
122 #[error("Attempt to set different EXT input thresholds set for signal generator and oscilloscope trigger"
123 )]
124 WARNING_EXT_THRESHOLD_CONFLICT = 51,
125 #[error("An SetTrigger... function has set AUX as an output and the signal generator is using it as a trigger"
126 )]
127 WARNING_AUX_OUTPUT_CONFLICT = 52,
128 #[error("The combined peak-to-peak voltage and the analog offset voltage exceed the maximum voltage the signal generator can produce"
129 )]
130 SIGGEN_OUTPUT_OVER_VOLTAGE = 53,
131 #[error("NULL pointer passed as delay parameter")]
132 DELAY_NULL = 54,
133 #[error("The buffers for overview data have not been set while streaming")]
134 INVALID_BUFFER = 55,
135 #[error("The analog offset voltage is out of range")]
136 SIGGEN_OFFSET_VOLTAGE = 56,
137 #[error("The analog peak-to-peak voltage is out of range")]
138 SIGGEN_PK_TO_PK = 57,
139 #[error("A block collection has been cancelled")]
140 CANCELLED = 58,
141 #[error("The segment index is not currently being used")]
142 SEGMENT_NOT_USED = 59,
143 #[error("The wrong GetValues function has been called for the collection mode in use")]
144 INVALID_CALL = 60,
145 #[error("")]
146 GET_VALUES_INTERRUPTED = 61,
147 #[error("The function is not available")]
148 NOT_USED = 63,
149 #[error("The aggregation ratio requested is out of range")]
150 INVALID_SAMPLERATIO = 64,
151 #[error("Device is in an invalid state")]
152 INVALID_STATE = 65,
153 #[error("The number of segments allocated is fewer than the number of captures requested")]
154 NOT_ENOUGH_SEGMENTS = 66,
155 #[error("A driver function has already been called and not yet finished. Only one call to the driver can be made at any one time"
156 )]
157 DRIVER_FUNCTION = 67,
158 #[error("Not used")]
159 RESERVED = 68,
160 #[error("An invalid coupling type was specified in SetChannel")]
161 INVALID_COUPLING = 69,
162 #[error("An attempt was made to get data before a data buffer was defined")]
163 BUFFERS_NOT_SET = 70,
164 #[error("The selected downsampling mode (used for data reduction) is not allowed")]
165 RATIO_MODE_NOT_SUPPORTED = 71,
166 #[error("Aggregation was requested in rapid block mode")]
167 RAPID_NOT_SUPPORT_AGGREGATION = 72,
168 #[error("An invalid parameter was passed to SetTriggerChannelProperties(V2)")]
169 INVALID_TRIGGER_PROPERTY = 73,
170 #[error("The driver was unable to contact the oscilloscope")]
171 INTERFACE_NOT_CONNECTED = 74,
172 #[error("Resistance-measuring mode is not allowed in conjunction with the specified probe")]
173 RESISTANCE_AND_PROBE_NOT_ALLOWED = 75,
174 #[error("The device was unexpectedly powered down")]
175 POWER_FAILED = 76,
176 #[error("A problem occurred in SetSigGenBuiltIn or SetSigGenArbitrary")]
177 SIGGEN_WAVEFORM_SETUP_FAILED = 77,
178 #[error("FPGA not successfully set up")]
179 FPGA_FAIL = 78,
180 #[error("")]
181 POWER_MANAGER = 79,
182 #[error("An impossible analog offset value was specified in SetChannel")]
183 INVALID_ANALOGUE_OFFSET = 80,
184 #[error("There is an error within the device hardware")]
185 PLL_LOCK_FAILED = 81,
186 #[error("There is an error within the device hardware")]
187 ANALOG_BOARD = 82,
188 #[error("Unable to configure the signal generator")]
189 CONFIG_FAIL_AWG = 83,
190 #[error("The FPGA cannot be initialized, so unit cannot be opened")]
191 INITIALISE_FPGA = 84,
192 #[error("The frequency for the external clock is not within 15% of the nominal value")]
193 EXTERNAL_FREQUENCY_INVALID = 86,
194 #[error("The FPGA could not lock the clock signal")]
195 CLOCK_CHANGE_ERROR = 87,
196 #[error("You are trying to configure the AUX input as both a trigger and a reference clock")]
197 TRIGGER_AND_EXTERNAL_CLOCK_CLASH = 88,
198 #[error("You are trying to configure the AUX input as both a pulse width qualifier and a reference clock"
199 )]
200 PWQ_AND_EXTERNAL_CLOCK_CLASH = 89,
201 #[error("The requested scaling file cannot be opened")]
202 UNABLE_TO_OPEN_SCALING_FILE = 90,
203 #[error("The frequency of the memory is reporting incorrectly")]
204 MEMORY_CLOCK_FREQUENCY = 91,
205 #[error("The I2C that is being actioned is not responding to requests")]
206 I2C_NOT_RESPONDING = 92,
207 #[error("There are no captures available and therefore no data can be returned")]
208 NO_CAPTURES_AVAILABLE = 93,
209 #[error("The number of trigger channels is greater than 4, except for a PicoScope 4824 where 8 channels are allowed for rising/falling/rising_or_falling trigger directions"
210 )]
211 TOO_MANY_TRIGGER_CHANNELS_IN_USE = 95,
212 #[error("When more than 4 trigger channels are set on a PicoScope 4824 and the direction is out of range"
213 )]
214 INVALID_TRIGGER_DIRECTION = 96,
215 #[error("When more than 4 trigger channels are set and their trigger condition states are not CONDITION_TRUE"
216 )]
217 INVALID_TRIGGER_STATES = 97,
218 #[error(
219 "The capture mode the device is currently running in does not support the current request"
220 )]
221 NOT_USED_IN_THIS_CAPTURE_MODE = 94,
222 #[error("")]
223 GET_DATA_ACTIVE = 259,
224 #[error("")]
225 IP_NETWORKED = 260,
226 #[error("")]
227 INVALID_IP_ADDRESS = 261,
228 #[error("")]
229 IPSOCKET_FAILED = 262,
230 #[error("")]
231 IPSOCKET_TIMEDOUT = 263,
232 #[error("")]
233 SETTINGS_FAILED = 264,
234 #[error("")]
235 NETWORK_FAILED = 265,
236 #[error("")]
237 WS2_32_DLL_NOT_LOADED = 266,
238 #[error("")]
239 INVALID_IP_PORT = 267,
240 #[error("The type of coupling requested is not supported on the opened device")]
241 COUPLING_NOT_SUPPORTED = 268,
242 #[error("Bandwidth limiting is not supported on the opened device")]
243 BANDWIDTH_NOT_SUPPORTED = 269,
244 #[error("The value requested for the bandwidth limit is out of range")]
245 INVALID_BANDWIDTH = 270,
246 #[error("The arbitrary waveform generator is not supported by the opened device")]
247 AWG_NOT_SUPPORTED = 271,
248 #[error("Data has been requested with ETS mode set but run block has not been called, or stop has been called"
249 )]
250 ETS_NOT_RUNNING = 272,
251 #[error("White noise output is not supported on the opened device")]
252 SIG_GEN_WHITENOISE_NOT_SUPPORTED = 273,
253 #[error("The wave type requested is not supported by the opened device")]
254 SIG_GEN_WAVETYPE_NOT_SUPPORTED = 274,
255 #[error("The requested digital port number is out of range (MSOs only)")]
256 INVALID_DIGITAL_PORT = 275,
257 #[error("The digital channel is not in the range DIGITAL_CHANNEL0 to DIGITAL_CHANNEL15, the digital channels that are supported"
258 )]
259 INVALID_DIGITAL_CHANNEL = 276,
260 #[error("The digital trigger direction is not a valid trigger direction and should be equal in value to one of the DIGITAL_DIRECTION enumerations"
261 )]
262 INVALID_DIGITAL_TRIGGER_DIRECTION = 277,
263 #[error("Signal generator does not generate pseudo-random binary sequence")]
264 SIG_GEN_PRBS_NOT_SUPPORTED = 278,
265 #[error("When a digital port is enabled, ETS sample mode is not available for use")]
266 ETS_NOT_AVAILABLE_WITH_LOGIC_CHANNELS = 279,
267 #[error("There has been no new sample taken, this value has already been returned previously")]
268 WARNING_REPEAT_VALUE = 280,
269 #[error("4-channel scopes only: The DC power supply is connected.")]
270 POWER_SUPPLY_CONNECTED = 281,
271 #[error("4-channel scopes only: The DC power supply is not connected.")]
272 POWER_SUPPLY_NOT_CONNECTED = 282,
273 #[error("Incorrect power mode passed for current power source")]
274 POWER_SUPPLY_REQUEST_INVALID = 283,
275 #[error("The supply voltage from the USB source is too low")]
276 POWER_SUPPLY_UNDERVOLTAGE = 284,
277 #[error("The oscilloscope is in the process of capturing data")]
278 CAPTURING_DATA = 285,
279 #[error("A USB 3.0 device is connected to a non-USB 3.0 port")]
280 USB3_0_DEVICE_NON_USB3_0_PORT = 286,
281 #[error("A function has been called that is not supported by the current device")]
282 NOT_SUPPORTED_BY_THIS_DEVICE = 287,
283 #[error("The device resolution is invalid (out of range)")]
284 INVALID_DEVICE_RESOLUTION = 288,
285 #[error("The number of channels that can be enabled is limited in 15 and 16-bit modes. (Flexible Resolution Oscilloscopes only)"
286 )]
287 INVALID_NUMBER_CHANNELS_FOR_RESOLUTION = 289,
288 #[error("USB power not sufficient for all requested channels")]
289 CHANNEL_DISABLED_DUE_TO_USB_POWERED = 290,
290 #[error("The signal generator does not have a configurable DC offset")]
291 SIGGEN_DC_VOLTAGE_NOT_CONFIGURABLE = 291,
292 #[error(
293 "An attempt has been made to define pre-trigger delay without first enabling a trigger"
294 )]
295 NO_TRIGGER_ENABLED_FOR_TRIGGER_IN_PRE_TRIG = 292,
296 #[error("An attempt has been made to define pre-trigger delay without first arming a trigger")]
297 TRIGGER_WITHIN_PRE_TRIG_NOT_ARMED = 293,
298 #[error("Pre-trigger delay and post-trigger delay cannot be used at the same time")]
299 TRIGGER_WITHIN_PRE_NOT_ALLOWED_WITH_DELAY = 294,
300 #[error("The array index points to a nonexistent trigger")]
301 TRIGGER_INDEX_UNAVAILABLE = 295,
302 #[error("")]
303 AWG_CLOCK_FREQUENCY = 296,
304 #[error("There are more than 4 analog channels with a trigger condition set")]
305 TOO_MANY_CHANNELS_IN_USE = 297,
306 #[error("The condition parameter is a null pointer")]
307 NULL_CONDITIONS = 298,
308 #[error("There is more than one condition pertaining to the same channel")]
309 DUPLICATE_CONDITION_SOURCE = 299,
310 #[error("The parameter relating to condition information is out of range")]
311 INVALID_CONDITION_INFO = 300,
312 #[error("Reading the meta data has failed")]
313 SETTINGS_READ_FAILED = 301,
314 #[error("Writing the meta data has failed")]
315 SETTINGS_WRITE_FAILED = 302,
316 #[error("A parameter has a value out of the expected range")]
317 ARGUMENT_OUT_OF_RANGE = 303,
318 #[error("The driver does not support the hardware variant connected")]
319 HARDWARE_VERSION_NOT_SUPPORTED = 304,
320 #[error("The driver does not support the digital hardware variant connected")]
321 DIGITAL_HARDWARE_VERSION_NOT_SUPPORTED = 305,
322 #[error("The driver does not support the analog hardware variant connected")]
323 ANALOGUE_HARDWARE_VERSION_NOT_SUPPORTED = 306,
324 #[error("Converting a channel's ADC value to resistance has failed")]
325 UNABLE_TO_CONVERT_TO_RESISTANCE = 307,
326 #[error("The channel is listed more than once in the function call")]
327 DUPLICATED_CHANNEL = 308,
328 #[error("The range cannot have resistance conversion applied")]
329 INVALID_RESISTANCE_CONVERSION = 309,
330 #[error("An invalid value is in the max buffer")]
331 INVALID_VALUE_IN_MAX_BUFFER = 310,
332 #[error("An invalid value is in the min buffer")]
333 INVALID_VALUE_IN_MIN_BUFFER = 311,
334 #[error("When calculating the frequency for phase conversion, the frequency is greater than that supported by the current variant"
335 )]
336 SIGGEN_FREQUENCY_OUT_OF_RANGE = 312,
337 #[error("The device's EEPROM is corrupt. Contact Pico Technology support: https://www.picotech.com/tech-support"
338 )]
339 EEPROM2_CORRUPT = 313,
340 #[error("The EEPROM has failed")]
341 EEPROM2_FAIL = 314,
342 #[error("The serial buffer is too small for the required information")]
343 SERIAL_BUFFER_TOO_SMALL = 315,
344 #[error("The signal generator trigger and the external clock have both been set. This is not allowed"
345 )]
346 SIGGEN_TRIGGER_AND_EXTERNAL_CLOCK_CLASH = 316,
347 #[error("The AUX trigger was enabled and the external clock has been enabled, so the AUX has been automatically disabled"
348 )]
349 WARNING_SIGGEN_AUXIO_TRIGGER_DISABLED = 317,
350 #[error("The AUX I/O was set as a scope trigger and is now being set as a signal generator gating trigger. This is not allowed"
351 )]
352 SIGGEN_GATING_AUXIO_NOT_AVAILABLE = 318,
353 #[error("The AUX I/O was set by the signal generator as a gating trigger and is now being set as a scope trigger. This is not allowed"
354 )]
355 SIGGEN_GATING_AUXIO_ENABLED = 319,
356 #[error("A resource has failed to initialise")]
357 RESOURCE_ERROR = 320,
358 #[error("The temperature type is out of range")]
359 TEMPERATURE_TYPE_INVALID = 321,
360 #[error("A requested temperature type is not supported on this device")]
361 TEMPERATURE_TYPE_NOT_SUPPORTED = 322,
362 #[error("A read/write to the device has timed out")]
363 TIMEOUT = 323,
364 #[error("The device cannot be connected correctly")]
365 DEVICE_NOT_FUNCTIONING = 324,
366 #[error(
367 "The driver has experienced an unknown error and is unable to recover from this error"
368 )]
369 INTERNAL_ERROR = 325,
370 #[error("Multiple devices found")]
371 MULTIPLE_DEVICES_FOUND = 326,
372 #[error("")]
373 WARNING_NUMBER_OF_SEGMENTS_REDUCED = 327,
374 #[error("The calibration pin states argument is out of range")]
375 CAL_PINS_STATES = 328,
376 #[error("The calibration pin frequency argument is out of range")]
377 CAL_PINS_FREQUENCY = 329,
378 #[error("The calibration pin amplitude argument is out of range")]
379 CAL_PINS_AMPLITUDE = 330,
380 #[error("The calibration pin wavetype argument is out of range")]
381 CAL_PINS_WAVETYPE = 331,
382 #[error("The calibration pin offset argument is out of range")]
383 CAL_PINS_OFFSET = 332,
384 #[error("The probe's identity has a problem")]
385 PROBE_FAULT = 333,
386 #[error("The probe has not been identified")]
387 PROBE_IDENTITY_UNKNOWN = 334,
388 #[error("Enabling the probe would cause the device to exceed the allowable current limit")]
389 PROBE_POWER_DC_POWER_SUPPLY_REQUIRED = 335,
390 #[error("The DC power supply is connected; enabling the probe would cause the device to exceed the allowable current limit"
391 )]
392 PROBE_NOT_POWERED_WITH_DC_POWER_SUPPLY = 336,
393 #[error("Failed to complete probe configuration")]
394 PROBE_CONFIG_FAILURE = 337,
395 #[error("Failed to set the callback function, as currently in current callback function")]
396 PROBE_INTERACTION_CALLBACK = 338,
397 #[error("The probe has been verified but not known on this driver")]
398 UNKNOWN_INTELLIGENT_PROBE = 339,
399 #[error("The intelligent probe cannot be verified")]
400 INTELLIGENT_PROBE_CORRUPT = 340,
401 #[error("The callback is null, probe collection will only start when first callback is a none null pointer"
402 )]
403 PROBE_COLLECTION_NOT_STARTED = 341,
404 #[error("The current drawn by the probe(s) has exceeded the allowed limit")]
405 PROBE_POWER_CONSUMPTION_EXCEEDED = 342,
406 #[error("The channel range limits have changed due to connecting or disconnecting a probe the channel has been enabled"
407 )]
408 WARNING_PROBE_CHANNEL_OUT_OF_SYNC = 343,
409 #[error("")]
410 ENDPOINT_MISSING = 344,
411 #[error("")]
412 UNKNOWN_ENDPOINT_REQUEST = 345,
413 #[error("The ADC on board the device has not been correctly identified")]
414 ADC_TYPE_ERROR = 346,
415 #[error("")]
416 FPGA2_FAILED = 347,
417 #[error("")]
418 FPGA2_DEVICE_STATUS = 348,
419 #[error("")]
420 ENABLE_PROGRAM_FPGA2_FAILED = 349,
421 #[error("")]
422 NO_CHANNELS_OR_PORTS_ENABLED = 350,
423 #[error("")]
424 INVALID_RATIO_MODE = 351,
425 #[error("")]
426 READS_NOT_SUPPORTED_IN_CURRENT_CAPTURE_MODE = 352,
427 #[error("")]
428 READ1_SELECTION_CHECK_FAILED = 353,
429 #[error("")]
430 READ2_SELECTION_CHECK_FAILED = 354,
431 #[error("")]
432 READ3_SELECTION_CHECK_FAILED = 356,
433 #[error("")]
434 READ4_SELECTION_CHECK_FAILED = 360,
435 #[error("The requested read is not one of the reads available in enPicoReadSelection")]
436 READ_SELECTION_OUT_OF_RANGE = 368,
437 #[error("The downsample ratio options cannot be combined together for this request")]
438 MULTIPLE_RATIO_MODES = 369,
439 #[error("The enPicoReadSelection request has no samples available")]
440 NO_SAMPLES_READ = 370,
441 #[error("The enPicoReadSelection did not include one of the downsample ratios now requested")]
442 RATIO_MODE_NOT_REQUESTED = 371,
443 #[error("No read requests have been made")]
444 NO_USER_READ_REQUESTS_SET = 372,
445 #[error("The parameter for <number of values> cannot be zero")]
446 ZERO_SAMPLES_INVALID = 373,
447 #[error("The analog hardware cannot be identified; contact Pico Technology Technical Support")]
448 ANALOGUE_HARDWARE_MISSING = 374,
449 #[error("Setting of the analog hardware pins failed")]
450 ANALOGUE_HARDWARE_PINS = 375,
451 #[error("An SMPS fault has occurred")]
452 ANALOGUE_HARDWARE_SMPS_FAULT = 376,
453 #[error("There appears to be a conflict between the expected and actual hardware in the device; contact Pico Technology Technical Support"
454 )]
455 DIGITAL_ANALOGUE_HARDWARE_CONFLICT = 377,
456 #[error("One or more of the enPicoRatioMode requested do not have a data buffer set")]
457 RATIO_MODE_BUFFER_NOT_SET = 378,
458 #[error("The resolution is valid but not supported by the opened device")]
459 RESOLUTION_NOT_SUPPORTED_BY_VARIANT = 379,
460 #[error("The requested trigger threshold is out of range for the current device resolution")]
461 THRESHOLD_OUT_OF_RANGE = 380,
462 #[error("The simple trigger only supports upper edge direction options")]
463 INVALID_SIMPLE_TRIGGER_DIRECTION = 381,
464 #[error("The aux trigger is not supported on this variant")]
465 AUX_NOT_SUPPORTED = 382,
466 #[error("The trigger directions pointer may not be null")]
467 NULL_DIRECTIONS = 383,
468 #[error("The trigger channel properties pointer may not be null")]
469 NULL_CHANNEL_PROPERTIES = 384,
470 #[error("A trigger is set on a channel that has not been enabled")]
471 TRIGGER_CHANNEL_NOT_ENABLED = 385,
472 #[error("A trigger condition has been set but a trigger property not set")]
473 CONDITION_HAS_NO_TRIGGER_PROPERTY = 386,
474 #[error("When requesting trigger data, this option can only be combined with the segment header ratio mode flag"
475 )]
476 RATIO_MODE_TRIGGER_MASKING_INVALID = 387,
477 #[error("The trigger data buffer must be 40 or more samples in size")]
478 TRIGGER_DATA_REQUIRES_MIN_BUFFER_SIZE_OF_40_SAMPLES = 388,
479 #[error(
480 "The number of requested waveforms is greater than the number of memory segments allocated"
481 )]
482 NO_OF_CAPTURES_OUT_OF_RANGE = 389,
483 #[error("When requesting segment header information, the segment header does not require a data buffer, to get the segment information use GetTriggerInfo"
484 )]
485 RATIO_MODE_SEGMENT_HEADER_DOES_NOT_REQUIRE_BUFFERS = 390,
486 #[error("Use GetTriggerInfo to retrieve the segment header information")]
487 FOR_SEGMENT_HEADER_USE_GETTRIGGERINFO = 391,
488 #[error("A read request has not been set")]
489 READ_NOT_SET = 392,
490 #[error("The expected and actual states of the ADCs do not match")]
491 ADC_SETTING_MISMATCH = 393,
492 #[error("The requested data type is not one of the enPicoDataType listed")]
493 DATATYPE_INVALID = 394,
494 #[error(
495 "The down sample ratio mode requested does not support the enPicoDataType option chosen"
496 )]
497 RATIO_MODE_DOES_NOT_SUPPORT_DATATYPE = 395,
498 #[error("The channel combination is not valid for the resolution")]
499 CHANNEL_COMBINATION_NOT_VALID_IN_THIS_RESOLUTION = 396,
500 #[error("")]
501 USE_8BIT_RESOLUTION = 397,
502 #[error("The buffer for minimum data values and maximum data values are the same buffers")]
503 AGGREGATE_BUFFERS_SAME_POINTER = 398,
504 #[error("The read request number of samples requested for an overlapped operation are more than the total number of samples to capture"
505 )]
506 OVERLAPPED_READ_VALUES_OUT_OF_RANGE = 399,
507 #[error("The overlapped read request has more segments specified than segments allocated")]
508 OVERLAPPED_READ_SEGMENTS_OUT_OF_RANGE = 400,
509 #[error(
510 "The number of channel combinations available are greater than the array size received"
511 )]
512 CHANNELFLAGSCOMBINATIONS_ARRAY_SIZE_TOO_SMALL = 401,
513 #[error("The number of captures is larger than the maximum number of segments allowed for the device variant"
514 )]
515 CAPTURES_EXCEEDS_NO_OF_SUPPORTED_SEGMENTS = 402,
516 #[error("The time unit requested is not one of the listed enPicoTimeUnits")]
517 TIME_UNITS_OUT_OF_RANGE = 403,
518 #[error("The number of samples parameter may not be zero")]
519 NO_SAMPLES_REQUESTED = 404,
520 #[error("The action requested is not listed in enPicoAction")]
521 INVALID_ACTION = 405,
522 #[error("When adding buffers for the same read request the buffers for all ratio mode requests have to be the same size"
523 )]
524 NO_OF_SAMPLES_NEED_TO_BE_EQUAL_WHEN_ADDING_BUFFERS = 406,
525 #[error("The data is being processed but there is no empty data buffers available, a new data buffer needs to be set sent to the driver so that the data can be processed"
526 )]
527 WAITING_FOR_DATA_BUFFERS = 407,
528 #[error("when streaming data, only one read option is available")]
529 STREAMING_ONLY_SUPPORTS_ONE_READ = 408,
530 #[error("A clear read request is not one of the enPicoAction listed")]
531 CLEAR_DATA_BUFFER_INVALID = 409,
532 #[error("The combination of action flags are not allowed")]
533 INVALID_ACTION_FLAGS_COMBINATION = 410,
534 #[error("PICO_ADD request has been made but both data buffers are set to null and so there is nowhere to put the data"
535 )]
536 BOTH_MIN_AND_MAX_NULL_BUFFERS_CANNOT_BE_ADDED = 411,
537 #[error("A conflict between the data buffers being set has occurred. Please use the PICO_CLEAR_ALL action to reset"
538 )]
539 CONFLICT_IN_SET_DATA_BUFFERS_CALL_REMOVE_DATA_BUFFER_TO_RESET = 412,
540 #[error("While processing data, buffers cannot be removed from the data buffers list")]
541 REMOVING_DATA_BUFFER_ENTRIES_NOT_ALLOWED_WHILE_DATA_PROCESSING = 413,
542 #[error("An USB request has failed")]
543 CYUSB_REQUEST_FAILED = 512,
544 #[error("A request has been made to retrieve the latest streaming data, but with either a null pointer or an array size set to zero"
545 )]
546 STREAMING_DATA_REQUIRED = 513,
547 #[error("A buffer being set has a length that is invalid (ie less than zero)")]
548 INVALID_NUMBER_OF_SAMPLES = 514,
549 #[error("The distribution size may not be zero")]
550 INVALID_DISTRIBUTION = 515,
551 #[error("The buffer length in bytes is greater than a 4-byte word")]
552 BUFFER_LENGTH_GREATER_THAN_INT32_T = 516,
553 #[error("The PLL has failed")]
554 PLL_MUX_OUT_FAILED = 521,
555 #[error("Pulse width only supports one direction")]
556 ONE_PULSE_WIDTH_DIRECTION_ALLOWED = 522,
557 #[error("There is no external trigger available on the device specified by the handle")]
558 EXTERNAL_TRIGGER_NOT_SUPPORTED = 523,
559 #[error("The condition parameter is a null pointer")]
560 NO_TRIGGER_CONDITIONS_SET = 524,
561 #[error(
562 "The number of trigger channel properties it outside the allowed range (is less than zero)"
563 )]
564 NO_OF_CHANNEL_TRIGGER_PROPERTIES_OUT_OF_RANGE = 525,
565 #[error("A probe has been plugged into a channel, but can not be identified correctly")]
566 PROBE_COMPONENT_ERROR = 526,
567 #[error("The requested channel for ETS triggering is not supported")]
568 INVALID_TRIGGER_CHANNEL_FOR_ETS = 528,
569 #[error("The device variant is not supported by this current driver")]
570 INVALID_VARIANT = 4096,
571 #[error("The actual memory module does not match the expected memory module")]
572 MEMORY_MODULE_ERROR = 4097,
573 #[error("A null pointer has been passed in the trigger function or one of the parameters is out of range"
574 )]
575 PULSE_WIDTH_QUALIFIER_LOWER_UPPER_CONFILCT = 8192,
576 #[error("The pulse width qualifier type is not one of the listed options")]
577 PULSE_WIDTH_QUALIFIER_TYPE = 8193,
578 #[error("The pulse width qualifier direction is not one of the listed options")]
579 PULSE_WIDTH_QUALIFIER_DIRECTION = 8194,
580 #[error("The threshold range is not one of the listed options")]
581 THRESHOLD_MODE_OUT_OF_RANGE = 8195,
582 #[error("The trigger direction and pulse width option conflict with each other")]
583 TRIGGER_AND_PULSEWIDTH_DIRECTION_IN_CONFLICT = 8196,
584 #[error("The thresholds upper limits and thresholds lower limits conflict with each other")]
585 THRESHOLD_UPPER_LOWER_MISMATCH = 8197,
586 #[error("The pulse width lower count is out of range")]
587 PULSE_WIDTH_LOWER_OUT_OF_RANGE = 8198,
588 #[error("The pulse width upper count is out of range")]
589 PULSE_WIDTH_UPPER_OUT_OF_RANGE = 8199,
590 #[error("The devices front panel has caused an error")]
591 FRONT_PANEL_ERROR = 8200,
592 #[error("The actual and expected mode of the front panel do not match")]
593 FRONT_PANEL_MODE = 8203,
594 #[error("A front panel feature is not available or failed to configure")]
595 FRONT_PANEL_FEATURE = 8204,
596 #[error("When setting the pulse width conditions either the pointer is null or the number of conditions is set to zero"
597 )]
598 NO_PULSE_WIDTH_CONDITIONS_SET = 8205,
599 #[error("a trigger condition exists for a port, but the port has not been enabled")]
600 TRIGGER_PORT_NOT_ENABLED = 8206,
601 #[error(
602 "a trigger condition exists for a port, but no digital channel directions have been set"
603 )]
604 DIGITAL_DIRECTION_NOT_SET = 8207,
605 #[error("")]
606 I2C_DEVICE_INVALID_READ_COMMAND = 8208,
607 #[error("")]
608 I2C_DEVICE_INVALID_RESPONSE = 8209,
609 #[error("")]
610 I2C_DEVICE_INVALID_WRITE_COMMAND = 8210,
611 #[error("")]
612 I2C_DEVICE_ARGUMENT_OUT_OF_RANGE = 8211,
613 #[error("The actual and expected mode do not match")]
614 I2C_DEVICE_MODE = 8212,
615 #[error("While trying to configure the device, set up failed")]
616 I2C_DEVICE_SETUP_FAILED = 8213,
617 #[error("A feature is not available or failed to configure")]
618 I2C_DEVICE_FEATURE = 8214,
619 #[error("he device did not pass the validation checks")]
620 I2C_DEVICE_VALIDATION_FAILED = 8215,
621 #[error("")]
622 INTERNAL_HEADER_ERROR = 8216,
623 #[error("The number of MSO's edge transitions being set is not supported by this device (RISING, FALLING, or RISING_OR_FALLING)"
624 )]
625 MSO_TOO_MANY_EDGE_TRANSITIONS_WHEN_USING_PULSE_WIDTH = 12288,
626 #[error("A probe LED position requested is not one of the available probe positions in the ProbeLedPosition enum"
627 )]
628 INVALID_PROBE_LED_POSITION = 12289,
629 #[error("The LED position is not supported by the selected variant")]
630 PROBE_LED_POSITION_NOT_SUPPORTED = 12290,
631 #[error(
632 "A channel has more than one of the same LED position in the ProbeChannelLedSetting struct"
633 )]
634 DUPLICATE_PROBE_CHANNEL_LED_POSITION = 12291,
635 #[error("Setting the probes LED has failed")]
636 PROBE_LED_FAILURE = 12292,
637 #[error("Probe is not supported by the selected variant")]
638 PROBE_NOT_SUPPORTED_BY_THIS_DEVICE = 12293,
639 #[error("The probe name is not in the list of enPicoConnectProbe enums")]
640 INVALID_PROBE_NAME = 12294,
641 #[error("The number of colour settings are zero or a null pointer passed to the function")]
642 NO_PROBE_COLOUR_SETTINGS = 12295,
643 #[error("Channel has no probe connected to it")]
644 NO_PROBE_CONNECTED_ON_REQUESTED_CHANNEL = 12296,
645 #[error("Connected probe does not require calibration")]
646 PROBE_DOES_NOT_REQUIRE_CALIBRATION = 12297,
647 #[error("Connected probe could not be calibrated - hardware fault is a possible cause")]
648 PROBE_CALIBRATION_FAILED = 12298,
649 #[error("A probe has been connected, but the version is not recognised")]
650 PROBE_VERSION_ERROR = 12299,
651 #[error("The requested trigger time is to long for the selected variant")]
652 AUTO_TRIGGER_TIME_TOO_LONG = 16384,
653 #[error("The MSO pod did not pass the validation checks")]
654 MSO_POD_VALIDATION_FAILED = 20480,
655 #[error("No MSO pod found on the requested digital port")]
656 NO_MSO_POD_CONNECTED = 20481,
657 #[error("the digital port enum value is not in the enPicoDigitalPortHysteresis declaration")]
658 DIGITAL_PORT_HYSTERESIS_OUT_OF_RANGE = 20482,
659 #[error("")]
660 MSO_POD_FAILED_UNIT = 20483,
661 #[error("The time stamp per waveform segment has been reset")]
662 DEVICE_TIME_STAMP_RESET = 16_777_216,
663 #[error("When requesting the TriggerTimeOffset the trigger time has not been set")]
664 TRIGGER_TIME_NOT_REQUESTED = 33_554_433,
665 #[error("Trigger time buffer not set")]
666 TRIGGER_TIME_BUFFER_NOT_SET = 33_554_434,
667 #[error("The trigger time failed to be calculated")]
668 TRIGGER_TIME_FAILED_TO_CALCULATE = 33_554_436,
669 #[error("The trigger time stamp was not requested")]
670 TRIGGER_TIME_STAMP_NOT_REQUESTED = 33_554_688,
671 #[error("Attempted to set up the signal generator with an inconsistent configuration")]
672 SIGGEN_SETTINGS_MISMATCH = 50_331_664,
673 #[error("The signal generator has been partially reconfigured and the new settings must be applied before it can be paused or restarted"
674 )]
675 SIGGEN_SETTINGS_CHANGED_CALL_APPLY = 50_331_665,
676 #[error("")]
677 SIGGEN_WAVETYPE_NOT_SUPPORTED = 50_331_666,
678 #[error("")]
679 SIGGEN_TRIGGERTYPE_NOT_SUPPORTED = 50_331_667,
680 #[error("")]
681 SIGGEN_TRIGGERSOURCE_NOT_SUPPORTED = 50_331_668,
682 #[error("")]
683 SIGGEN_FILTER_STATE_NOT_SUPPORTED = 50_331_669,
684 #[error("")]
685 SIGGEN_NULL_PARAMETER = 50_331_680,
686 #[error("")]
687 SIGGEN_EMPTY_BUFFER_SUPPLIED = 50_331_681,
688 #[error("")]
689 SIGGEN_RANGE_NOT_SUPPLIED = 50_331_682,
690 #[error("")]
691 SIGGEN_BUFFER_NOT_SUPPLIED = 50_331_683,
692 #[error("")]
693 SIGGEN_FREQUENCY_NOT_SUPPLIED = 50_331_684,
694 #[error("")]
695 SIGGEN_SWEEP_INFO_NOT_SUPPLIED = 50_331_685,
696 #[error("")]
697 SIGGEN_TRIGGER_INFO_NOT_SUPPLIED = 50_331_686,
698 #[error("")]
699 SIGGEN_CLOCK_FREQ_NOT_SUPPLIED = 50_331_687,
700 #[error("")]
701 SIGGEN_TOO_MANY_SAMPLES = 50_331_696,
702 #[error("")]
703 SIGGEN_DUTYCYCLE_OUT_OF_RANGE = 50_331_697,
704 #[error("")]
705 SIGGEN_CYCLES_OUT_OF_RANGE = 50_331_698,
706 #[error("")]
707 SIGGEN_PRESCALE_OUT_OF_RANGE = 50_331_699,
708 #[error("")]
709 SIGGEN_SWEEPTYPE_INVALID = 50_331_700,
710 #[error("")]
711 SIGGEN_SWEEP_WAVETYPE_MISMATCH = 50_331_701,
712 #[error("")]
713 SIGGEN_INVALID_SWEEP_PARAMETERS = 50_331_702,
714 #[error("")]
715 SIGGEN_SWEEP_PRESCALE_NOT_SUPPORTED = 50_331_703,
716 #[error("")]
717 AWG_OVER_VOLTAGE_RANGE = 50_331_704,
718 #[error("")]
719 NOT_LOCKED_TO_REFERENCE_FREQUENCY = 50_331_705,
720 #[error("udev rules are incorrectly configured. The user does not have read/write permissions on the device's file descriptor"
721 )]
722 PERMISSIONS_ERROR = 50_331_712,
723 #[error("")]
724 PORTS_WITHOUT_ANALOGUE_CHANNELS_ONLY_ALLOWED_IN_8BIT_RESOLUTION = 50_335_744,
725 #[error("")]
726 ANALOGUE_FRONTEND_MISSING = 50_343_937,
727 #[error("")]
728 FRONT_PANEL_MISSING = 50_343_938,
729 #[error("")]
730 ANALOGUE_FRONTEND_AND_FRONT_PANEL_MISSING = 50_343_939,
731 #[error("")]
732 FIRMWARE_UPDATE_REQUIRED_TO_USE_DEVICE_WITH_THIS_DRIVER = 50_348_032,
733 #[error("")]
734 UPDATE_REQUIRED_NULL = 50_348_033,
735 #[error("")]
736 FIRMWARE_UP_TO_DATE = 50_348_034,
737 #[error("")]
738 FLASH_FAIL = 50_348_035,
739 #[error("")]
740 INTERNAL_ERROR_FIRMWARE_LENGTH_INVALID = 50_348_036,
741 #[error("")]
742 INTERNAL_ERROR_FIRMWARE_NULL = 50_348_037,
743 #[error("")]
744 FIRMWARE_FAILED_TO_BE_CHANGED = 50_348_038,
745 #[error("")]
746 FIRMWARE_FAILED_TO_RELOAD = 50_348_039,
747 #[error("")]
748 FIRMWARE_FAILED_TO_BE_UPDATE = 50_348_040,
749 #[error("")]
750 FIRMWARE_VERSION_OUT_OF_RANGE = 50_348_041,
751 #[error("")]
752 FRONTPANEL_FIRMWARE_UPDATE_REQUIRED_TO_USE_DEVICE_WITH_THIS_DRIVER = 50_348_042,
753 #[error("")]
754 NO_APPS_AVAILABLE = 50_364_416,
755 #[error("")]
756 UNSUPPORTED_APP = 50_364_417,
757 #[error("The adc was powered down when trying to capture data")]
758 ADC_POWERED_DOWN = 50_339_840,
759 #[error("An internal error has occurred and a watchdog timer has been called")]
760 WATCHDOGTIMER = 268_435_456,
761 #[error("The picoipp library has not been found")]
762 IPP_NOT_FOUND = 268_435_457,
763 #[error("A function in the picoipp does not exist")]
764 IPP_NO_FUNCTION = 268_435_458,
765 #[error("The Pico IPP call has failed")]
766 IPP_ERROR = 268_435_459,
767 #[error("Shadow calibration is not available on this device")]
768 SHADOW_CAL_NOT_AVAILABLE = 268_435_460,
769 #[error("Shadow calibration is currently disabled")]
770 SHADOW_CAL_DISABLED = 268_435_461,
771 #[error("Shadow calibration error has occurred")]
772 SHADOW_CAL_ERROR = 268_435_462,
773 #[error("The shadow calibration is corrupt")]
774 SHADOW_CAL_CORRUPT = 268_435_463,
775 #[error("The memory on board the device has overflowed")]
776 DEVICE_MEMORY_OVERFLOW = 268_435_464,
777 #[error("The device Adc test failed")]
778 ADC_TEST_FAILURE = 268_435_472,
779 #[error("")]
780 RESERVED_1 = 285_212_672,
781 #[error("")]
782 SOURCE_NOT_READY = 536_870_912,
783 #[error("")]
784 SOURCE_INVALID_BAUD_RATE = 536_870_913,
785 #[error("")]
786 SOURCE_NOT_OPENED_FOR_WRITE = 536_870_914,
787 #[error("")]
788 SOURCE_FAILED_TO_WRITE_DEVICE = 536_870_915,
789 #[error("")]
790 SOURCE_EEPROM_FAIL = 536_870_916,
791 #[error("")]
792 SOURCE_EEPROM_NOT_PRESENT = 536_870_917,
793 #[error("")]
794 SOURCE_EEPROM_NOT_PROGRAMMED = 536_870_918,
795 #[error("")]
796 SOURCE_LIST_NOT_READY = 536_870_919,
797 #[error("")]
798 SOURCE_FTD2XX_NOT_FOUND = 536_870_920,
799 #[error("")]
800 SOURCE_FTD2XX_NO_FUNCTION = 536_870_921,
801}
802
803impl PicoStatus {
804 pub fn is_ok(&self) -> bool {
805 matches!(self, PicoStatus::OK)
806 }
807}
808
809impl From<PicoStatus> for u32 {
810 fn from(value: PicoStatus) -> Self {
811 num_traits::ToPrimitive::to_u32(&value).expect("Non-valid status code")
812 }
813}
814
815impl From<u32> for PicoStatus {
816 fn from(value: u32) -> Self {
817 num_traits::FromPrimitive::from_u32(value)
818 .unwrap_or_else(|| panic!("Non-valid status code {}", value))
819 }
820}
821
822impl From<i16> for PicoStatus {
823 fn from(value: i16) -> Self {
824 match value {
825 0 => PicoStatus::OPERATION_FAILED,
826 _ => PicoStatus::OK,
827 }
828 }
829}
830
831impl PicoStatus {
832 pub fn to_result<T>(self, ok_val: T, context: &str) -> PicoResult<T> {
834 match self {
835 PicoStatus::OK => Ok(ok_val),
836 x => Err(PicoError::from_status(x, context)),
837 }
838 }
839}