Spectrometer library  2.1
Simplified version of the thread-safe core
libspectr.h
Go to the documentation of this file.
1 
5 #ifndef LIBSHARED_AND_STATIC_EXPORT_H
6 #define LIBSHARED_AND_STATIC_EXPORT_H
7 
8 #ifndef AS_CORE_LIBRARY
9  #ifdef LIBSHARED_AND_STATIC_STATIC_DEFINE
10  # define LIBSHARED_AND_STATIC_EXPORT
11  # define LIBSHARED_AND_STATIC_NO_EXPORT
12  #else
13  # ifndef LIBSHARED_AND_STATIC_EXPORT
14  # ifdef spectrlib_shared_EXPORTS
15  /* We are building this library */
16  # define LIBSHARED_AND_STATIC_EXPORT __declspec(dllexport)
17  # else
18  /* We are using this library */
19  # define LIBSHARED_AND_STATIC_EXPORT __declspec(dllimport)
20  # endif
21  # endif
22 
23  # ifndef LIBSHARED_AND_STATIC_NO_EXPORT
24  # define LIBSHARED_AND_STATIC_NO_EXPORT
25  # endif
26  #endif
27 
28  #ifndef LIBSHARED_AND_STATIC_DEPRECATED
29  # define LIBSHARED_AND_STATIC_DEPRECATED __declspec(deprecated)
30  # define LIBSHARED_AND_STATIC_DEPRECATED_EXPORT LIBSHARED_AND_STATIC_EXPORT __declspec(deprecated)
31  # define LIBSHARED_AND_STATIC_DEPRECATED_NO_EXPORT LIBSHARED_AND_STATIC_NO_EXPORT __declspec(deprecated)
32  #endif
33 
34  #define DEFINE_NO_DEPRECATED 0
35  #if DEFINE_NO_DEPRECATED
36  # define LIBSHARED_AND_STATIC_NO_DEPRECATED
37  #endif
38 
39  #ifdef __cplusplus
40  extern "C" {
41  #endif
42 #endif
43 
44 #include <stdint.h>
45 
46 typedef unsigned char uint8_t;
47 typedef unsigned short uint16_t;
48 typedef unsigned int uint32_t;
49 
50 #ifndef DEVICE_INFO
51 #define DEVICE_INFO
52 typedef struct DeviceInfo_t{
53  char* serialNumber;
54  struct DeviceInfo_t *next;
55 } DeviceInfo_t;
56 #endif
57 
58 
59 #ifndef AS_CORE_LIBRARY
60 LIBSHARED_AND_STATIC_EXPORT
61 #endif
62 
76 int disconnectDeviceContext(uintptr_t* deviceContextPtr);
77 
78 
79 #ifndef AS_CORE_LIBRARY
80 LIBSHARED_AND_STATIC_EXPORT
81 #endif
82 
103 int connectToDeviceBySerial(const char * const serialNumber, uintptr_t* deviceContextPtr);
104 
105 #ifndef AS_CORE_LIBRARY
106 LIBSHARED_AND_STATIC_EXPORT
107 #endif
108 
130 int connectToDeviceByIndex(unsigned int index, uintptr_t *deviceContextPtr);
131 /* Deprecated - left for internal use only
132 LIBSHARED_AND_STATIC_EXPORT void disconnectDevice();
133 */
134 
135 #ifndef AS_CORE_LIBRARY
136 LIBSHARED_AND_STATIC_EXPORT
137 #endif
138 
139 uint32_t getDevicesCount();
140 
141 #ifndef AS_CORE_LIBRARY
142 LIBSHARED_AND_STATIC_EXPORT
143 #endif
144 
154 
155 #ifndef AS_CORE_LIBRARY
156 LIBSHARED_AND_STATIC_EXPORT
157 #endif
158 
159 void clearDevicesInfo(DeviceInfo_t *devices);
160 
161 #ifndef AS_CORE_LIBRARY
162 LIBSHARED_AND_STATIC_EXPORT
163 #endif
164 
224 int setFrameFormat(uint16_t numOfStartElement, uint16_t numOfEndElement, uint8_t reductionMode, uint16_t *numOfPixelsInFrame, uintptr_t *deviceContextPtr);
225 
226 #ifndef AS_CORE_LIBRARY
227 LIBSHARED_AND_STATIC_EXPORT
228 #endif
229 
263 int setExposure(uint32_t timeOfExposure, uint8_t force, uintptr_t *deviceContextPtr);
264 
265 #ifndef AS_CORE_LIBRARY
266 LIBSHARED_AND_STATIC_EXPORT
267 #endif
268 
315 int setAcquisitionParameters(uint16_t numOfScans, uint16_t numOfBlankScans, uint8_t scanMode, uint32_t timeOfExposure, uintptr_t *deviceContextPtr);
316 
317 #ifndef AS_CORE_LIBRARY
318 LIBSHARED_AND_STATIC_EXPORT
319 #endif
320 
339 int setMultipleParameters(uint16_t numOfScans, uint16_t numOfBlankScans, uint8_t scanMode, uint32_t timeOfExposure, uint8_t enableMode, uint8_t signalFrontMode, uintptr_t *deviceContextPtr);
340 
341 #ifndef AS_CORE_LIBRARY
342 LIBSHARED_AND_STATIC_EXPORT
343 #endif
344 
371 int setExternalTrigger(uint8_t enableMode, uint8_t signalFrontMode, uintptr_t *deviceContextPtr);
372 
373 #ifndef AS_CORE_LIBRARY
374 LIBSHARED_AND_STATIC_EXPORT
375 #endif
376 
415 int setOpticalTrigger(uint8_t enableMode, uint16_t pixel, uint16_t threshold, uintptr_t *deviceContextPtr);
416 
417 #ifndef AS_CORE_LIBRARY
418 LIBSHARED_AND_STATIC_EXPORT
419 #endif
420 
436 int triggerAcquisition(uintptr_t *deviceContextPtr);
437 
438 #ifndef AS_CORE_LIBRARY
439 LIBSHARED_AND_STATIC_EXPORT
440 #endif
441 
469 int getStatus(uint8_t *statusFlags, uint16_t *framesInMemory, uintptr_t *deviceContextPtr);
470 
471 #ifndef AS_CORE_LIBRARY
472 LIBSHARED_AND_STATIC_EXPORT
473 #endif
474 
491 int getAcquisitionParameters(uint16_t* numOfScans, uint16_t* numOfBlankScans, uint8_t *scanMode, uint32_t* timeOfExposure, uintptr_t *deviceContextPtr);
492 
493 #ifndef AS_CORE_LIBRARY
494 LIBSHARED_AND_STATIC_EXPORT
495 #endif
496 
525 int getFrameFormat(uint16_t *numOfStartElement, uint16_t *numOfEndElement, uint8_t *reductionMode, uint16_t *numOfPixelsInFrame, uintptr_t *deviceContextPtr);
526 
527 #ifndef AS_CORE_LIBRARY
528 LIBSHARED_AND_STATIC_EXPORT
529 #endif
530 
569 int getFrame(uint16_t *framePixelsBuffer, uint16_t numOfFrame, uintptr_t *deviceContextPtr);
570 
571 #ifndef AS_CORE_LIBRARY
572 LIBSHARED_AND_STATIC_EXPORT
573 #endif
574 
594 int clearMemory(uintptr_t *deviceContextPtr);
595 
596 #ifndef AS_CORE_LIBRARY
597 LIBSHARED_AND_STATIC_EXPORT
598 #endif
599 
619 int eraseFlash(uintptr_t *deviceContextPtr);
620 
621 #ifndef AS_CORE_LIBRARY
622 LIBSHARED_AND_STATIC_EXPORT
623 #endif
624 
662 int readFlash(uint8_t *buffer, uint32_t absoluteOffset, uint32_t bytesToRead, uintptr_t *deviceContextPtr);
663 
664 #ifndef AS_CORE_LIBRARY
665 LIBSHARED_AND_STATIC_EXPORT
666 #endif
667 
708 int writeFlash(uint8_t *buffer, uint32_t absoluteOffset, uint32_t bytesToWrite, uintptr_t *deviceContextPtr);
709 
710 
711 #ifndef AS_CORE_LIBRARY
712 LIBSHARED_AND_STATIC_EXPORT
713 #endif
714 
737 int resetDevice(uintptr_t *deviceContextPtr);
738 
739 #ifndef AS_CORE_LIBRARY
740 LIBSHARED_AND_STATIC_EXPORT
741 #endif
742 
757 int detachDevice(uintptr_t *deviceContextPtr);
758 
759 #ifndef SPECTROMETER_ERROR_CODES
760 #define SPECTROMETER_ERROR_CODES
761  #define OK 0
762  #define CONNECT_ERROR_WRONG_ID 500
763  #define CONNECT_ERROR_NOT_FOUND 501
764  #define CONNECT_ERROR_FAILED 502
765  #define DEVICE_NOT_INITIALIZED 503
766  #define WRITING_PROCESS_FAILED 504
767  #define READING_PROCESS_FAILED 505
768  #define WRONG_ANSWER 506
769  #define GET_FRAME_REMAINING_PACKETS_ERROR 507
770  #define NUM_OF_PACKETS_IN_FRAME_ERROR 508
771  #define INPUT_PARAMETER_NOT_INITIALIZED 509
772  #define READ_FLASH_REMAINING_PACKETS_ERROR 510
773 
774  #define CONNECT_ERROR_WRONG_SERIAL_NUMBER 516
775 
776  #define NO_DEVICE_CONTEXT_ERROR 585
777 #endif
778 
779 #ifndef AS_CORE_LIBRARY
780 
781  #ifdef __cplusplus
782  }
783  #endif
784 
785  #endif
786 #endif
LIBSHARED_AND_STATIC_EXPORT int disconnectDeviceContext(uintptr_t *deviceContextPtr)
Free a device handle.
Definition: libspectr.c:33
LIBSHARED_AND_STATIC_EXPORT uint32_t getDevicesCount()
Returns the number of the connected devices.
Definition: libspectr.c:163
LIBSHARED_AND_STATIC_EXPORT int getFrame(uint16_t *framePixelsBuffer, uint16_t numOfFrame, uintptr_t *deviceContextPtr)
Gets frame.
Definition: libspectr.c:525
LIBSHARED_AND_STATIC_EXPORT int eraseFlash(uintptr_t *deviceContextPtr)
Erases user flash memory.
Definition: libspectr.c:649
LIBSHARED_AND_STATIC_EXPORT int getAcquisitionParameters(uint16_t *numOfScans, uint16_t *numOfBlankScans, uint8_t *scanMode, uint32_t *timeOfExposure, uintptr_t *deviceContextPtr)
Returns the same values as set by setAcquisitionParameters.
Definition: libspectr.c:448
LIBSHARED_AND_STATIC_EXPORT int setFrameFormat(uint16_t numOfStartElement, uint16_t numOfEndElement, uint8_t reductionMode, uint16_t *numOfPixelsInFrame, uintptr_t *deviceContextPtr)
Sets frame parameters Note: this function clears the memory and stops the current acquisition...
Definition: libspectr.c:224
LIBSHARED_AND_STATIC_EXPORT int setExposure(uint32_t timeOfExposure, uint8_t force, uintptr_t *deviceContextPtr)
Sets exposure parameter.
Definition: libspectr.c:262
LIBSHARED_AND_STATIC_EXPORT int triggerAcquisition(uintptr_t *deviceContextPtr)
Start acquisition by software.
Definition: libspectr.c:404
LIBSHARED_AND_STATIC_EXPORT int clearMemory(uintptr_t *deviceContextPtr)
Clears memory.
Definition: libspectr.c:627
LIBSHARED_AND_STATIC_EXPORT int connectToDeviceByIndex(unsigned int index, uintptr_t *deviceContextPtr)
Connects to the required device by index This function or its analog connectToSingleDeviceBySerial sh...
Definition: libspectr.c:100
LIBSHARED_AND_STATIC_EXPORT int connectToDeviceBySerial(const char *const serialNumber, uintptr_t *deviceContextPtr)
Finds the requested device by the provided serial number and connects to it. This function or its ana...
Definition: libspectr.c:53
LIBSHARED_AND_STATIC_EXPORT int setExternalTrigger(uint8_t enableMode, uint8_t signalFrontMode, uintptr_t *deviceContextPtr)
Sets the external acquisition trigger.
Definition: libspectr.c:353
LIBSHARED_AND_STATIC_EXPORT int getFrameFormat(uint16_t *numOfStartElement, uint16_t *numOfEndElement, uint8_t *reductionMode, uint16_t *numOfPixelsInFrame, uintptr_t *deviceContextPtr)
Returns the same values as set by setFrameFormat.
Definition: libspectr.c:484
LIBSHARED_AND_STATIC_EXPORT int setMultipleParameters(uint16_t numOfScans, uint16_t numOfBlankScans, uint8_t scanMode, uint32_t timeOfExposure, uint8_t enableMode, uint8_t signalFrontMode, uintptr_t *deviceContextPtr)
Sets multiple parameters - combination of setAcquisitionParametersOnSingleDevice and setExternalTrigg...
Definition: libspectr.c:320
LIBSHARED_AND_STATIC_EXPORT int readFlash(uint8_t *buffer, uint32_t absoluteOffset, uint32_t bytesToRead, uintptr_t *deviceContextPtr)
Reads from user flash memory Reads bytesToRead from user flash memory starting at offset and copies t...
Definition: libspectr.c:671
LIBSHARED_AND_STATIC_EXPORT int getStatus(uint8_t *statusFlags, uint16_t *framesInMemory, uintptr_t *deviceContextPtr)
Gets the device status.
Definition: libspectr.c:420
LIBSHARED_AND_STATIC_EXPORT int detachDevice(uintptr_t *deviceContextPtr)
Disconnects the device The device will be disconnected from USB, and any interaction with it will not...
Definition: libspectr.c:858
LIBSHARED_AND_STATIC_EXPORT int resetDevice(uintptr_t *deviceContextPtr)
Resets all the device parameters to their default values and clears the memory.
Definition: libspectr.c:842
LIBSHARED_AND_STATIC_EXPORT DeviceInfo_t * getDevicesInfo()
Obtains the list of all connected devices. Run clearDevicesInfo() with the result of this function to...
Definition: libspectr.c:178
LIBSHARED_AND_STATIC_EXPORT void clearDevicesInfo(DeviceInfo_t *devices)
Clears the list of all connected devices obtained by getDevicesInfo() function.
Definition: libspectr.c:218
LIBSHARED_AND_STATIC_EXPORT int setOpticalTrigger(uint8_t enableMode, uint16_t pixel, uint16_t threshold, uintptr_t *deviceContextPtr)
Sets the optical atrigger.
Definition: libspectr.c:377
LIBSHARED_AND_STATIC_EXPORT int setAcquisitionParameters(uint16_t numOfScans, uint16_t numOfBlankScans, uint8_t scanMode, uint32_t timeOfExposure, uintptr_t *deviceContextPtr)
Sets acquisition parameters.
Definition: libspectr.c:289
LIBSHARED_AND_STATIC_EXPORT int writeFlash(uint8_t *buffer, uint32_t absoluteOffset, uint32_t bytesToWrite, uintptr_t *deviceContextPtr)
Writes bytesToWrite bytes from the buffer to the user flash memory starting at offset.
Definition: libspectr.c:771