├── .gitignore ├── README.md ├── include ├── nScopeAPI.h ├── nScopeAPI_analogInputs.h ├── nScopeAPI_analogOutputs.h ├── nScopeAPI_defs.h ├── nScopeAPI_pulseGenerators.h ├── nScopeAPI_requests.h ├── nScopeAPI_sampleTiming.h └── nScopeAPI_trigger.h ├── lib ├── README.md ├── linux_amd64 │ └── libnscopeapi.so ├── linux_arm64 │ └── libnscopeapi.so ├── linux_armhf │ └── libnscopeapi.so ├── linux_i386 │ └── libnscopeapi.so ├── mac │ └── libnscopeapi.dylib ├── win32 │ ├── libnscopeapi.dll │ └── libnscopeapi.lib └── win64 │ ├── libnscopeapi.dll │ └── libnscopeapi.lib ├── matlab ├── nScopeAPI.cpp ├── nScopeAPI.mexa64 ├── nScopeAPI.mexmaci64 ├── nScopeAPI.mexw32 ├── nScopeAPI.mexw64 ├── nScopeAPI_MATLAB.zip ├── nScopeAPI_MATLABv0.6.zip ├── nScopeReadAllChannels.m ├── nScopeReadCh1.m ├── nScopeTurnOnA1.m ├── nScopeTurnOnA2.m ├── nScopeTurnOnP1.m └── nScopeTurnOnP2.m ├── nscopetest.cpp └── python ├── MANIFEST.in ├── README.md ├── nscopeapi ├── __init__.py ├── analogInputs.py ├── analogOutputs.py ├── lib │ ├── linux_amd64 │ │ └── libnscopeapi.so │ ├── linux_arm64 │ │ └── libnscopeapi.so │ ├── linux_armhf │ │ └── libnscopeapi.so │ ├── linux_i386 │ │ └── libnscopeapi.so │ ├── mac │ │ └── libnscopeapi.dylib │ ├── win32 │ │ ├── libnscopeapi.dll │ │ └── libnscopeapi.lib │ └── win64 │ │ ├── libnscopeapi.dll │ │ └── libnscopeapi.lib ├── nScopeDefs.py ├── pulseGenerators.py ├── requests.py ├── sampleTiming.py └── trigger.py ├── setup.py └── testConnection.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nScopeAPI 2 | 3 | nScopeAPI is used for communicating with nScope hardware. 4 | 5 | This API and docs are in development at [github](http://github.com/nLabs-nScope/nScopeAPI). 6 | -------------------------------------------------------------------------------- /include/nScopeAPI.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file nScopeAPI.h 14 | 15 | @brief Main header file that includes the entire API 16 | */ 17 | 18 | #ifndef NSCOPEAPI_H__ 19 | #define NSCOPEAPI_H__ 20 | 21 | 22 | #include "nScopeAPI_defs.h" 23 | #include "nScopeAPI_requests.h" 24 | #include "nScopeAPI_analogInputs.h" 25 | #include "nScopeAPI_sampleTiming.h" 26 | #include "nScopeAPI_trigger.h" 27 | #include "nScopeAPI_analogOutputs.h" 28 | #include "nScopeAPI_pulseGenerators.h" 29 | #include "stdbool.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | 36 | 37 | /** @brief Open a connected nScope device and initialize it. 38 | 39 | Looks for a nScope device, connects to it, then runs nScope_initialize() 40 | Stores the resulting #ScopeHandle object in *nScope_p 41 | 42 | @returns 43 | #ErrorType 44 | @param [in] powerOn 45 | true turns nScope on when first opened, false leaves nScope in 46 | its current state 47 | @param [out] nScope_p 48 | a pointer to a #ScopeHandle object 49 | */ 50 | NSCOPE_API ErrorType nScope_open(bool powerOn, ScopeHandle* nScope_p); 51 | 52 | /** @brief Close and clean a connected nScope device. 53 | 54 | @returns 55 | #ErrorType 56 | @param [in] nScope_p 57 | pointer to a #ScopeHandle object 58 | */ 59 | NSCOPE_API ErrorType nScope_close(ScopeHandle* nScope_p); 60 | 61 | /** @brief Clean up an nScope device. 62 | 63 | This function cleans the memory that was used for an nScope object. This function 64 | is called by nScope_close(), so it is only needed when nScope is disconnected for an 65 | unknown reason. 66 | 67 | @returns 68 | #ErrorType 69 | @param [in] nScope_p 70 | pointer to a #ScopeHandle object 71 | */ 72 | NSCOPE_API ErrorType nScope_clean(ScopeHandle* nScope_p); 73 | 74 | /** @brief Initialize an nScope with the default configuration. 75 | 76 | This function is called by nScope_open(), so it's only needed to reset 77 | the configuration if it ever reaches an unknown state. 78 | 79 | The default configuration is: 80 | 81 | @returns 82 | #ErrorType 83 | @param [in] nScope 84 | nScope handle 85 | */ 86 | NSCOPE_API ErrorType nScope_initialize(ScopeHandle nScope); 87 | 88 | /** @brief Read how much power is being used by nScope 89 | 90 | @returns 91 | #ErrorType 92 | @param [in] nScope 93 | nScope handle 94 | @param [out] powerUsage 95 | pointer to a variable to store the amount of power being 96 | used by nScope in watts 97 | */ 98 | NSCOPE_API ErrorType nScope_get_power_usage(ScopeHandle nScope, double *powerUsage); 99 | 100 | /** @brief Read the #PowerState of the nScope 101 | 102 | @returns 103 | #ErrorType 104 | @param [in] nScope 105 | nScope handle 106 | @param [out] powerState 107 | pointer to a variable to store nScope's current power state 108 | */ 109 | NSCOPE_API ErrorType nScope_get_power_state(ScopeHandle nScope, PowerState* powerState); 110 | 111 | /** @brief find the firmware loader 112 | 113 | @returns 114 | #ErrorType 115 | */ 116 | NSCOPE_API ErrorType nScope_find_firmware_loader(); 117 | 118 | /** @brief write the firmware to the loader 119 | 120 | @returns 121 | #ErrorType 122 | */ 123 | NSCOPE_API ErrorType nScope_write_to_loader(); 124 | 125 | /** @brief load the nScope with current firmware 126 | 127 | calls both nScope_find_firmware_loader() and nScope_write_to_loader() 128 | 129 | @returns 130 | #ErrorType 131 | */ 132 | NSCOPE_API ErrorType nScope_load_firmware(); 133 | 134 | /** @brief check the version of this API 135 | 136 | @returns 137 | #ErrorType 138 | @param [out] apiVersion 139 | pointer to a variable to store the current API version 140 | */ 141 | NSCOPE_API ErrorType nScope_check_API_version(double* apiVersion); 142 | 143 | /** @brief check the version of the connected firmware 144 | 145 | @returns 146 | #ErrorType 147 | @param [out] fwVersion 148 | pointer to a variable to store the current firmware version 149 | */ 150 | NSCOPE_API ErrorType nScope_check_FW_version(double* fwVersion); 151 | 152 | /** @brief check the build number of this API 153 | 154 | @returns 155 | #ErrorType 156 | @param [out] apiVersion 157 | pointer to a variable to store the current API build 158 | */ 159 | NSCOPE_API ErrorType nScope_check_API_build(int* buildNo); 160 | 161 | #ifdef __cplusplus 162 | } 163 | #endif 164 | 165 | #endif 166 | -------------------------------------------------------------------------------- /include/nScopeAPI_analogInputs.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file 14 | 15 | @brief contains function headers for controlling the nScope analog inputs 16 | */ 17 | 18 | #ifndef NSCOPEAPI_ANALOGINPUTS_H__ 19 | #define NSCOPEAPI_ANALOGINPUTS_H__ 20 | 21 | 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** @brief Set the channel states (on/off) for all channels 28 | 29 | A true state means the channel is on and will sample if a request is sent 30 | 31 | @returns 32 | nScope #ErrorType 33 | @param [in] nScope 34 | nScope handle 35 | @param [in] ch1on 36 | true: turn channel 1 on, false: turn it off 37 | @param [in] ch2on 38 | true: turn channel 2 on, false: turn it off 39 | @param [in] ch3on 40 | true: turn channel 3 on, false: turn it off 41 | @param [in] ch4on 42 | true: turn channel 4 on, false: turn it off 43 | */ 44 | NSCOPE_API ErrorType nScope_set_channels_on(ScopeHandle nScope, bool ch1on, bool ch2on, bool ch3on, bool ch4on); 45 | 46 | /** @brief Get the channel states (on/off) for all channels 47 | 48 | A true state means the channel is on and will sample if a request is sent 49 | 50 | @returns 51 | nScope #ErrorType 52 | @param [in] nScope 53 | pointer to nScope handle 54 | @param [out] channelsOn 55 | pointer to an array of booleans for retreiving the on state for each channel 56 | */ 57 | NSCOPE_API ErrorType nScope_get_channels_on(ScopeHandle nScope, bool* channelsOn); 58 | 59 | /** @brief Get the number of channels currently on 60 | 61 | @returns 62 | nScope #ErrorType 63 | @param [in] nScope 64 | #ScopeHandle 65 | @param [out] numChannelsOn 66 | pointer to a variable for retreiving the number of channels on 67 | */ 68 | NSCOPE_API ErrorType nScope_get_num_channels_on(ScopeHandle nScope, int* numChannelsOn); 69 | 70 | /** @brief Set a channel state on or off 71 | 72 | A true state means the channel is on and will sample if a request is sent 73 | 74 | @returns 75 | nScope #ErrorType 76 | @param[in] nScope 77 | #ScopeHandle object 78 | @param[in] ch 79 | channel number to set on or off 80 | @param[in] channelOn 81 | true: turn the channel on, false: turn the channel off 82 | */ 83 | NSCOPE_API ErrorType nScope_set_ChX_on(ScopeHandle nScope, int ch, bool channelOn); 84 | 85 | /** @brief Get the on/off state of a given channel 86 | 87 | @returns 88 | nScope #ErrorType 89 | @param[in] nScope 90 | #ScopeHandle object 91 | @param[in] ch 92 | channel number to query 93 | @param[out] channelOn 94 | pointer to bool to store whether the channel is on or off 95 | */ 96 | NSCOPE_API ErrorType nScope_get_ChX_on(ScopeHandle nScope, int ch, bool* channelOn); 97 | 98 | /** @brief Set the channel gains for all channels 99 | 100 | A gain of 1 indicates 101 | 102 | @returns 103 | nScope #ErrorType 104 | @param[in] nScope 105 | #ScopeHandle object 106 | @param[in] ch1Gain 107 | channel 1 gain 108 | @param[in] ch2Gain 109 | channel 2 gain 110 | @param[in] ch3Gain 111 | channel 3 gain 112 | @param[in] ch4Gain 113 | channel 4 gain 114 | */ 115 | NSCOPE_API ErrorType nScope_set_channel_gains(ScopeHandle nScope, double ch1Gain, double ch2Gain, double ch3Gain, double ch4Gain); 116 | 117 | /** @brief Get the channel gains for all channels 118 | 119 | @returns 120 | nScope #ErrorType 121 | @param[in] nScope 122 | #ScopeHandle object 123 | @param[out] channelGains 124 | pointer to an array of doubles for retreiving the gain for each channel 125 | */ 126 | NSCOPE_API ErrorType nScope_get_channel_gains(ScopeHandle nScope, double* channelGains); 127 | 128 | /** @brief Set a given channel's gain 129 | 130 | @returns 131 | nScope #ErrorType 132 | @param[in] nScope 133 | #ScopeHandle object 134 | @param[in] ch 135 | channel number to set on or off 136 | @param[in] channelGain 137 | the desired gain of the channel 138 | */ 139 | NSCOPE_API ErrorType nScope_set_ChX_gain(ScopeHandle nScope, int ch, double channelGain); 140 | 141 | /** @brief Get the gain of a given channel 142 | 143 | @returns 144 | nScope #ErrorType 145 | @param[in] nScope 146 | #ScopeHandle object 147 | @param[in] ch 148 | channel number to query 149 | @param[out] channelGain 150 | pointer to double to store the channel gain 151 | */ 152 | NSCOPE_API ErrorType nScope_get_ChX_gain(ScopeHandle nScope, int ch, double* channelGain); 153 | 154 | /** @brief Set the channel levels for all channels 155 | 156 | Level means: 157 | 158 | @returns 159 | nScope #ErrorType 160 | @param[in] nScope 161 | #ScopeHandle object 162 | @param[in] ch1Level 163 | channel 1 level 164 | @param[in] ch2Level 165 | channel 2 level 166 | @param[in] ch3Level 167 | channel 3 level 168 | @param[in] ch4Level 169 | channel 4 level 170 | */ 171 | NSCOPE_API ErrorType nScope_set_channel_levels(ScopeHandle nScope, double ch1Level, double ch2Level, double ch3Level, double ch4Level); 172 | 173 | /** @brief Get the channel levels for all channels 174 | 175 | @returns 176 | nScope #ErrorType 177 | @param[in] nScope 178 | #ScopeHandle object 179 | @param[out] channelLevels 180 | pointer to an array of doubles for retreiving the level for each channel 181 | */ 182 | NSCOPE_API ErrorType nScope_get_channel_levels(ScopeHandle nScope, double* channelLevels); 183 | 184 | /** @brief Set a given channel's level 185 | 186 | @returns 187 | nScope #ErrorType 188 | @param[in] nScope 189 | #ScopeHandle object 190 | @param[in] ch 191 | channel number to set on or off 192 | @param[out] channelLevel 193 | the desired level of the channel 194 | */ 195 | NSCOPE_API ErrorType nScope_set_ChX_level(ScopeHandle nScope, int ch, double channelLevel); 196 | 197 | /** @brief Get the level of a given channel 198 | 199 | @returns 200 | nScope #ErrorType 201 | @param[in] nScope 202 | #ScopeHandle object 203 | @param[in] ch 204 | channel number to query 205 | @param[out] channelLevel 206 | pointer to double to store the channel level 207 | */ 208 | NSCOPE_API ErrorType nScope_get_ChX_level(ScopeHandle nScope, int ch, double* channelLevel); 209 | 210 | 211 | #ifdef __cplusplus 212 | } 213 | #endif 214 | 215 | #endif 216 | -------------------------------------------------------------------------------- /include/nScopeAPI_analogOutputs.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2015 nLabs, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file 14 | 15 | @brief contains function headers for controlling the nScope analog outputs 16 | */ 17 | 18 | #ifndef NSCOPEAPI_ANALOGOUTPUTS_H__ 19 | #define NSCOPEAPI_ANALOGOUTPUTS_H__ 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** @brief Set the analog channel (on/off) 27 | 28 | A true state means the analog channel is on and outputing voltage 29 | A false state means the analog channel is held at ground 30 | 31 | @returns 32 | nScope #ErrorType 33 | @param [in] nScope 34 | nScope handle 35 | @param [in] aChannel 36 | the channel (1 or 2) to turn on or off 37 | @param [in] aOn 38 | true: turn the channel on, false: turn it off 39 | */ 40 | NSCOPE_API ErrorType nScope_set_AX_on(ScopeHandle nScope, int aChannel, bool aOn); 41 | 42 | /** @brief Get the analog channel (on/off) and store it in aOn 43 | 44 | A true state means the analog channel is on and outputing voltage 45 | A false state means the analog channel is held at ground 46 | 47 | @returns 48 | nScope #ErrorType 49 | @param [in] nScope 50 | nScope handle 51 | @param [in] aChannel 52 | the channel (1 or 2) to query 53 | @param [out] aOn 54 | pointer to a boolean to store the state of the analog channel 55 | */ 56 | NSCOPE_API ErrorType nScope_get_AX_on(ScopeHandle nScope, int aChannel, bool* aOn); 57 | 58 | /** @brief Set the analog channel output frequency 59 | 60 | Not all frequency values can be acheived, nScope will automatically choose the closest approximation 61 | 62 | @returns 63 | nScope #ErrorType 64 | @param [in] nScope 65 | nScope handle 66 | @param [in] aChannel 67 | the channel (1 or 2) to set 68 | @param [in] frequency 69 | desired signal frequency in hz 70 | */ 71 | NSCOPE_API ErrorType nScope_set_AX_frequency_in_hz(ScopeHandle nScope, int aChannel, double frequency); 72 | 73 | /** @brief Get the analog channel output frequency and store it in the given variable 74 | 75 | @returns 76 | nScope #ErrorType 77 | @param [in] nScope 78 | nScope handle 79 | @param [in] aChannel 80 | the channel (1 or 2) to query 81 | @param [out] frequency 82 | pointer to double to store the actual signal frequency in hz 83 | */ 84 | NSCOPE_API ErrorType nScope_get_AX_frequency_in_hz(ScopeHandle nScope, int aChannel, double* frequency); 85 | 86 | /** @brief Set the analog channel output wave type 87 | 88 | The output waves can be set to any one of the available #WaveType 89 | 90 | @returns 91 | nScope #ErrorType 92 | @param [in] nScope 93 | nScope handle 94 | @param [in] aChannel 95 | the channel (1 or 2) to set 96 | @param [in] wave 97 | the signal #WaveType 98 | */ 99 | NSCOPE_API ErrorType nScope_set_AX_wave_type(ScopeHandle nScope, int aChannel, WaveType wave); 100 | 101 | /** @brief Get the analog channel output wave type 102 | 103 | @returns 104 | nScope #ErrorType 105 | @param [in] nScope 106 | nScope handle 107 | @param [in] aChannel 108 | the channel (1 or 2) to query 109 | @param [out] wave 110 | pointer to #WaveType to store the current wave type 111 | */ 112 | NSCOPE_API ErrorType nScope_get_AX_wave_type(ScopeHandle nScope, int aChannel, WaveType* wave); 113 | 114 | /** @brief Set the analog channel unipolarity 115 | 116 | Unipolar waves range from 0 to amplitude, bipolar waves range from -amplitude to amplitude 117 | 118 | @returns 119 | nScope #ErrorType 120 | @param [in] nScope 121 | nScope handle 122 | @param [in] aChannel 123 | the channel (1 or 2) to set 124 | @param [in] isUnipolar 125 | true to set the output to be unipolar only, false to set it bipolar 126 | */ 127 | NSCOPE_API ErrorType nScope_set_AX_unipolar(ScopeHandle nScope, int aChannel, bool isUnipolar); 128 | 129 | /** @brief Get the analog channel unipolarity 130 | 131 | Unipolar waves range from 0 to amplitude, bipolar waves range from -amplitude to amplitude 132 | 133 | @returns 134 | nScope #ErrorType 135 | @param [in] nScope 136 | nScope handle 137 | @param [in] aChannel 138 | the channel (1 or 2) to query 139 | @param [out] isUnipolar 140 | true if the wave is unipolar, false if it is not 141 | */ 142 | NSCOPE_API ErrorType nScope_get_AX_unipolar(ScopeHandle nScope, int aChannel, bool* isUnipolar); 143 | 144 | /** @brief Set the analog channel amplitude 145 | 146 | Unipolar waves range from 0 to amplitude, bipolar waves range from -amplitude to amplitude 147 | 148 | Not all amplitude values can be acheived, nScope will automatically choose the closest approximation 149 | 150 | @returns 151 | nScope #ErrorType 152 | @param [in] nScope 153 | nScope handle 154 | @param [in] aChannel 155 | the channel (1 or 2) to set 156 | @param [in] amplitude 157 | desired signal amplitude in volts 158 | */ 159 | NSCOPE_API ErrorType nScope_set_AX_amplitude(ScopeHandle nScope, int aChannel, double amplitude); 160 | 161 | /** @brief Get the analog channel amplitude 162 | 163 | Retreives the actual signal amplitude and puts it into the amplitude variable 164 | 165 | @returns 166 | nScope #ErrorType 167 | @param [in] nScope 168 | nScope handle 169 | @param [in] aChannel 170 | the channel (1 or 2) to query 171 | @param [out] amplitude 172 | actual signal amplitude in volts 173 | */ 174 | NSCOPE_API ErrorType nScope_get_AX_amplitude(ScopeHandle nScope, int aChannel, double* amplitude); 175 | 176 | #ifdef __cplusplus 177 | } 178 | #endif 179 | 180 | #endif 181 | -------------------------------------------------------------------------------- /include/nScopeAPI_defs.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 9/10/2016 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file nScopeAPI_defs.h 14 | 15 | @brief header file for common definitions 16 | */ 17 | 18 | #ifndef NSCOPEAPI_DEFS_H__ 19 | #define NSCOPEAPI_DEFS_H__ 20 | 21 | #ifdef _WIN32 22 | #define NSCOPE_API_EXPORT __declspec(dllexport) 23 | #define NSCOPE_API_CALL //__declspec(dllimport) 24 | #else 25 | #define NSCOPE_API_EXPORT /**< API export macro */ 26 | #define NSCOPE_API_CALL /**< API call macro */ 27 | #endif 28 | 29 | #define NSCOPE_API NSCOPE_API_EXPORT NSCOPE_API_CALL /**< API export and call macro*/ 30 | 31 | struct scopeDev_; 32 | typedef struct scopeDev_ *ScopeHandle; /**< nScope structure handle */ 33 | 34 | struct request_; 35 | typedef struct request_ *Request; /**< nScope request handle */ 36 | 37 | /** nScope error types 38 | 39 | return type for all nScopeAPI functions 40 | 41 | */ 42 | typedef enum 43 | { 44 | /** No error was encountered */ 45 | SUCCESS = 0, 46 | /** An unknown error occurred */ 47 | UNKNOWN_ERROR = -100, 48 | /** nScope is not open, or has been disconnected unexpectedly */ 49 | NSCOPE_NOT_OPEN = -101, 50 | /** the desired channel is currently off */ 51 | NSCOPE_CHANNEL_OFF = -102, 52 | /** nScope power is off */ 53 | NSCOPE_POWER_OFF = -103, 54 | /** There is no data available */ 55 | NO_DATA_AVAILABLE = -104, 56 | /** The trigger settings are invalid */ 57 | INVALID_TRIGGER = -105, 58 | /** The request is invalid */ 59 | INVALID_REQUEST = -106, 60 | /** A communication error has occurred */ 61 | COMM_ERROR = -107, 62 | /** TODO: no clue */ 63 | INTERRUPT_STOPPED = -108, 64 | /** Firmware and API are incompatible */ 65 | FW_API_INCOMPATIBLE = -109, 66 | /** Value error: a parameter is too small */ 67 | VALUE_ERROR_TOO_SMALL = -110, 68 | /** Value error: a parameter is too large */ 69 | VALUE_ERROR_TOO_LARGE = -111, 70 | /** Value error: a parameter is out of range */ 71 | VALUE_ERROR_OUT_OF_RANGE = -112, 72 | /** Awaiting more data from the request transfer */ 73 | WAITING_FOR_DATA = -113, 74 | /** Value warning: a parameter is very small */ 75 | VALUE_WARNING_TOO_SMALL = -120, 76 | /** Value warning: a parameter is very large */ 77 | VALUE_WARNING_TOO_LARGE = -121, 78 | } ErrorType; 79 | 80 | /** Trigger edges of nScope */ 81 | typedef enum 82 | { 83 | FALLING_EDGE = 1, /**< trigger on the falling edge */ 84 | RISING_EDGE = 2, /**< trigger on the rising edge */ 85 | } TriggerEdge; 86 | 87 | /** Power state of nScope */ 88 | typedef enum 89 | { 90 | NOT_CONNECTED = -1, /**< nScope is not connected */ 91 | POWER_OFF = 0, /**< power is off */ 92 | POWER_ON = 1, /**< power is on */ 93 | SHORTED = 2, /**< a short has been detected */ 94 | OVERCURRENT = 3 /**< an overcurrent has been detected */ 95 | } PowerState; 96 | 97 | /** Wave Types of nScope */ 98 | typedef enum 99 | { 100 | SINE_WAVE = 0, /**< analog output is a sine wave */ 101 | TRIANGLE_WAVE = 1, /**< analog output is a triangle wave */ 102 | } WaveType; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /include/nScopeAPI_pulseGenerators.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file 14 | 15 | @brief contains function headers for controlling the nScope pulse outputs 16 | 17 | nScope has two pulse generators, P1 and P2, that output pulse signals from 0 to 5V. These signals 18 | are good for use with digital logic or for driving the logic of H-bridge controllers. 19 | 20 | These functions provide control over the timing characteristics of the two pulse outputs. 21 | */ 22 | 23 | #ifndef NSCOPEAPI_PULSEGNERATORS_H__ 24 | #define NSCOPEAPI_PULSEGNERATORS_H__ 25 | 26 | 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** @brief Set a pulse channel (on/off) 33 | 34 | A true state means the pulse channel is on and outputing voltage 35 | A false state means the pulse channel is held at ground 36 | 37 | @returns 38 | nScope #ErrorType 39 | @param [in] nScope 40 | nScope handle 41 | @param [in] pChannel 42 | the channel (1 or 2) to turn on or off 43 | @param [in] PXon 44 | true: turn the channel on, false: turn it off 45 | */ 46 | NSCOPE_API ErrorType nScope_set_PX_on(ScopeHandle nScope, int pChannel, bool PXon); 47 | 48 | /** @brief Get a pulse channel (on/off) 49 | 50 | @returns 51 | nScope #ErrorType 52 | @param [in] nScope 53 | nScope handle 54 | @param [in] pChannel 55 | the channel (1 or 2) to query 56 | @param [in] PXon 57 | pointer to boolean to store the on/off state of the queried channel 58 | */ 59 | NSCOPE_API ErrorType nScope_get_PX_on(ScopeHandle nScope, int pChannel, bool* PXon); 60 | 61 | /** @brief Set the pulse channels (on/off) 62 | 63 | A true state means the pulse channel is on and outputing voltage 64 | A false state means the pulse channel is held at ground 65 | 66 | @returns 67 | nScope #ErrorType 68 | @param [in] nScope 69 | nScope handle 70 | @param [out] P1on 71 | true: turn P1 on, false: turn it off 72 | @param [out] P2on 73 | true: turn P2 on, false: turn it off 74 | */ 75 | NSCOPE_API ErrorType nScope_set_P1_P2_on(ScopeHandle nScope, bool P1on, bool P2on); 76 | 77 | /** @brief Get the pulse channels (on/off) 78 | 79 | A true state means the pulse channel is on and outputing voltage 80 | A false state means the pulse channel is held at ground 81 | 82 | @returns 83 | nScope #ErrorType 84 | @param [in] nScope 85 | nScope handle 86 | @param [out] pulseGensOn 87 | pointer to boolean array to store the on/off states of the pulse channels 88 | */ 89 | NSCOPE_API ErrorType nScope_get_P1_P2_on(ScopeHandle nScope, bool* pulseGensOn); 90 | 91 | /** @brief Set a pulse channel frequency in hz 92 | 93 | Not all frequency values can be acheived, nScope will automatically choose the closest approximation 94 | 95 | @returns 96 | nScope #ErrorType 97 | @param [in] nScope 98 | nScope handle 99 | @param [in] pChannel 100 | the channel (1 or 2) to set 101 | @param [in] frequency 102 | the desired pulse frequency of the channel 103 | */ 104 | NSCOPE_API ErrorType nScope_set_PX_frequency_in_hz(ScopeHandle nScope, int pChannel, double frequency); 105 | 106 | /** @brief Get a pulse channel frequency in hz 107 | 108 | @returns 109 | nScope #ErrorType 110 | @param [in] nScope 111 | nScope handle 112 | @param [in] pChannel 113 | the channel (1 or 2) to query 114 | @param [out] frequency 115 | pointer to the actual pulse frequency of the channel 116 | */ 117 | NSCOPE_API ErrorType nScope_get_PX_frequency_in_hz(ScopeHandle nScope, int pChannel, double* frequency); 118 | 119 | /** @brief Set the pulse channel frequencies in hz 120 | 121 | Not all frequency values can be acheived, nScope will automatically choose the closest approximation 122 | 123 | @returns 124 | nScope #ErrorType 125 | @param [in] nScope 126 | nScope handle 127 | @param [in] frequency1 128 | the desired frequency of P1 129 | @param [in] frequency2 130 | the desired frequency of P2 131 | */ 132 | NSCOPE_API ErrorType nScope_set_P1_P2_frequencies_in_hz(ScopeHandle nScope, double frequency1, double frequency2); 133 | 134 | /** @brief Get the pulse channel frequencies in hz 135 | 136 | @returns 137 | nScope #ErrorType 138 | @param [in] nScope 139 | nScope handle 140 | @param [out] pulseFrequencies 141 | pointer to an array of doubles to store the actual pulse frequencies 142 | */ 143 | NSCOPE_API ErrorType nScope_get_P1_P2_frequencies_in_hz(ScopeHandle nScope, double* pulseFrequencies); 144 | 145 | /** @brief Set a pulse channel period in milliseconds 146 | 147 | The pulse period is the time between pulses on the output channel 148 | 149 | Not all pulse periods can be acheived, nScope will automatically choose the closest approximation 150 | 151 | @returns 152 | nScope #ErrorType 153 | @param [in] nScope 154 | nScope handle 155 | @param [in] pChannel 156 | the channel (1 or 2) to set 157 | @param [in] period 158 | the desired pulse period (ms) of the channel 159 | */ 160 | NSCOPE_API ErrorType nScope_set_PX_period_in_ms(ScopeHandle nScope, int pChannel, double period); 161 | 162 | /** @brief Get a pulse channel period in milliseconds 163 | 164 | The pulse period is the time between pulses on the output channel 165 | 166 | @returns 167 | nScope #ErrorType 168 | @param [in] nScope 169 | nScope handle 170 | @param [in] pChannel 171 | the channel (1 or 2) to query 172 | @param [out] period 173 | pointer to the actual pulse period (ms) of the channel 174 | */ 175 | NSCOPE_API ErrorType nScope_get_PX_period_in_ms(ScopeHandle nScope, int pChannel, double* period); 176 | 177 | /** @brief Set a pulse channel periods in milliseconds 178 | 179 | The pulse period is the time between pulses on the output channel 180 | 181 | Not all pulse periods can be acheived, nScope will automatically choose the closest approximation 182 | 183 | @returns 184 | nScope #ErrorType 185 | @param [in] nScope 186 | nScope handle 187 | @param [in] period1 188 | the desired pulse period (ms) on P1 189 | @param [in] period2 190 | the desired pulse period (ms) on P2 191 | */ 192 | NSCOPE_API ErrorType nScope_set_P1_P2_periods_in_ms(ScopeHandle nScope, double period1, double period2); 193 | 194 | /** @brief Get a pulse channel periods in milliseconds 195 | 196 | The pulse period is the time between pulses on the output channel 197 | 198 | @returns 199 | nScope #ErrorType 200 | @param [in] nScope 201 | nScope handle 202 | @param [out] pulsePeriods 203 | pointer to an array of doubles to store the actual pulse periods (ms) 204 | */ 205 | NSCOPE_API ErrorType nScope_get_P1_P2_periods_in_ms(ScopeHandle nScope, double* pulsePeriods); 206 | 207 | /** @brief Set a pulse channel period in microseconds 208 | 209 | The pulse period is the time between pulses on the output channel 210 | 211 | Not all pulse periods can be acheived, nScope will automatically choose the closest approximation 212 | 213 | @returns 214 | nScope #ErrorType 215 | @param [in] nScope 216 | nScope handle 217 | @param [in] pChannel 218 | the channel (1 or 2) to set 219 | @param [in] period 220 | the desired pulse period (µs) of the channel 221 | */ 222 | NSCOPE_API ErrorType nScope_set_PX_period_in_us(ScopeHandle nScope, int pChannel, double period); 223 | 224 | /** @brief Get a pulse channel period in microseconds 225 | 226 | The pulse period is the time between pulses on the output channel 227 | 228 | @returns 229 | nScope #ErrorType 230 | @param [in] nScope 231 | nScope handle 232 | @param [in] pChannel 233 | the channel (1 or 2) to query 234 | @param [out] period 235 | pointer to the actual pulse period (µs) of the channel 236 | */ 237 | NSCOPE_API ErrorType nScope_get_PX_period_in_us(ScopeHandle nScope, int pChannel, double* period); 238 | 239 | /** @brief Set a pulse channel periods in microseconds 240 | 241 | The pulse period is the time between pulses on the output channel 242 | 243 | Not all pulse periods can be acheived, nScope will automatically choose the closest approximation 244 | 245 | @returns 246 | nScope #ErrorType 247 | @param [in] nScope 248 | nScope handle 249 | @param [in] period1 250 | the desired pulse period (µs) on P1 251 | @param [in] period2 252 | the desired pulse period (µs) on P2 253 | */ 254 | NSCOPE_API ErrorType nScope_set_P1_P2_periods_in_us(ScopeHandle nScope, double period1, double period2); 255 | 256 | /** @brief Get a pulse channel periods in microseconds 257 | 258 | The pulse period is the time between pulses on the output channel 259 | 260 | @returns 261 | nScope #ErrorType 262 | @param [in] nScope 263 | nScope handle 264 | @param [out] pulsePeriods 265 | pointer to an array of doubles to store the actual pulse periods (µs) 266 | */ 267 | NSCOPE_API ErrorType nScope_get_P1_P2_periods_in_us(ScopeHandle nScope, double* pulsePeriods); 268 | 269 | /** @brief Set a pulse channel duty percentage 270 | 271 | The duty percentage is the ratio of the time the output is high to the total period of the pulse. 272 | A duty of 100% means the signal is always 5V, and a signal of 0V means the signal is always 0V. 273 | 274 | Not all duty percentages can be acheived, nScope will automatically choose the closest approximation. 275 | 276 | @returns 277 | nScope #ErrorType 278 | @param [in] nScope 279 | nScope handle 280 | @param [in] pChannel 281 | the channel (1 or 2) to set 282 | @param [in] duty 283 | the desired pulse duty percentage (0.0-100.0) 284 | */ 285 | NSCOPE_API ErrorType nScope_set_PX_duty_percentage(ScopeHandle nScope, int pChannel, double duty); 286 | 287 | /** @brief Get a pulse channel duty percentage 288 | 289 | The duty percentage is the ratio of the time the output is high to the total period of the pulse. 290 | A duty of 100% means the signal is always 5V, and a signal of 0V means the signal is always 0V. 291 | 292 | @returns 293 | nScope #ErrorType 294 | @param [in] nScope 295 | nScope handle 296 | @param [in] pChannel 297 | the channel (1 or 2) to query 298 | @param [out] duty 299 | pointer to the actual pulse duty percentage (0.0-100.0) 300 | */ 301 | NSCOPE_API ErrorType nScope_get_PX_duty_percentage(ScopeHandle nScope, int pChannel, double* duty); 302 | 303 | /** @brief Set the pulse channel duty percentages 304 | 305 | The duty percentage is the ratio of the time the output is high to the total period of the pulse. 306 | A duty of 100% means the signal is always 5V, and a signal of 0V means the signal is always 0V. 307 | 308 | Not all duty percentages can be acheived, nScope will automatically choose the closest approximation. 309 | 310 | @returns 311 | nScope #ErrorType 312 | @param [in] nScope 313 | nScope handle 314 | @param [in] duty1 315 | the desired pulse duty percentage (0.0-100.0) on P1 316 | @param [in] duty2 317 | the desired pulse duty percentage (0.0-100.0) on P2 318 | */ 319 | NSCOPE_API ErrorType nScope_set_P1_P2_duty_percentages(ScopeHandle nScope, double duty1, double duty2); 320 | 321 | /** @brief Get the pulse channel duty percentages 322 | 323 | The duty percentage is the ratio of the time the output is high to the total period of the pulse. 324 | A duty of 100% means the signal is always 5V, and a signal of 0V means the signal is always 0V. 325 | 326 | @returns 327 | nScope #ErrorType 328 | @param [in] nScope 329 | nScope handle 330 | @param [out] dutyPercentages 331 | pointer to an array of doubles to store the actual pulse duty percentages (0.0-100.0) 332 | */ 333 | NSCOPE_API ErrorType nScope_get_P1_P2_duty_percentages(ScopeHandle nScope, double* dutyPercentages); 334 | 335 | /** @brief Set a pulse width in milliseconds on a pulse channel 336 | 337 | The pulse width is the amount of time the signal is high (5V) during each cycle 338 | 339 | Not all pulse widths can be acheived, nScope will automatically choose the closest approximation. 340 | 341 | @returns 342 | nScope #ErrorType 343 | @param [in] nScope 344 | nScope handle 345 | @param [in] pChannel 346 | the channel (1 or 2) to set 347 | @param [in] pulseWidth 348 | the desired pulse width (ms) 349 | */ 350 | NSCOPE_API ErrorType nScope_set_PX_pulse_width_in_ms(ScopeHandle nScope, int pChannel, double pulseWidth); 351 | 352 | /** @brief Get a pulse width in milliseconds on a pulse channel 353 | 354 | The pulse width is the amount of time the signal is high (5V) during each cycle 355 | 356 | @returns 357 | nScope #ErrorType 358 | @param [in] nScope 359 | nScope handle 360 | @param [in] pChannel 361 | the channel (1 or 2) to query 362 | @param [out] pulseWidth 363 | pointer to the actual pulse width (ms) 364 | */ 365 | NSCOPE_API ErrorType nScope_get_PX_pulse_width_in_ms(ScopeHandle nScope, int pChannel, double* pulseWidth); 366 | 367 | /** @brief Set the pulse widths in milliseconds on the pulse channels 368 | 369 | The pulse width is the amount of time the signal is high (5V) during each cycle 370 | 371 | Not all pulse widths can be acheived, nScope will automatically choose the closest approximation. 372 | 373 | @returns 374 | nScope #ErrorType 375 | @param [in] nScope 376 | nScope handle 377 | @param [in] pulseWidth1 378 | the desired pulse width (ms) on P1 379 | @param [in] pulseWidth2 380 | the desired pulse width (ms) on P2 381 | */ 382 | NSCOPE_API ErrorType nScope_set_P1_P2_pulse_widths_in_ms(ScopeHandle nScope, double pulseWidth1, double pulseWidth2); 383 | 384 | /** @brief Get the pulse widths in milliseconds on the pulse channels 385 | 386 | The pulse width is the amount of time the signal is high (5V) during each cycle 387 | 388 | @returns 389 | nScope #ErrorType 390 | @param [in] nScope 391 | nScope handle 392 | @param [out] pulseWidths 393 | pointer to an array of doubles to store the actual pulse widths (ms) 394 | */ 395 | NSCOPE_API ErrorType nScope_get_P1_P2_pulse_widths_in_ms(ScopeHandle nScope, double* pulseWidths); 396 | 397 | /** @brief Set a pulse width in microseconds on a pulse channel 398 | 399 | The pulse width is the amount of time the signal is high (5V) during each cycle 400 | 401 | Not all pulse widths can be acheived, nScope will automatically choose the closest approximation. 402 | 403 | @returns 404 | nScope #ErrorType 405 | @param [in] nScope 406 | nScope handle 407 | @param [in] pChannel 408 | the channel (1 or 2) to set 409 | @param [in] pulseWidth 410 | the desired pulse width (µs) 411 | */ 412 | NSCOPE_API ErrorType nScope_set_PX_pulse_width_in_us(ScopeHandle nScope, int pChannel, double pulseWidth); 413 | 414 | /** @brief Get a pulse width in microseconds on a pulse channel 415 | 416 | The pulse width is the amount of time the signal is high (5V) during each cycle 417 | 418 | @returns 419 | nScope #ErrorType 420 | @param [in] nScope 421 | nScope handle 422 | @param [in] pChannel 423 | the channel (1 or 2) to query 424 | @param [out] pulseWidth 425 | pointer to the actual pulse width (µs) 426 | */ 427 | NSCOPE_API ErrorType nScope_get_PX_pulse_width_in_us(ScopeHandle nScope, int pChannel, double* pulseWidth); 428 | 429 | /** @brief Set the pulse widths in microseconds on the pulse channels 430 | 431 | The pulse width is the amount of time the signal is high (5V) during each cycle 432 | 433 | Not all pulse widths can be acheived, nScope will automatically choose the closest approximation. 434 | 435 | @returns 436 | nScope #ErrorType 437 | @param [in] nScope 438 | nScope handle 439 | @param [in] pulseWidth1 440 | the desired pulse width (µs) on P1 441 | @param [in] pulseWidth2 442 | the desired pulse width (µs) on P2 443 | */ 444 | NSCOPE_API ErrorType nScope_set_P1_P2_pulse_widths_in_us(ScopeHandle nScope, double pulseWidth1, double pulseWidth2); 445 | 446 | /** @brief Get the pulse widths in microseconds on the pulse channels 447 | 448 | The pulse width is the amount of time the signal is high (5V) during each cycle 449 | 450 | @returns 451 | nScope #ErrorType 452 | @param [in] nScope 453 | nScope handle 454 | @param [out] pulseWidths 455 | pointer to an array of doubles to store the actual pulse widths (µs) 456 | */ 457 | NSCOPE_API ErrorType nScope_get_P1_P2_pulse_widths_in_us(ScopeHandle nScope, double* pulseWidths); 458 | 459 | /** @brief Send a single pulse out on a pulse channel 460 | 461 | The pulse width is the amount of time (ms) the signal is high (5V) 462 | 463 | Not all pulse widths can be acheived, nScope will automatically choose the closest approximation. 464 | 465 | @returns 466 | nScope #ErrorType 467 | @param [in] nScope 468 | nScope handle 469 | @param [in] pChannel 470 | the channel (1 or 2) to use 471 | @param [in] pulseWidth 472 | the desired pulse width (ms) 473 | */ 474 | NSCOPE_API ErrorType nScope_send_PX_oneshot_pulse(ScopeHandle nScope, int pChannel, double pulseWidth); 475 | 476 | /** @brief Send a single pulse out on both pulse channels 477 | 478 | The pulse width is the amount of time (ms) the signal is high (5V) 479 | 480 | Not all pulse widths can be acheived, nScope will automatically choose the closest approximation. 481 | 482 | @returns 483 | nScope #ErrorType 484 | @param [in] nScope 485 | nScope handle 486 | @param [in] pulseWidth1 487 | the desired pulse width (ms) on P1 488 | @param [in] pulseWidth2 489 | the desired pulse width (ms) on P2 490 | */ 491 | NSCOPE_API ErrorType nScope_send_P1_P2_oneshot_pulses(ScopeHandle nScope, double pulseWidth1, double pulseWidth2); 492 | 493 | 494 | 495 | #ifdef __cplusplus 496 | } 497 | #endif 498 | 499 | #endif 500 | -------------------------------------------------------------------------------- /include/nScopeAPI_requests.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file 14 | 15 | @brief contains function headers for making requests to nScope 16 | */ 17 | 18 | #ifndef NSCOPEAPI_REQUESTS_H__ 19 | #define NSCOPEAPI_REQUESTS_H__ 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** @brief Request data from nScope 27 | 28 | Creates a request for data from nScope. 29 | Anti-aliasing algorithm is used for nScope GUI, not recommended for data acquisition 30 | 31 | 32 | @returns 33 | #ErrorType 34 | @param [in] nScope 35 | #ScopeHandle object 36 | @param [out] newRequest_p 37 | pointer to a #Request object to store the request handle 38 | @param [in] numSamples 39 | number of data samples (per channel) to request 40 | @param [in] antiAliased 41 | true: turn on anti-aliasing, false: turn it off. 42 | */ 43 | NSCOPE_API ErrorType nScope_request_data(ScopeHandle nScope, Request* newRequest_p, int numSamples, bool antiAliased); 44 | 45 | /** @brief Request an infinite stream of data from nScope 46 | 47 | @warning not yet implemented 48 | 49 | */ 50 | NSCOPE_API ErrorType nScope_request_data_stream(ScopeHandle nScope, Request* newRequest_p); 51 | 52 | /** @brief stop a request that is in progress 53 | 54 | interrupts a current request from completing 55 | 56 | @returns 57 | #ErrorType 58 | @param [in] nScope 59 | #ScopeHandle object 60 | @param [in] reqHandle 61 | #Request object to stop 62 | */ 63 | NSCOPE_API ErrorType nScope_stop_request(ScopeHandle nScope, Request reqHandle); 64 | 65 | /** @brief release a request that is finished or stopped 66 | 67 | Frees the memory for the request. 68 | 69 | To prevent memory leaks, the developer must call this function after 70 | the request has finished an all data has been read. 71 | 72 | On success, the #Request handle will be a null pointer 73 | 74 | @returns 75 | #ErrorType 76 | @param [in] nScope 77 | #ScopeHandle object 78 | @param [out] reqHandle_p 79 | pointer to #Request object to release 80 | */ 81 | NSCOPE_API ErrorType nScope_release_request(ScopeHandle nScope, Request* reqHandle_p); 82 | 83 | /** @brief wait for a request to finish 84 | 85 | Blocks program execution until a request has finished transferring data from nScope 86 | 87 | @returns 88 | #ErrorType 89 | @param [in] nScope 90 | #ScopeHandle object 91 | @param [in] reqHandle 92 | #Request object on which to wait 93 | */ 94 | NSCOPE_API ErrorType nScope_wait_for_request_finish(ScopeHandle nScope,Request reqHandle); 95 | 96 | /** @brief determine if a request has completed the transfer 97 | 98 | Queries a request to see if the data has finished transferring, stores the result in 99 | hasCompleted 100 | 101 | @returns 102 | #ErrorType 103 | @param [in] nScope 104 | #ScopeHandle object 105 | @param [in] reqHandle 106 | #Request object to query 107 | @param [out] hasCompleted 108 | pointer to bool to store the result of the query 109 | */ 110 | NSCOPE_API ErrorType nScope_request_xfer_has_completed(ScopeHandle nScope, Request reqHandle, bool* hasCompleted); 111 | 112 | /** @brief query the number of samples remaining in the request transfer 113 | 114 | @warning not yet implemented 115 | 116 | */ 117 | NSCOPE_API ErrorType nScope_request_xfer_samples_remaining(ScopeHandle nScope, Request reqHandle); 118 | 119 | /** @brief Stop an infinite stream of data from nScope 120 | 121 | @warning not yet implemented 122 | 123 | */ 124 | NSCOPE_API ErrorType nScope_stop_data_stream(ScopeHandle nScope, Request reqHandle); 125 | 126 | /** @brief Read data from the request 127 | 128 | reads data from a specific channel on a request, and stores the result in data 129 | 130 | @returns 131 | #ErrorType 132 | @param [in] nScope 133 | #ScopeHandle object 134 | @param [in] reqHandle 135 | #Request object to query 136 | @param [in] channel 137 | channel to read 138 | @param [out] data 139 | pointer to double to store the read value on the request 140 | */ 141 | NSCOPE_API ErrorType nScope_read_data(ScopeHandle nScope, Request reqHandle, int channel, double* data); 142 | 143 | /** @brief Read data from the request 144 | 145 | reads data from a specific channel on a request, and stores the result in data, 146 | will not block to wait for more data to arrive from the device 147 | 148 | @returns 149 | #ErrorType 150 | @param [in] nScope 151 | #ScopeHandle object 152 | @param [in] reqHandle 153 | #Request object to query 154 | @param [in] channel 155 | channel to read 156 | @param [out] data 157 | pointer to double to store the read value on the request 158 | */ 159 | NSCOPE_API ErrorType nScope_read_data_nonblocking(ScopeHandle nScope, Request reqHandle, int channel, double* data); 160 | 161 | /** @brief determine if a request has unread data still stored in it 162 | 163 | Queries a request to see if there is still data to be read, stores the result in 164 | hasData 165 | 166 | @returns 167 | #ErrorType 168 | @param [in] nScope 169 | #ScopeHandle object 170 | @param [in] reqHandle 171 | #Request object to query 172 | @param [out] hasData 173 | pointer to bool to store the result of the query 174 | */ 175 | NSCOPE_API ErrorType nScope_request_has_data(ScopeHandle nScope, Request reqHandle, bool* hasData); 176 | 177 | #ifdef __cplusplus 178 | } 179 | #endif 180 | 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /include/nScopeAPI_sampleTiming.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file 14 | 15 | @brief contains function headers for controlling the nScope sample timing 16 | */ 17 | 18 | #ifndef NSCOPEAPI_SAMPLETIMING_H__ 19 | #define NSCOPEAPI_SAMPLETIMING_H__ 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** @brief set the sample rate 27 | 28 | Sets the scope sample rate in Hz 29 | 30 | Not all sample rates can be acheived, nScope will automatically choose the closest approximation 31 | 32 | @returns 33 | #ErrorType 34 | @param [in] nScope 35 | #ScopeHandle object 36 | @param [in] sample_hz 37 | desired sample rate in Hz 38 | */ 39 | NSCOPE_API ErrorType nScope_set_sample_rate_in_hz(ScopeHandle nScope, double sample_hz); 40 | 41 | /** @brief get the sample rate 42 | 43 | Gets the scope sample rate in Hz, stores it in sample_hz 44 | 45 | @returns 46 | #ErrorType 47 | @param [in] nScope 48 | #ScopeHandle object 49 | @param [out] sample_hz 50 | pointer to double to store actual sample rate in Hz 51 | */ 52 | NSCOPE_API ErrorType nScope_get_sample_rate_in_hz(ScopeHandle nScope, double* sample_hz); 53 | 54 | /** @brief set the time between samples in seconds 55 | 56 | Not all sample rates can be acheived, nScope will automatically choose the closest approximation 57 | 58 | @returns 59 | #ErrorType 60 | @param [in] nScope 61 | #ScopeHandle object 62 | @param [in] sample_time_seconds 63 | desired time between samples in seconds 64 | */ 65 | NSCOPE_API ErrorType nScope_set_time_between_samples_in_seconds(ScopeHandle nScope, double sample_time_seconds); 66 | 67 | /** @brief get the time between samples in seconds 68 | 69 | Gets the time between samples in seconds, stores it in sample_time_seconds 70 | 71 | @returns 72 | #ErrorType 73 | @param [in] nScope 74 | #ScopeHandle object 75 | @param [out] sample_time_seconds 76 | pointer to double to store actual time between samples 77 | */ 78 | NSCOPE_API ErrorType nScope_get_time_between_samples_in_seconds(ScopeHandle nScope, double* sample_time_seconds); 79 | 80 | /** @brief set the time between samples in minutes 81 | 82 | Not all sample rates can be acheived, nScope will automatically choose the closest approximation 83 | 84 | @returns 85 | #ErrorType 86 | @param [in] nScope 87 | #ScopeHandle object 88 | @param [in] sample_time_minutes 89 | desired time between samples in minutes 90 | */ 91 | NSCOPE_API ErrorType nScope_set_time_between_samples_in_minutes(ScopeHandle nScope, double sample_time_minutes); 92 | 93 | /** @brief get the time between samples in minutes 94 | 95 | Gets the time between samples in minutes, stores it in sample_time_minutes 96 | 97 | @returns 98 | #ErrorType 99 | @param [in] nScope 100 | #ScopeHandle object 101 | @param [out] sample_time_minutes 102 | pointer to double to store actual time between samples 103 | */ 104 | NSCOPE_API ErrorType nScope_get_time_between_samples_in_minutes(ScopeHandle nScope, double* sample_time_minutes); 105 | 106 | /** @brief set the time between samples in milliseconds 107 | 108 | Not all sample rates can be acheived, nScope will automatically choose the closest approximation 109 | 110 | @returns 111 | #ErrorType 112 | @param [in] nScope 113 | #ScopeHandle object 114 | @param [in] sample_time_ms 115 | desired time between samples in milliseconds 116 | */ 117 | NSCOPE_API ErrorType nScope_set_time_between_samples_in_ms(ScopeHandle nScope, double sample_time_ms); 118 | 119 | /** @brief get the time between samples in milliseconds 120 | 121 | Gets the time between samples in milliseconds, stores it in sample_time_ms 122 | 123 | @returns 124 | #ErrorType 125 | @param [in] nScope 126 | #ScopeHandle object 127 | @param [out] sample_time_ms 128 | pointer to double to store actual time between samples 129 | */ 130 | NSCOPE_API ErrorType nScope_get_time_between_samples_in_ms(ScopeHandle nScope, double* sample_time_ms); 131 | 132 | /** @brief set the time between samples in microseconds 133 | 134 | Not all sample rates can be acheived, nScope will automatically choose the closest approximation 135 | 136 | @returns 137 | #ErrorType 138 | @param [in] nScope 139 | #ScopeHandle object 140 | @param [in] sample_time_us 141 | desired time between samples in microseconds 142 | */ 143 | NSCOPE_API ErrorType nScope_set_time_between_samples_in_us(ScopeHandle nScope, double sample_time_us); 144 | 145 | /** @brief get the time between samples in microseconds 146 | 147 | Gets the time between samples in microseconds, stores it in sample_time_us 148 | 149 | @returns 150 | #ErrorType 151 | @param [in] nScope 152 | #ScopeHandle object 153 | @param [out] sample_time_us 154 | pointer to double to store actual time between samples 155 | */ 156 | NSCOPE_API ErrorType nScope_get_time_between_samples_in_us(ScopeHandle nScope, double* sample_time_us); 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /include/nScopeAPI_trigger.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | nScopeAPI - Multi-Platform library for 3 | communication with nScope devices. 4 | 5 | David Meyer 6 | 7 | 10/23/2014 8 | 9 | Copyright 2014, All Rights Reserved. 10 | 11 | ********************************************************/ 12 | 13 | /** @file 14 | 15 | @brief contains function headers for controlling the nScope trigger function 16 | */ 17 | 18 | #ifndef NSCOPEAPI_TRIGGER_H__ 19 | #define NSCOPEAPI_TRIGGER_H__ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | 26 | /** @brief Set the trigger on/off state 27 | 28 | A true state means the triggering on and will trigger on the current 29 | source, level, and edge state. 30 | 31 | @returns 32 | nScope ::ErrorType 33 | @param [in] nScope 34 | nScope handle 35 | @param [in] triggerOn 36 | true: set the trigger on, false: turn it off 37 | */ 38 | NSCOPE_API ErrorType nScope_set_trigger_on(ScopeHandle nScope, bool triggerOn); 39 | 40 | /** @brief Get the trigger on/off state 41 | 42 | A true state means the triggering on and will trigger on the current 43 | source, level, and edge state. 44 | 45 | @returns 46 | nScope ::ErrorType 47 | @param [in] nScope 48 | nScope handle 49 | @param [out] triggerOn 50 | pointer to variable to store the state of the trigger 51 | */ 52 | NSCOPE_API ErrorType nScope_get_trigger_on(ScopeHandle nScope, bool* triggerOn); 53 | 54 | /** @brief Set the trigger source channel 55 | 56 | The trigger source is the channel that is used to trigger a sweep. 57 | 58 | @returns 59 | nScope ::ErrorType 60 | @param [in] nScope 61 | nScope handle 62 | @param [in] triggerSource 63 | number 1-4 specifying the trigger channel 64 | */ 65 | NSCOPE_API ErrorType nScope_set_trigger_source(ScopeHandle nScope, int triggerSource); 66 | 67 | /** @brief Get the trigger source channel 68 | 69 | The trigger source is the channel that is used to trigger a sweep. 70 | 71 | @returns 72 | nScope ::ErrorType 73 | @param [in] nScope 74 | nScope handle 75 | @param [out] triggerSource 76 | pointer to int to store the trigger source channel 77 | */ 78 | NSCOPE_API ErrorType nScope_get_trigger_source(ScopeHandle nScope, int* triggerSource); 79 | 80 | /** @brief Set the trigger edge condition 81 | 82 | The trigger edge condition specifies which edge (rising or falling) will 83 | trigger a sweep. 84 | 85 | @returns 86 | nScope ::ErrorType 87 | @param [in] nScope 88 | nScope handle 89 | @param [in] triggerEdge 90 | number 1-4 specifying the trigger channel 91 | */ 92 | NSCOPE_API ErrorType nScope_set_trigger_edge(ScopeHandle nScope, TriggerEdge triggerEdge); 93 | 94 | /** @brief Get the trigger edge condition 95 | 96 | The trigger edge condition specifies which edge (rising or falling) will 97 | trigger a sweep. 98 | 99 | @returns 100 | nScope #ErrorType 101 | @param [in] nScope 102 | nScope handle 103 | @param [out] triggerEdge 104 | pointer to a #TriggerEdge to store the result 105 | */ 106 | NSCOPE_API ErrorType nScope_get_trigger_edge(ScopeHandle nScope, TriggerEdge* triggerEdge); 107 | 108 | /** @brief Set the trigger level 109 | 110 | The scope will be triggered when the source crosses the trigger level in the direction specified 111 | 112 | @returns 113 | nScope ::ErrorType 114 | @param [in] nScope 115 | nScope handle 116 | @param [in] triggerLevel 117 | voltage to se the trigger crossing detection 118 | */ 119 | NSCOPE_API ErrorType nScope_set_trigger_level(ScopeHandle nScope, double triggerLevel); 120 | 121 | /** @brief Get the trigger level 122 | 123 | The trigger source is the channel that is used to trigger a sweep. 124 | 125 | @returns 126 | nScope ::ErrorType 127 | @param [in] nScope 128 | nScope handle 129 | @param [out] triggerLevel 130 | pointer to double to store the current trigger level 131 | */ 132 | NSCOPE_API ErrorType nScope_get_trigger_level(ScopeHandle nScope, double* triggerLevel); 133 | 134 | /** @brief Set the trigger delay in milliseconds 135 | 136 | The trigger delay sets the amount of time before the trigger event the scope records data 137 | 138 | @returns 139 | nScope ::ErrorType 140 | @param [in] nScope 141 | nScope handle 142 | @param [in] triggerDelay 143 | trigger delay in milliseconds 144 | */ 145 | NSCOPE_API ErrorType nScope_set_trigger_delay_ms(ScopeHandle nScope, double triggerDelay); 146 | 147 | /** @brief Get the trigger delay in milliseconds 148 | 149 | The trigger delay sets the amount of time before the trigger event the scope records data 150 | 151 | @returns 152 | nScope ::ErrorType 153 | @param [in] nScope 154 | nScope handle 155 | @param [out] triggerDelay 156 | pointer to double to store the current trigger delay in milliseconds 157 | */ 158 | NSCOPE_API ErrorType nScope_get_trigger_delay_ms(ScopeHandle nScope, double* triggerDelay); 159 | 160 | /** @brief Set the trigger delay in microseconds 161 | 162 | The trigger delay sets the amount of time before the trigger event the scope records data 163 | 164 | @returns 165 | nScope ::ErrorType 166 | @param [in] nScope 167 | nScope handle 168 | @param [in] triggerDelay 169 | trigger delay in microseconds 170 | */ 171 | NSCOPE_API ErrorType nScope_set_trigger_delay_us(ScopeHandle nScope, double triggerDelay); 172 | 173 | /** @brief Get the trigger delay in microseconds 174 | 175 | The trigger delay sets the amount of time before the trigger event the scope records data 176 | 177 | @returns 178 | nScope ::ErrorType 179 | @param [in] nScope 180 | nScope handle 181 | @param [out] triggerDelay 182 | pointer to double to store the current trigger delay in microseconds 183 | */ 184 | NSCOPE_API ErrorType nScope_get_trigger_delay_us(ScopeHandle nScope, double* triggerDelay); 185 | 186 | #ifdef __cplusplus 187 | } 188 | #endif 189 | 190 | #endif 191 | -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | # nScopeAPI 2 | 3 | dynamic libraries live in this directory. more documentation to come. 4 | -------------------------------------------------------------------------------- /lib/linux_amd64/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/linux_amd64/libnscopeapi.so -------------------------------------------------------------------------------- /lib/linux_arm64/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/linux_arm64/libnscopeapi.so -------------------------------------------------------------------------------- /lib/linux_armhf/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/linux_armhf/libnscopeapi.so -------------------------------------------------------------------------------- /lib/linux_i386/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/linux_i386/libnscopeapi.so -------------------------------------------------------------------------------- /lib/mac/libnscopeapi.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/mac/libnscopeapi.dylib -------------------------------------------------------------------------------- /lib/win32/libnscopeapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/win32/libnscopeapi.dll -------------------------------------------------------------------------------- /lib/win32/libnscopeapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/win32/libnscopeapi.lib -------------------------------------------------------------------------------- /lib/win64/libnscopeapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/win64/libnscopeapi.dll -------------------------------------------------------------------------------- /lib/win64/libnscopeapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/lib/win64/libnscopeapi.lib -------------------------------------------------------------------------------- /matlab/nScopeAPI.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "mex.h" 3 | #include "nScopeAPI.h" 4 | #include "nScope.h" 5 | #include 6 | 7 | 8 | 9 | static scopeHandle* nScope; 10 | static request* currentRequest; 11 | 12 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 13 | { 14 | 15 | char cmd[64]; 16 | if (nrhs < 1 || mxGetString(prhs[0], cmd, sizeof(cmd))) 17 | mexErrMsgTxt("first input should be a command string less than 64 characters long."); 18 | 19 | // Open connection to nScope 20 | if (!strcmp("open", cmd)) { 21 | if(nlhs!=0){ 22 | mexErrMsgTxt(strcat(cmd,": no output required")); 23 | } 24 | if(nrhs!=2){ 25 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 26 | } 27 | if (nScope){ 28 | mexErrMsgTxt(strcat(cmd,": nScope already open")); 29 | } else { 30 | double APIver = nScope_check_API_version(); 31 | double FWver = nScope_check_FW_version(); 32 | int fwTryCount = 0; 33 | if((APIver != FWver && FWver > 0.0)){ 34 | mexEvalString("disp('incorrect firmware detected, attempting to find firmware loader...')"); 35 | while(nScope_find_firmware_loader()<0){ 36 | fwTryCount++; 37 | if(fwTryCount == 5){ 38 | mexEvalString("disp('having trouble finding firmware loader. please unplug nScope and re-plug while holding button')"); 39 | } 40 | if(fwTryCount == 30){ 41 | mexErrMsgTxt(strcat(cmd,": could not connect to firmware loader")); 42 | } 43 | } 44 | mexEvalString("disp('connected to loader. Writing firmware to nScope, do NOT unplug')"); 45 | fwTryCount = 0; 46 | while(nScope_write_to_loader() < 0){ 47 | fwTryCount++; 48 | if(fwTryCount == 30){ 49 | mexErrMsgTxt(strcat(cmd,": could not load firmware")); 50 | } 51 | } 52 | mexEvalString("disp('firmware update completed. please unplug and re-plug nScope')"); 53 | nScope = nScope_open(mxGetScalar(prhs[1])); 54 | fwTryCount++; 55 | while(!nScope){ 56 | mexEvalString("pause(0.5);"); 57 | nScope = nScope_open(mxGetScalar(prhs[1])); 58 | fwTryCount++; 59 | if(fwTryCount == 30){ 60 | mexErrMsgTxt(strcat(cmd,": unable to connect to nScope")); 61 | } 62 | } 63 | mexLock(); 64 | } else { 65 | nScope = nScope_open(mxGetScalar(prhs[1])); 66 | if(!nScope){ 67 | mexErrMsgTxt(strcat(cmd,": unable to connect to nScope")); 68 | } 69 | mexLock(); 70 | } 71 | } 72 | return; 73 | } 74 | 75 | // Close connection to nScope; 76 | if (!strcmp("close", cmd)) { 77 | if(nlhs!=0){ 78 | mexErrMsgTxt(strcat(cmd,": no output required")); 79 | } 80 | if (nScope){ 81 | nScope_close(&nScope); 82 | nScope = NULL; 83 | mexUnlock(); 84 | } else { 85 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 86 | } 87 | return; 88 | } 89 | 90 | // check API Version 91 | if (!strcmp("checkAPIver", cmd)) { 92 | if(nrhs>1){ 93 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 94 | } 95 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 96 | double* output = (double*)mxGetPr(plhs[0]); 97 | *output = nScope_check_API_version(); 98 | return; 99 | } 100 | 101 | if (!strcmp("checkFWver", cmd)) { 102 | if(nrhs>1){ 103 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 104 | } 105 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 106 | double* output = (double*)mxGetPr(plhs[0]); 107 | *output = nScope_check_FW_version(); 108 | if(*output == -101){ 109 | mexErrMsgTxt(strcat(cmd,": cannot connect to an nScope")); 110 | } 111 | return; 112 | } 113 | 114 | // Request Data from nScope 115 | if (!strcmp("requestData", cmd)) { 116 | if(nrhs!=2){ 117 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 118 | } 119 | if (nScope){ 120 | if(currentRequest != NULL){ 121 | nScope_release_request(nScope,¤tRequest); 122 | currentRequest = NULL; 123 | } 124 | currentRequest = nScope_request_data(nScope,mxGetScalar(prhs[1]),0); 125 | if(currentRequest == NULL){ 126 | mexErrMsgTxt(strcat(cmd,": invalid request")); 127 | } 128 | } else { 129 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 130 | } 131 | return; 132 | } 133 | 134 | // Read Data from the request 135 | if (!strcmp("readData", cmd)) { 136 | if(nrhs!=2){ 137 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 138 | } 139 | if (nScope){ 140 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 141 | double* output = (double*)mxGetPr(plhs[0]); 142 | if(currentRequest == NULL){ 143 | mexWarnMsgTxt(strcat(cmd,": no request found")); 144 | *output = 0; 145 | } else { 146 | *output = nScope_read_data(nScope,¤tRequest,mxGetScalar(prhs[1])); 147 | if (*output == -102){ 148 | mexWarnMsgTxt("nScopeAPI:readData: nScope channel is off"); 149 | } 150 | if (*output == -104){ 151 | mexWarnMsgTxt("nScopeAPI:readData: no more data is available"); 152 | } 153 | if (*output == -112){ 154 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 155 | } 156 | if (*output == -106){ 157 | mexErrMsgTxt(strcat(cmd,": invalid request")); 158 | } 159 | } 160 | } else { 161 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 162 | } 163 | return; 164 | } 165 | 166 | // Check if request has data 167 | if (!strcmp("requestHasData", cmd)) { 168 | if(nrhs!=1){ 169 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 170 | } 171 | if (nScope){ 172 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 173 | int* output = (int*)mxGetPr(plhs[0]); 174 | if(currentRequest == NULL){ 175 | *output = 0; 176 | mexWarnMsgTxt(strcat(cmd,": no request found")); 177 | } else { 178 | *output = nScope_request_has_data(nScope,¤tRequest); 179 | if (*output == -106){ 180 | mexErrMsgTxt(strcat(cmd,": invalid request")); 181 | } 182 | if(*output == 0){ 183 | nScope_release_request(nScope,¤tRequest); 184 | currentRequest = NULL; 185 | } 186 | } 187 | } else { 188 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 189 | } 190 | return; 191 | } 192 | 193 | 194 | /********************** 195 | Analog Inputs 196 | ***********************/ 197 | {{{ 198 | if (!strcmp("setChannelsOn", cmd)) { 199 | if(nrhs!=5){ 200 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 201 | } 202 | if(nlhs>0){ 203 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 204 | } 205 | if (nScope){ 206 | nScope_set_channels_on(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2]),mxGetScalar(prhs[3]),mxGetScalar(prhs[4])); 207 | } else { 208 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 209 | } 210 | return; 211 | } 212 | if (!strcmp("getChannelsOn", cmd)) { 213 | if(nrhs!=1){ 214 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 215 | } 216 | if(nlhs>1){ 217 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 218 | } 219 | if (nScope){ 220 | plhs[0] = mxCreateNumericMatrix(1,4,mxINT32_CLASS,mxREAL); 221 | int* output = (int*)mxGetPr(plhs[0]); 222 | nScope_get_channels_on(nScope,output); 223 | } else { 224 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 225 | } 226 | return; 227 | } 228 | if (!strcmp("getNumChannelsOn", cmd)) { 229 | if(nrhs!=1){ 230 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 231 | } 232 | if(nlhs>1){ 233 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 234 | } 235 | if (nScope){ 236 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 237 | int* output = (int*)mxGetPr(plhs[0]); 238 | *output = nScope_get_num_channels_on(nScope); 239 | } else { 240 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 241 | } 242 | return; 243 | } 244 | if (!strcmp("setChannelOn", cmd)) { 245 | if(nrhs!=3){ 246 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 247 | } 248 | if(nlhs>0){ 249 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 250 | } 251 | if (nScope){ 252 | int rtrn = nScope_set_ch_on(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 253 | if (rtrn == -112){ 254 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 255 | } 256 | } else { 257 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 258 | } 259 | return; 260 | } 261 | if (!strcmp("getChannelOn", cmd)) { 262 | if(nrhs!=2){ 263 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 264 | } 265 | if(nlhs>1){ 266 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 267 | } 268 | if (nScope){ 269 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 270 | int* output = (int*)mxGetPr(plhs[0]); 271 | *output = nScope_get_ch_on(nScope,mxGetScalar(prhs[1])); 272 | if (*output == -112){ 273 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 274 | } 275 | } else { 276 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 277 | } 278 | return; 279 | } 280 | 281 | if (!strcmp("setCh1on", cmd)) { 282 | if(nrhs!=2){ 283 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 284 | } 285 | if(nlhs>0){ 286 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 287 | } 288 | if (nScope){ 289 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 290 | int* output = (int*)mxGetPr(plhs[0]); 291 | *output = nScope_set_ch1_on(nScope,mxGetScalar(prhs[1])); 292 | } else { 293 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 294 | } 295 | return; 296 | } 297 | if (!strcmp("getCh1on", cmd)) { 298 | if(nrhs!=1){ 299 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 300 | } 301 | if(nlhs>1){ 302 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 303 | } 304 | if (nScope){ 305 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 306 | int* output = (int*)mxGetPr(plhs[0]); 307 | *output = nScope_get_ch1_on(nScope); 308 | } else { 309 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 310 | } 311 | return; 312 | } 313 | if (!strcmp("setCh2on", cmd)) { 314 | if(nrhs!=2){ 315 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 316 | } 317 | if(nlhs>0){ 318 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 319 | } 320 | if (nScope){ 321 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 322 | int* output = (int*)mxGetPr(plhs[0]); 323 | *output = nScope_set_ch2_on(nScope,mxGetScalar(prhs[1])); 324 | } else { 325 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 326 | } 327 | return; 328 | } 329 | if (!strcmp("getCh2on", cmd)) { 330 | if(nrhs!=1){ 331 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 332 | } 333 | if(nlhs>1){ 334 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 335 | } 336 | if (nScope){ 337 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 338 | int* output = (int*)mxGetPr(plhs[0]); 339 | *output = nScope_get_ch2_on(nScope); 340 | } else { 341 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 342 | } 343 | return; 344 | } 345 | if (!strcmp("setCh3on", cmd)) { 346 | if(nrhs!=2){ 347 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 348 | } 349 | if(nlhs>0){ 350 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 351 | } 352 | if (nScope){ 353 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 354 | int* output = (int*)mxGetPr(plhs[0]); 355 | *output = nScope_set_ch3_on(nScope,mxGetScalar(prhs[1])); 356 | } else { 357 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 358 | } 359 | return; 360 | } 361 | if (!strcmp("getCh3on", cmd)) { 362 | if(nrhs!=1){ 363 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 364 | } 365 | if(nlhs>1){ 366 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 367 | } 368 | if (nScope){ 369 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 370 | int* output = (int*)mxGetPr(plhs[0]); 371 | *output = nScope_get_ch3_on(nScope); 372 | } else { 373 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 374 | } 375 | return; 376 | } 377 | if (!strcmp("setCh4on", cmd)) { 378 | if(nrhs!=2){ 379 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 380 | } 381 | if(nlhs>0){ 382 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 383 | } 384 | if (nScope){ 385 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 386 | int* output = (int*)mxGetPr(plhs[0]); 387 | *output = nScope_set_ch4_on(nScope,mxGetScalar(prhs[1])); 388 | } else { 389 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 390 | } 391 | return; 392 | } 393 | if (!strcmp("getCh4on", cmd)) { 394 | if(nrhs!=1){ 395 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 396 | } 397 | if(nlhs>1){ 398 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 399 | } 400 | if (nScope){ 401 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 402 | int* output = (int*)mxGetPr(plhs[0]); 403 | *output = nScope_get_ch4_on(nScope); 404 | } else { 405 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 406 | } 407 | return; 408 | } 409 | 410 | if (!strcmp("setChannelGains", cmd)) { 411 | if(nrhs!=5){ 412 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 413 | } 414 | if(nlhs>0){ 415 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 416 | } 417 | if (nScope){ 418 | int rtrn = nScope_set_channel_gains(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2]),mxGetScalar(prhs[3]),mxGetScalar(prhs[4])); 419 | if(rtrn == -110){ 420 | mexErrMsgTxt(strcat(cmd,": requested gain is too low")); 421 | } 422 | if(rtrn == -111){ 423 | mexErrMsgTxt(strcat(cmd,": requested gain is too high")); 424 | } 425 | } else { 426 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 427 | } 428 | return; 429 | } 430 | if (!strcmp("getChannelGains", cmd)) { 431 | if(nrhs!=1){ 432 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 433 | } 434 | if(nlhs>1){ 435 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 436 | } 437 | if (nScope){ 438 | plhs[0] = mxCreateNumericMatrix(1,4,mxDOUBLE_CLASS,mxREAL); 439 | double* output = (double*)mxGetPr(plhs[0]); 440 | nScope_get_channel_gains(nScope,output); 441 | } else { 442 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 443 | } 444 | return; 445 | } 446 | 447 | if (!strcmp("setChannelGain", cmd)) { 448 | if(nrhs!=3){ 449 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 450 | } 451 | if(nlhs>0){ 452 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 453 | } 454 | if (nScope){ 455 | int rtrn = nScope_set_ch_gain(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 456 | if (rtrn == -112){ 457 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 458 | } 459 | if(rtrn == -110){ 460 | mexErrMsgTxt(strcat(cmd,": requested gain is too low")); 461 | } 462 | if(rtrn == -111){ 463 | mexErrMsgTxt(strcat(cmd,": requested gain is too high")); 464 | } 465 | } else { 466 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 467 | } 468 | return; 469 | } 470 | if (!strcmp("getChannelGain", cmd)) { 471 | if(nrhs!=2){ 472 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 473 | } 474 | if(nlhs>1){ 475 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 476 | } 477 | if (nScope){ 478 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 479 | double* output = (double*)mxGetPr(plhs[0]); 480 | *output = nScope_get_ch_gain(nScope,mxGetScalar(prhs[1])); 481 | if (*output == -112){ 482 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 483 | } 484 | } else { 485 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 486 | } 487 | return; 488 | } 489 | 490 | if (!strcmp("setCh1gain", cmd)) { 491 | if(nrhs!=2){ 492 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 493 | } 494 | if(nlhs>0){ 495 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 496 | } 497 | if (nScope){ 498 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 499 | double* output = (double*)mxGetPr(plhs[0]); 500 | *output = nScope_set_ch1_gain(nScope,mxGetScalar(prhs[1])); 501 | if(*output == -110){ 502 | mexErrMsgTxt(strcat(cmd,": requested gain is too low")); 503 | } 504 | if(*output == -111){ 505 | mexErrMsgTxt(strcat(cmd,": requested gain is too high")); 506 | } 507 | } else { 508 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 509 | } 510 | return; 511 | } 512 | if (!strcmp("getCh1gain", cmd)) { 513 | if(nrhs!=1){ 514 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 515 | } 516 | if(nlhs>1){ 517 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 518 | } 519 | if (nScope){ 520 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 521 | double* output = (double*)mxGetPr(plhs[0]); 522 | *output = nScope_get_ch1_gain(nScope); 523 | } else { 524 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 525 | } 526 | return; 527 | } 528 | if (!strcmp("setCh2gain", cmd)) { 529 | if(nrhs!=2){ 530 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 531 | } 532 | if(nlhs>0){ 533 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 534 | } 535 | if (nScope){ 536 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 537 | double* output = (double*)mxGetPr(plhs[0]); 538 | *output = nScope_set_ch2_gain(nScope,mxGetScalar(prhs[1])); 539 | if(*output == -110){ 540 | mexErrMsgTxt(strcat(cmd,": requested gain is too low")); 541 | } 542 | if(*output == -111){ 543 | mexErrMsgTxt(strcat(cmd,": requested gain is too high")); 544 | } 545 | } else { 546 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 547 | } 548 | return; 549 | } 550 | if (!strcmp("getCh2gain", cmd)) { 551 | if(nrhs!=1){ 552 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 553 | } 554 | if(nlhs>1){ 555 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 556 | } 557 | if (nScope){ 558 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 559 | double* output = (double*)mxGetPr(plhs[0]); 560 | *output = nScope_get_ch2_gain(nScope); 561 | } else { 562 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 563 | } 564 | return; 565 | } 566 | if (!strcmp("setCh3gain", cmd)) { 567 | if(nrhs!=2){ 568 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 569 | } 570 | if(nlhs>0){ 571 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 572 | } 573 | if (nScope){ 574 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 575 | double* output = (double*)mxGetPr(plhs[0]); 576 | *output = nScope_set_ch3_gain(nScope,mxGetScalar(prhs[1])); 577 | if(*output == -110){ 578 | mexErrMsgTxt(strcat(cmd,": requested gain is too low")); 579 | } 580 | if(*output == -111){ 581 | mexErrMsgTxt(strcat(cmd,": requested gain is too high")); 582 | } 583 | } else { 584 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 585 | } 586 | return; 587 | } 588 | if (!strcmp("getCh3gain", cmd)) { 589 | if(nrhs!=1){ 590 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 591 | } 592 | if(nlhs>1){ 593 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 594 | } 595 | if (nScope){ 596 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 597 | double* output = (double*)mxGetPr(plhs[0]); 598 | *output = nScope_get_ch3_gain(nScope); 599 | } else { 600 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 601 | } 602 | return; 603 | } 604 | if (!strcmp("setCh4gain", cmd)) { 605 | if(nrhs!=2){ 606 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 607 | } 608 | if(nlhs>0){ 609 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 610 | } 611 | if (nScope){ 612 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 613 | double* output = (double*)mxGetPr(plhs[0]); 614 | *output = nScope_set_ch4_gain(nScope,mxGetScalar(prhs[1])); 615 | if(*output == -110){ 616 | mexErrMsgTxt(strcat(cmd,": requested gain is too low")); 617 | } 618 | if(*output == -111){ 619 | mexErrMsgTxt(strcat(cmd,": requested gain is too high")); 620 | } 621 | } else { 622 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 623 | } 624 | return; 625 | } 626 | if (!strcmp("getCh4gain", cmd)) { 627 | if(nrhs!=1){ 628 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 629 | } 630 | if(nlhs>1){ 631 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 632 | } 633 | if (nScope){ 634 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 635 | double* output = (double*)mxGetPr(plhs[0]); 636 | *output = nScope_get_ch4_gain(nScope); 637 | } else { 638 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 639 | } 640 | return; 641 | } 642 | 643 | if (!strcmp("setChannelLevels", cmd)) { 644 | if(nrhs!=5){ 645 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 646 | } 647 | if(nlhs>0){ 648 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 649 | } 650 | if (nScope){ 651 | int rtrn = nScope_set_channel_levels(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2]),mxGetScalar(prhs[3]),mxGetScalar(prhs[4])); 652 | } else { 653 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 654 | } 655 | return; 656 | } 657 | if (!strcmp("getChannelLevels", cmd)) { 658 | if(nrhs!=1){ 659 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 660 | } 661 | if(nlhs>1){ 662 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 663 | } 664 | if (nScope){ 665 | plhs[0] = mxCreateNumericMatrix(1,4,mxDOUBLE_CLASS,mxREAL); 666 | double* output = (double*)mxGetPr(plhs[0]); 667 | nScope_get_channel_levels(nScope,output); 668 | } else { 669 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 670 | } 671 | return; 672 | } 673 | 674 | if (!strcmp("setChannelLevel", cmd)) { 675 | if(nrhs!=3){ 676 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 677 | } 678 | if(nlhs>0){ 679 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 680 | } 681 | if (nScope){ 682 | int rtrn = nScope_set_ch_level(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 683 | if (rtrn == -112){ 684 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 685 | } 686 | } else { 687 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 688 | } 689 | return; 690 | } 691 | if (!strcmp("getChannelLevel", cmd)) { 692 | if(nrhs!=2){ 693 | mexErrMsgTxt(strcat(cmd,": too many arguments")); 694 | } 695 | if(nlhs>1){ 696 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 697 | } 698 | if (nScope){ 699 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 700 | double* output = (double*)mxGetPr(plhs[0]); 701 | *output = nScope_get_ch_level(nScope,mxGetScalar(prhs[1])); 702 | if (*output == -112){ 703 | mexErrMsgTxt(strcat(cmd,": nScope channel does not exist")); 704 | } 705 | } else { 706 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 707 | } 708 | return; 709 | } 710 | 711 | if (!strcmp("setCh1level", cmd)) { 712 | if(nrhs!=2){ 713 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 714 | } 715 | if(nlhs>0){ 716 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 717 | } 718 | if (nScope){ 719 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 720 | double* output = (double*)mxGetPr(plhs[0]); 721 | *output = nScope_set_ch1_level(nScope,mxGetScalar(prhs[1])); 722 | } else { 723 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 724 | } 725 | return; 726 | } 727 | if (!strcmp("getCh1level", cmd)) { 728 | if(nrhs!=1){ 729 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 730 | } 731 | if(nlhs>1){ 732 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 733 | } 734 | if (nScope){ 735 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 736 | double* output = (double*)mxGetPr(plhs[0]); 737 | *output = nScope_get_ch1_level(nScope); 738 | } else { 739 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 740 | } 741 | return; 742 | } 743 | if (!strcmp("setCh2level", cmd)) { 744 | if(nrhs!=2){ 745 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 746 | } 747 | if(nlhs>0){ 748 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 749 | } 750 | if (nScope){ 751 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 752 | double* output = (double*)mxGetPr(plhs[0]); 753 | *output = nScope_set_ch2_level(nScope,mxGetScalar(prhs[1])); 754 | } else { 755 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 756 | } 757 | return; 758 | } 759 | if (!strcmp("getCh2level", cmd)) { 760 | if(nrhs!=1){ 761 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 762 | } 763 | if(nlhs>1){ 764 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 765 | } 766 | if (nScope){ 767 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 768 | double* output = (double*)mxGetPr(plhs[0]); 769 | *output = nScope_get_ch2_level(nScope); 770 | } else { 771 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 772 | } 773 | return; 774 | } 775 | if (!strcmp("setCh3level", cmd)) { 776 | if(nrhs!=2){ 777 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 778 | } 779 | if(nlhs>0){ 780 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 781 | } 782 | if (nScope){ 783 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 784 | double* output = (double*)mxGetPr(plhs[0]); 785 | *output = nScope_set_ch3_level(nScope,mxGetScalar(prhs[1])); 786 | } else { 787 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 788 | } 789 | return; 790 | } 791 | if (!strcmp("getCh3level", cmd)) { 792 | if(nrhs!=1){ 793 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 794 | } 795 | if(nlhs>1){ 796 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 797 | } 798 | if (nScope){ 799 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 800 | double* output = (double*)mxGetPr(plhs[0]); 801 | *output = nScope_get_ch3_level(nScope); 802 | } else { 803 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 804 | } 805 | return; 806 | } 807 | if (!strcmp("setCh4level", cmd)) { 808 | if(nrhs!=2){ 809 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 810 | } 811 | if(nlhs>0){ 812 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 813 | } 814 | if (nScope){ 815 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 816 | double* output = (double*)mxGetPr(plhs[0]); 817 | *output = nScope_set_ch4_level(nScope,mxGetScalar(prhs[1])); 818 | } else { 819 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 820 | } 821 | return; 822 | } 823 | if (!strcmp("getCh4level", cmd)) { 824 | if(nrhs!=1){ 825 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 826 | } 827 | if(nlhs>1){ 828 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 829 | } 830 | if (nScope){ 831 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 832 | double* output = (double*)mxGetPr(plhs[0]); 833 | *output = nScope_get_ch4_level(nScope); 834 | } else { 835 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 836 | } 837 | return; 838 | } 839 | 840 | 841 | }}} 842 | 843 | 844 | /********************** 845 | Sample Timing 846 | ***********************/ 847 | {{{ 848 | if (!strcmp("setSampleRateInHz", cmd)) { 849 | if(nrhs!=2){ 850 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 851 | } 852 | if (nScope){ 853 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 854 | double* output = (double*)mxGetPr(plhs[0]); 855 | *output = nScope_set_sample_rate_in_hz(nScope,mxGetScalar(prhs[1])); 856 | if(*output == -102){ 857 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 858 | } 859 | if(*output == -111){ 860 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too fast")); 861 | } 862 | if(*output == -110){ 863 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too slow")); 864 | } 865 | } else { 866 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 867 | } 868 | return; 869 | } 870 | if (!strcmp("getSampleRateInHz", cmd)) { 871 | if(nrhs!=1){ 872 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 873 | } 874 | if (nScope){ 875 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 876 | double* output = (double*)mxGetPr(plhs[0]); 877 | *output = nScope_get_sample_rate_in_hz(nScope); 878 | if(*output == -102){ 879 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 880 | } 881 | } else { 882 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 883 | } 884 | return; 885 | } 886 | if (!strcmp("setTimeBetweenSamplesInSeconds", cmd)) { 887 | if(nrhs!=2){ 888 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 889 | } 890 | if (nScope){ 891 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 892 | double* output = (double*)mxGetPr(plhs[0]); 893 | *output = nScope_set_time_between_samples_in_seconds(nScope,mxGetScalar(prhs[1])); 894 | if(*output == -102){ 895 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 896 | } 897 | if(*output == -110){ 898 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too fast")); 899 | } 900 | if(*output == -111){ 901 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too slow")); 902 | } 903 | } else { 904 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 905 | } 906 | return; 907 | } 908 | if (!strcmp("getTimeBetweenSamplesInSeconds", cmd)) { 909 | if(nrhs!=1){ 910 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 911 | } 912 | if (nScope){ 913 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 914 | double* output = (double*)mxGetPr(plhs[0]); 915 | *output = nScope_get_time_between_samples_in_seconds(nScope); 916 | if(*output == -102){ 917 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 918 | } 919 | } else { 920 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 921 | } 922 | return; 923 | } 924 | if (!strcmp("setTimeBetweenSamplesInMinutes", cmd)) { 925 | if(nrhs!=2){ 926 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 927 | } 928 | if (nScope){ 929 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 930 | double* output = (double*)mxGetPr(plhs[0]); 931 | *output = nScope_set_time_between_samples_in_minutes(nScope,mxGetScalar(prhs[1])); 932 | if(*output == -102){ 933 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 934 | } 935 | if(*output == -110){ 936 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too fast")); 937 | } 938 | if(*output == -111){ 939 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too slow")); 940 | } 941 | } else { 942 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 943 | } 944 | return; 945 | } 946 | if (!strcmp("getTimeBetweenSamplesInMinutes", cmd)) { 947 | if(nrhs!=1){ 948 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 949 | } 950 | if (nScope){ 951 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 952 | double* output = (double*)mxGetPr(plhs[0]); 953 | *output = nScope_get_time_between_samples_in_minutes(nScope); 954 | if(*output == -102){ 955 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 956 | } 957 | } else { 958 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 959 | } 960 | return; 961 | } 962 | if (!strcmp("setTimeBetweenSamplesInMs", cmd)) { 963 | if(nrhs!=2){ 964 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 965 | } 966 | if (nScope){ 967 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 968 | double* output = (double*)mxGetPr(plhs[0]); 969 | *output = nScope_set_time_between_samples_in_ms(nScope,mxGetScalar(prhs[1])); 970 | if(*output == -102){ 971 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 972 | } 973 | if(*output == -110){ 974 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too fast")); 975 | } 976 | if(*output == -111){ 977 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too slow")); 978 | } 979 | } else { 980 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 981 | } 982 | return; 983 | } 984 | if (!strcmp("getTimeBetweenSamplesInMs", cmd)) { 985 | if(nrhs!=1){ 986 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 987 | } 988 | if (nScope){ 989 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 990 | double* output = (double*)mxGetPr(plhs[0]); 991 | *output = nScope_get_time_between_samples_in_ms(nScope); 992 | if(*output == -102){ 993 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 994 | } 995 | } else { 996 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 997 | } 998 | return; 999 | } 1000 | if (!strcmp("setTimeBetweenSamplesInUs", cmd)) { 1001 | if(nrhs!=2){ 1002 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1003 | } 1004 | if (nScope){ 1005 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1006 | double* output = (double*)mxGetPr(plhs[0]); 1007 | *output = nScope_set_time_between_samples_in_us(nScope,mxGetScalar(prhs[1])); 1008 | if(*output == -102){ 1009 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 1010 | } 1011 | if(*output == -110){ 1012 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too fast")); 1013 | } 1014 | if(*output == -111){ 1015 | mexErrMsgTxt(strcat(cmd,": requested sample rate is too slow")); 1016 | } 1017 | } else { 1018 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1019 | } 1020 | return; 1021 | } 1022 | if (!strcmp("getTimeBetweenSamplesInUs", cmd)) { 1023 | if(nrhs!=1){ 1024 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1025 | } 1026 | if (nScope){ 1027 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1028 | double* output = (double*)mxGetPr(plhs[0]); 1029 | *output = nScope_get_time_between_samples_in_us(nScope); 1030 | if(*output == -102){ 1031 | mexErrMsgTxt(strcat(cmd,": no scope channels are on")); 1032 | } 1033 | } else { 1034 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1035 | } 1036 | return; 1037 | } 1038 | 1039 | }}} 1040 | 1041 | 1042 | /********************** 1043 | Pulse Generators 1044 | **********************/ 1045 | {{{ 1046 | 1047 | if (!strcmp("setP1frequencyInHz", cmd)) { 1048 | if(nrhs!=2){ 1049 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1050 | } 1051 | if (nScope){ 1052 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1053 | double* output = (double*)mxGetPr(plhs[0]); 1054 | *output = nScope_set_P1_frequency_in_hz(nScope,mxGetScalar(prhs[1])); 1055 | if(*output == -110){ 1056 | mexErrMsgTxt(strcat(cmd,": requested frequency is too fast")); 1057 | } 1058 | if(*output == -111){ 1059 | mexErrMsgTxt(strcat(cmd,": requested frequecny is too slow")); 1060 | } 1061 | } else { 1062 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1063 | } 1064 | return; 1065 | } 1066 | if (!strcmp("getP1frequencyInHz", cmd)) { 1067 | if(nrhs!=1){ 1068 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1069 | } 1070 | if (nScope){ 1071 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1072 | double* output = (double*)mxGetPr(plhs[0]); 1073 | *output = nScope_get_P1_frequency_in_hz(nScope); 1074 | } else { 1075 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1076 | } 1077 | return; 1078 | } 1079 | if (!strcmp("setP2frequencyInHz", cmd)) { 1080 | if(nrhs!=2){ 1081 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1082 | } 1083 | if (nScope){ 1084 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1085 | double* output = (double*)mxGetPr(plhs[0]); 1086 | *output = nScope_set_P2_frequency_in_hz(nScope,mxGetScalar(prhs[1])); 1087 | if(*output == -110){ 1088 | mexErrMsgTxt(strcat(cmd,": requested frequency is too fast")); 1089 | } 1090 | if(*output == -111){ 1091 | mexErrMsgTxt(strcat(cmd,": requested frequecny is too slow")); 1092 | } 1093 | } else { 1094 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1095 | } 1096 | return; 1097 | } 1098 | if (!strcmp("getP2frequencyInHz", cmd)) { 1099 | if(nrhs!=1){ 1100 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1101 | } 1102 | if (nScope){ 1103 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1104 | double* output = (double*)mxGetPr(plhs[0]); 1105 | *output = nScope_get_P2_frequency_in_hz(nScope); 1106 | } else { 1107 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1108 | } 1109 | return; 1110 | } 1111 | if (!strcmp("setPulseFrequenciesInHz", cmd)) { 1112 | if(nrhs!=3){ 1113 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1114 | } 1115 | if (nScope){ 1116 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1117 | double* output = (double*)mxGetPr(plhs[0]); 1118 | *output = nScope_set_pulse_frequencies_in_hz(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1119 | if(*output == -110){ 1120 | mexErrMsgTxt(strcat(cmd,": requested frequency is too fast")); 1121 | } 1122 | if(*output == -111){ 1123 | mexErrMsgTxt(strcat(cmd,": requested frequecny is too slow")); 1124 | } 1125 | } else { 1126 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1127 | } 1128 | return; 1129 | } 1130 | 1131 | if (!strcmp("setP1periodInMs", cmd)) { 1132 | if(nrhs!=2){ 1133 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1134 | } 1135 | if (nScope){ 1136 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1137 | double* output = (double*)mxGetPr(plhs[0]); 1138 | *output = nScope_set_P1_period_in_ms(nScope,mxGetScalar(prhs[1])); 1139 | if(*output == -110){ 1140 | mexErrMsgTxt(strcat(cmd,": requested period is too short")); 1141 | } 1142 | if(*output == -111){ 1143 | mexErrMsgTxt(strcat(cmd,": requested period is too long")); 1144 | } 1145 | } else { 1146 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1147 | } 1148 | return; 1149 | } 1150 | if (!strcmp("getP1periodInMs", cmd)) { 1151 | if(nrhs!=1){ 1152 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1153 | } 1154 | if (nScope){ 1155 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1156 | double* output = (double*)mxGetPr(plhs[0]); 1157 | *output = nScope_get_P1_period_in_ms(nScope); 1158 | } else { 1159 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1160 | } 1161 | return; 1162 | } 1163 | if (!strcmp("setP2periodInMs", cmd)) { 1164 | if(nrhs!=2){ 1165 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1166 | } 1167 | if (nScope){ 1168 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1169 | double* output = (double*)mxGetPr(plhs[0]); 1170 | *output = nScope_set_P2_period_in_ms(nScope,mxGetScalar(prhs[1])); 1171 | if(*output == -110){ 1172 | mexErrMsgTxt(strcat(cmd,": requested period is too short")); 1173 | } 1174 | if(*output == -111){ 1175 | mexErrMsgTxt(strcat(cmd,": requested period is too long")); 1176 | } 1177 | } else { 1178 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1179 | } 1180 | return; 1181 | } 1182 | if (!strcmp("getP2periodInMs", cmd)) { 1183 | if(nrhs!=1){ 1184 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1185 | } 1186 | if (nScope){ 1187 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1188 | double* output = (double*)mxGetPr(plhs[0]); 1189 | *output = nScope_get_P2_period_in_ms(nScope); 1190 | } else { 1191 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1192 | } 1193 | return; 1194 | } 1195 | if (!strcmp("setPulsePeriodsInMs", cmd)) { 1196 | if(nrhs!=3){ 1197 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1198 | } 1199 | if (nScope){ 1200 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1201 | double* output = (double*)mxGetPr(plhs[0]); 1202 | *output = nScope_set_pulse_periods_in_ms(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1203 | if(*output == -110){ 1204 | mexErrMsgTxt(strcat(cmd,": requested period is too short")); 1205 | } 1206 | if(*output == -111){ 1207 | mexErrMsgTxt(strcat(cmd,": requested period is too long")); 1208 | } 1209 | } else { 1210 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1211 | } 1212 | return; 1213 | } 1214 | 1215 | if (!strcmp("setP1periodInUs", cmd)) { 1216 | if(nrhs!=2){ 1217 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1218 | } 1219 | if (nScope){ 1220 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1221 | double* output = (double*)mxGetPr(plhs[0]); 1222 | *output = nScope_set_P1_period_in_us(nScope,mxGetScalar(prhs[1])); 1223 | if(*output == -110){ 1224 | mexErrMsgTxt(strcat(cmd,": requested period is too short")); 1225 | } 1226 | if(*output == -111){ 1227 | mexErrMsgTxt(strcat(cmd,": requested period is too long")); 1228 | } 1229 | } else { 1230 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1231 | } 1232 | return; 1233 | } 1234 | if (!strcmp("getP1periodInUs", cmd)) { 1235 | if(nrhs!=1){ 1236 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1237 | } 1238 | if (nScope){ 1239 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1240 | double* output = (double*)mxGetPr(plhs[0]); 1241 | *output = nScope_get_P1_period_in_us(nScope); 1242 | } else { 1243 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1244 | } 1245 | return; 1246 | } 1247 | if (!strcmp("setP2periodInUs", cmd)) { 1248 | if(nrhs!=2){ 1249 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1250 | } 1251 | if (nScope){ 1252 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1253 | double* output = (double*)mxGetPr(plhs[0]); 1254 | *output = nScope_set_P2_period_in_us(nScope,mxGetScalar(prhs[1])); 1255 | if(*output == -110){ 1256 | mexErrMsgTxt(strcat(cmd,": requested period is too short")); 1257 | } 1258 | if(*output == -111){ 1259 | mexErrMsgTxt(strcat(cmd,": requested period is too long")); 1260 | } 1261 | } else { 1262 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1263 | } 1264 | return; 1265 | } 1266 | if (!strcmp("getP2periodInUs", cmd)) { 1267 | if(nrhs!=1){ 1268 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1269 | } 1270 | if (nScope){ 1271 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1272 | double* output = (double*)mxGetPr(plhs[0]); 1273 | *output = nScope_get_P2_period_in_us(nScope); 1274 | } else { 1275 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1276 | } 1277 | return; 1278 | } 1279 | if (!strcmp("setPulsePeriodsInUs", cmd)) { 1280 | if(nrhs!=3){ 1281 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1282 | } 1283 | if (nScope){ 1284 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1285 | double* output = (double*)mxGetPr(plhs[0]); 1286 | *output = nScope_set_pulse_periods_in_us(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1287 | if(*output == -110){ 1288 | mexErrMsgTxt(strcat(cmd,": requested period is too short")); 1289 | } 1290 | if(*output == -111){ 1291 | mexErrMsgTxt(strcat(cmd,": requested period is too long")); 1292 | } 1293 | } else { 1294 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1295 | } 1296 | return; 1297 | } 1298 | 1299 | if (!strcmp("setP1dutyPercentage", cmd)) { 1300 | if(nrhs!=2){ 1301 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1302 | } 1303 | if (nScope){ 1304 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1305 | double* output = (double*)mxGetPr(plhs[0]); 1306 | *output = nScope_set_P1_duty_percentage(nScope,mxGetScalar(prhs[1])); 1307 | if(*output == -121){ 1308 | mexWarnMsgTxt("nScopeAPI:setP1dutyPercentage: requested duty results in always high signal"); 1309 | } 1310 | if(*output == -120){ 1311 | mexWarnMsgTxt("nScopeAPI:setP1dutyPercentage: requested duty results in always low signal"); 1312 | } 1313 | } else { 1314 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1315 | } 1316 | return; 1317 | } 1318 | if (!strcmp("getP1dutyPercentage", cmd)) { 1319 | if(nrhs!=1){ 1320 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1321 | } 1322 | if (nScope){ 1323 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1324 | double* output = (double*)mxGetPr(plhs[0]); 1325 | *output = nScope_get_P1_duty_percentage(nScope); 1326 | } else { 1327 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1328 | } 1329 | return; 1330 | } 1331 | if (!strcmp("setP2dutyPercentage", cmd)) { 1332 | if(nrhs!=2){ 1333 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1334 | } 1335 | if (nScope){ 1336 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1337 | double* output = (double*)mxGetPr(plhs[0]); 1338 | *output = nScope_set_P2_duty_percentage(nScope,mxGetScalar(prhs[1])); 1339 | if(*output == -121){ 1340 | mexWarnMsgTxt("nScopeAPI:setP2dutyPercentage: requested duty results in always high signal"); 1341 | } 1342 | if(*output == -120){ 1343 | mexWarnMsgTxt("nScopeAPI:setP2dutyPercentage: requested duty results in always low signal"); 1344 | } 1345 | } else { 1346 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1347 | } 1348 | return; 1349 | } 1350 | if (!strcmp("getP2dutyPercentage", cmd)) { 1351 | if(nrhs!=1){ 1352 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1353 | } 1354 | if (nScope){ 1355 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1356 | double* output = (double*)mxGetPr(plhs[0]); 1357 | *output = nScope_get_P2_duty_percentage(nScope); 1358 | } else { 1359 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1360 | } 1361 | return; 1362 | } 1363 | if (!strcmp("setPulseDutyPercentages", cmd)) { 1364 | if(nrhs!=3){ 1365 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1366 | } 1367 | if (nScope){ 1368 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1369 | double* output = (double*)mxGetPr(plhs[0]); 1370 | *output = nScope_set_pulse_duty_percentages(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1371 | if(*output == -121){ 1372 | mexWarnMsgTxt("nScopeAPI:setPulseDutyPercentages: requested duty results in always high signal"); 1373 | } 1374 | if(*output == -120){ 1375 | mexWarnMsgTxt("nScopeAPI:setPulseDutyPercentages: requested duty results in always low signal"); 1376 | } 1377 | } else { 1378 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1379 | } 1380 | return; 1381 | } 1382 | 1383 | if (!strcmp("setP1pulseWidthInMs", cmd)) { 1384 | if(nrhs!=2){ 1385 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1386 | } 1387 | if (nScope){ 1388 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1389 | double* output = (double*)mxGetPr(plhs[0]); 1390 | *output = nScope_set_P1_pulse_width_in_ms(nScope,mxGetScalar(prhs[1])); 1391 | if(*output == -121){ 1392 | mexWarnMsgTxt("nScopeAPI:setP1pulseWidthInMs: requested pulse width results in always high signal"); 1393 | } 1394 | if(*output == -120){ 1395 | mexWarnMsgTxt("nScopeAPI:setP1pulseWidthInMs: requested pulse width results in always low signal"); 1396 | } 1397 | } else { 1398 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1399 | } 1400 | return; 1401 | } 1402 | if (!strcmp("getP1pulseWidthInMs", cmd)) { 1403 | if(nrhs!=1){ 1404 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1405 | } 1406 | if (nScope){ 1407 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1408 | double* output = (double*)mxGetPr(plhs[0]); 1409 | *output = nScope_get_P1_pulse_width_in_ms(nScope); 1410 | } else { 1411 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1412 | } 1413 | return; 1414 | } 1415 | if (!strcmp("setP2pulseWidthInMs", cmd)) { 1416 | if(nrhs!=2){ 1417 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1418 | } 1419 | if (nScope){ 1420 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1421 | double* output = (double*)mxGetPr(plhs[0]); 1422 | *output = nScope_set_P2_pulse_width_in_ms(nScope,mxGetScalar(prhs[1])); 1423 | if(*output == -121){ 1424 | mexWarnMsgTxt("nScopeAPI:setP2pulseWidthInMs: requested pulse width results in always high signal"); 1425 | } 1426 | if(*output == -120){ 1427 | mexWarnMsgTxt("nScopeAPI:setP2pulseWidthInMs: requested pulse width results in always low signal"); 1428 | } 1429 | } else { 1430 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1431 | } 1432 | return; 1433 | } 1434 | if (!strcmp("getP2pulseWidthInMs", cmd)) { 1435 | if(nrhs!=1){ 1436 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1437 | } 1438 | if (nScope){ 1439 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1440 | double* output = (double*)mxGetPr(plhs[0]); 1441 | *output = nScope_get_P2_pulse_width_in_ms(nScope); 1442 | } else { 1443 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1444 | } 1445 | return; 1446 | } 1447 | if (!strcmp("setPulseWidthsInMs", cmd)) { 1448 | if(nrhs!=3){ 1449 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1450 | } 1451 | if (nScope){ 1452 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1453 | double* output = (double*)mxGetPr(plhs[0]); 1454 | *output = nScope_set_pulse_widths_in_ms(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1455 | if(*output == -121){ 1456 | mexWarnMsgTxt("nScopeAPI:setPulseWidthsInMs: requested pulse width results in always high signal"); 1457 | } 1458 | if(*output == -120){ 1459 | mexWarnMsgTxt("nScopeAPI:setPulseWidthsInMs: requested pulse width results in always low signal"); 1460 | } 1461 | } else { 1462 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1463 | } 1464 | return; 1465 | } 1466 | 1467 | if (!strcmp("setP1pulseWidthInUs", cmd)) { 1468 | if(nrhs!=2){ 1469 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1470 | } 1471 | if (nScope){ 1472 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1473 | double* output = (double*)mxGetPr(plhs[0]); 1474 | *output = nScope_set_P1_pulse_width_in_us(nScope,mxGetScalar(prhs[1])); 1475 | if(*output == -121){ 1476 | mexWarnMsgTxt("nScopeAPI:setP1pulseWidthInUs: requested pulse width results in always high signal"); 1477 | } 1478 | if(*output == -120){ 1479 | mexWarnMsgTxt("nScopeAPI:setP1pulseWidthInUs: requested pulse width results in always low signal"); 1480 | } 1481 | } else { 1482 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1483 | } 1484 | return; 1485 | } 1486 | if (!strcmp("getP1pulseWidthInUs", cmd)) { 1487 | if(nrhs!=1){ 1488 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1489 | } 1490 | if (nScope){ 1491 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1492 | double* output = (double*)mxGetPr(plhs[0]); 1493 | *output = nScope_get_P1_pulse_width_in_us(nScope); 1494 | } else { 1495 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1496 | } 1497 | return; 1498 | } 1499 | if (!strcmp("setP2pulseWidthInUs", cmd)) { 1500 | if(nrhs!=2){ 1501 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1502 | } 1503 | if (nScope){ 1504 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1505 | double* output = (double*)mxGetPr(plhs[0]); 1506 | *output = nScope_set_P2_pulse_width_in_us(nScope,mxGetScalar(prhs[1])); 1507 | if(*output == -121){ 1508 | mexWarnMsgTxt("nScopeAPI:setP2pulseWidthInUs: requested pulse width results in always high signal"); 1509 | } 1510 | if(*output == -120){ 1511 | mexWarnMsgTxt("nScopeAPI:setP2pulseWidthInUs: requested pulse width results in always low signal"); 1512 | } 1513 | } else { 1514 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1515 | } 1516 | return; 1517 | } 1518 | if (!strcmp("getP2pulseWidthInUs", cmd)) { 1519 | if(nrhs!=1){ 1520 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1521 | } 1522 | if (nScope){ 1523 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1524 | double* output = (double*)mxGetPr(plhs[0]); 1525 | *output = nScope_get_P2_pulse_width_in_us(nScope); 1526 | } else { 1527 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1528 | } 1529 | return; 1530 | } 1531 | if (!strcmp("setPulseWidthsInUs", cmd)) { 1532 | if(nrhs!=3){ 1533 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1534 | } 1535 | if (nScope){ 1536 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1537 | double* output = (double*)mxGetPr(plhs[0]); 1538 | *output = nScope_set_pulse_widths_in_us(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1539 | if(*output == -121){ 1540 | mexWarnMsgTxt("nScopeAPI:setPulseWidthsInUs: requested pulse width results in always high signal"); 1541 | } 1542 | if(*output == -120){ 1543 | mexWarnMsgTxt("nScopeAPI:setPulseWidthsInUs: requested pulse width results in always low signal"); 1544 | } 1545 | } else { 1546 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1547 | } 1548 | return; 1549 | } 1550 | 1551 | if (!strcmp("sendP1pulse", cmd)) { 1552 | if(nrhs!=2){ 1553 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1554 | } 1555 | if (nScope){ 1556 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1557 | double* output = (double*)mxGetPr(plhs[0]); 1558 | *output = nScope_send_P1_pulse(nScope,mxGetScalar(prhs[1])); 1559 | if(*output == -110){ 1560 | mexWarnMsgTxt("nScopeAPI:sendP1pulse: requested pulse is too short"); 1561 | } 1562 | if(*output == -111){ 1563 | mexWarnMsgTxt("nScopeAPI:sendP1pulse: requested pulse is too long"); 1564 | } 1565 | } else { 1566 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1567 | } 1568 | return; 1569 | } 1570 | if (!strcmp("sendP2pulse", cmd)) { 1571 | if(nrhs!=2){ 1572 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1573 | } 1574 | if (nScope){ 1575 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1576 | double* output = (double*)mxGetPr(plhs[0]); 1577 | *output = nScope_send_P2_pulse(nScope,mxGetScalar(prhs[1])); 1578 | if(*output == -110){ 1579 | mexWarnMsgTxt("nScopeAPI:sendP2pulse: requested pulse is too short"); 1580 | } 1581 | if(*output == -111){ 1582 | mexWarnMsgTxt("nScopeAPI:sendP2pulse: requested pulse is too long"); 1583 | } 1584 | } else { 1585 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1586 | } 1587 | return; 1588 | } 1589 | if (!strcmp("sendPulses", cmd)) { 1590 | if(nrhs!=3){ 1591 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1592 | } 1593 | if (nScope){ 1594 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 1595 | double* output = (double*)mxGetPr(plhs[0]); 1596 | *output = nScope_send_pulses(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1597 | if(*output == -110){ 1598 | mexWarnMsgTxt("nScopeAPI:sendPulses: requested pulse is too short"); 1599 | } 1600 | if(*output == -111){ 1601 | mexWarnMsgTxt("nScopeAPI:sendPulses: requested pulse is too long"); 1602 | } 1603 | } else { 1604 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1605 | } 1606 | return; 1607 | } 1608 | 1609 | if (!strcmp("setP1on", cmd)) { 1610 | if(nrhs!=2){ 1611 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1612 | } 1613 | if (nScope){ 1614 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1615 | int* output = (int*)mxGetPr(plhs[0]); 1616 | *output = nScope_set_P1_on(nScope,mxGetScalar(prhs[1])); 1617 | } else { 1618 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1619 | } 1620 | return; 1621 | } 1622 | if (!strcmp("getP1on", cmd)) { 1623 | if(nrhs!=1){ 1624 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1625 | } 1626 | if (nScope){ 1627 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1628 | int* output = (int*)mxGetPr(plhs[0]); 1629 | *output = nScope_get_P1_on(nScope); 1630 | } else { 1631 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1632 | } 1633 | return; 1634 | } 1635 | if (!strcmp("setP2on", cmd)) { 1636 | if(nrhs!=2){ 1637 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1638 | } 1639 | if (nScope){ 1640 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1641 | int* output = (int*)mxGetPr(plhs[0]); 1642 | *output = nScope_set_P2_on(nScope,mxGetScalar(prhs[1])); 1643 | } else { 1644 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1645 | } 1646 | return; 1647 | } 1648 | if (!strcmp("getP2on", cmd)) { 1649 | if(nrhs!=1){ 1650 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1651 | } 1652 | if (nScope){ 1653 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1654 | int* output = (int*)mxGetPr(plhs[0]); 1655 | *output = nScope_get_P2_on(nScope); 1656 | } else { 1657 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1658 | } 1659 | return; 1660 | } 1661 | if (!strcmp("setPulseGeneratorsOn", cmd)) { 1662 | if(nrhs!=3){ 1663 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1664 | } 1665 | if (nScope){ 1666 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1667 | int* output = (int*)mxGetPr(plhs[0]); 1668 | *output = nScope_set_pulse_generators_on(nScope,mxGetScalar(prhs[1]),mxGetScalar(prhs[2])); 1669 | } else { 1670 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1671 | } 1672 | return; 1673 | } 1674 | if (!strcmp("getPulseGeneratorsOn", cmd)) { 1675 | if(nrhs!=1){ 1676 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1677 | } 1678 | if (nScope){ 1679 | plhs[0] = mxCreateNumericMatrix(1,2,mxINT32_CLASS,mxREAL); 1680 | int* output = (int*)mxGetPr(plhs[0]); 1681 | nScope_get_pulse_generators_on(nScope,output); 1682 | } else { 1683 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1684 | } 1685 | return; 1686 | } 1687 | }}} 1688 | 1689 | /********************** 1690 | Analog Outputs 1691 | **********************/ 1692 | 1693 | if (!strcmp("setA1frequencyInHz", cmd)) { 1694 | if(nrhs!=2){ 1695 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1696 | } 1697 | if(nlhs>1){ 1698 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1699 | } 1700 | if (nScope){ 1701 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1702 | double* output = (double*)mxGetPr(plhs[0]); 1703 | *output = nScope_set_A1_frequency_in_hz(nScope,mxGetScalar(prhs[1])); 1704 | } else { 1705 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1706 | } 1707 | return; 1708 | } 1709 | if (!strcmp("getA1frequencyInHz", cmd)) { 1710 | if(nrhs!=1){ 1711 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1712 | } 1713 | if(nlhs>1){ 1714 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1715 | } 1716 | if (nScope){ 1717 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1718 | double* output = (double*)mxGetPr(plhs[0]); 1719 | *output = nScope_get_A1_frequency_in_hz(nScope); 1720 | } else { 1721 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1722 | } 1723 | return; 1724 | } 1725 | 1726 | if (!strcmp("setA2frequencyInHz", cmd)) { 1727 | if(nrhs!=2){ 1728 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1729 | } 1730 | if(nlhs>1){ 1731 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1732 | } 1733 | if (nScope){ 1734 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1735 | double* output = (double*)mxGetPr(plhs[0]); 1736 | *output = nScope_set_A2_frequency_in_hz(nScope,mxGetScalar(prhs[1])); 1737 | } else { 1738 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1739 | } 1740 | return; 1741 | } 1742 | if (!strcmp("getA2frequencyInHz", cmd)) { 1743 | if(nrhs!=1){ 1744 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1745 | } 1746 | if(nlhs>1){ 1747 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1748 | } 1749 | if (nScope){ 1750 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1751 | double* output = (double*)mxGetPr(plhs[0]); 1752 | *output = nScope_get_A2_frequency_in_hz(nScope); 1753 | } else { 1754 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1755 | } 1756 | return; 1757 | } 1758 | 1759 | if (!strcmp("setA1amplitude", cmd)) { 1760 | if(nrhs!=2){ 1761 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1762 | } 1763 | if(nlhs>1){ 1764 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1765 | } 1766 | if (nScope){ 1767 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1768 | double* output = (double*)mxGetPr(plhs[0]); 1769 | *output = nScope_set_A1_amplitude(nScope,mxGetScalar(prhs[1])); 1770 | } else { 1771 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1772 | } 1773 | return; 1774 | } 1775 | if (!strcmp("getA1amplitude", cmd)) { 1776 | if(nrhs!=1){ 1777 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1778 | } 1779 | if(nlhs>1){ 1780 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1781 | } 1782 | if (nScope){ 1783 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1784 | double* output = (double*)mxGetPr(plhs[0]); 1785 | *output = nScope_get_A1_amplitude(nScope); 1786 | } else { 1787 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1788 | } 1789 | return; 1790 | } 1791 | 1792 | if (!strcmp("setA2amplitude", cmd)) { 1793 | if(nrhs!=2){ 1794 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1795 | } 1796 | if(nlhs>1){ 1797 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1798 | } 1799 | if (nScope){ 1800 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1801 | double* output = (double*)mxGetPr(plhs[0]); 1802 | *output = nScope_set_A2_amplitude(nScope,mxGetScalar(prhs[1])); 1803 | } else { 1804 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1805 | } 1806 | return; 1807 | } 1808 | if (!strcmp("getA2amplitude", cmd)) { 1809 | if(nrhs!=1){ 1810 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1811 | } 1812 | if(nlhs>1){ 1813 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1814 | } 1815 | if (nScope){ 1816 | plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); 1817 | double* output = (double*)mxGetPr(plhs[0]); 1818 | *output = nScope_get_A2_amplitude(nScope); 1819 | } else { 1820 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1821 | } 1822 | return; 1823 | } 1824 | 1825 | if (!strcmp("setA1on", cmd)) { 1826 | if(nrhs!=2){ 1827 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1828 | } 1829 | if(nlhs>1){ 1830 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1831 | } 1832 | if (nScope){ 1833 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1834 | int* output = (int*)mxGetPr(plhs[0]); 1835 | *output = nScope_set_A1_on(nScope,mxGetScalar(prhs[1])); 1836 | } else { 1837 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1838 | } 1839 | return; 1840 | } 1841 | if (!strcmp("getA1on", cmd)) { 1842 | if(nrhs!=1){ 1843 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1844 | } 1845 | if(nlhs>1){ 1846 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1847 | } 1848 | if (nScope){ 1849 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1850 | int* output = (int*)mxGetPr(plhs[0]); 1851 | *output = nScope_get_A1_on(nScope); 1852 | } else { 1853 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1854 | } 1855 | return; 1856 | } 1857 | 1858 | if (!strcmp("setA2on", cmd)) { 1859 | if(nrhs!=2){ 1860 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1861 | } 1862 | if(nlhs>1){ 1863 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1864 | } 1865 | if (nScope){ 1866 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1867 | int* output = (int*)mxGetPr(plhs[0]); 1868 | *output = nScope_set_A2_on(nScope,mxGetScalar(prhs[1])); 1869 | } else { 1870 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1871 | } 1872 | return; 1873 | } 1874 | if (!strcmp("getA2on", cmd)) { 1875 | if(nrhs!=1){ 1876 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1877 | } 1878 | if(nlhs>1){ 1879 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1880 | } 1881 | if (nScope){ 1882 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1883 | int* output = (int*)mxGetPr(plhs[0]); 1884 | *output = nScope_get_A2_on(nScope); 1885 | } else { 1886 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1887 | } 1888 | return; 1889 | } 1890 | 1891 | if (!strcmp("setA1unipolar", cmd)) { 1892 | if(nrhs!=2){ 1893 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1894 | } 1895 | if(nlhs>1){ 1896 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1897 | } 1898 | if (nScope){ 1899 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1900 | int* output = (int*)mxGetPr(plhs[0]); 1901 | *output = nScope_set_A1_unipolar(nScope,mxGetScalar(prhs[1])); 1902 | } else { 1903 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1904 | } 1905 | return; 1906 | } 1907 | if (!strcmp("getA1unipolar", cmd)) { 1908 | if(nrhs!=1){ 1909 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1910 | } 1911 | if(nlhs>1){ 1912 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1913 | } 1914 | if (nScope){ 1915 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1916 | int* output = (int*)mxGetPr(plhs[0]); 1917 | *output = nScope_get_A1_unipolar(nScope); 1918 | } else { 1919 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1920 | } 1921 | return; 1922 | } 1923 | 1924 | if (!strcmp("setA2unipolar", cmd)) { 1925 | if(nrhs!=2){ 1926 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1927 | } 1928 | if(nlhs>1){ 1929 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1930 | } 1931 | if (nScope){ 1932 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1933 | int* output = (int*)mxGetPr(plhs[0]); 1934 | *output = nScope_set_A2_unipolar(nScope,mxGetScalar(prhs[1])); 1935 | } else { 1936 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1937 | } 1938 | return; 1939 | } 1940 | if (!strcmp("getA2unipolar", cmd)) { 1941 | if(nrhs!=1){ 1942 | mexErrMsgTxt(strcat(cmd,": incorrect number of arguments")); 1943 | } 1944 | if(nlhs>1){ 1945 | mexErrMsgTxt(strcat(cmd,": too many outputs")); 1946 | } 1947 | if (nScope){ 1948 | plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL); 1949 | int* output = (int*)mxGetPr(plhs[0]); 1950 | *output = nScope_get_A2_unipolar(nScope); 1951 | } else { 1952 | mexErrMsgTxt(strcat(cmd,": nScope is not connected")); 1953 | } 1954 | return; 1955 | } 1956 | 1957 | // Got here, so command not recognized 1958 | mexErrMsgTxt(strcat(cmd,": command not recognized.")); 1959 | } 1960 | -------------------------------------------------------------------------------- /matlab/nScopeAPI.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/matlab/nScopeAPI.mexa64 -------------------------------------------------------------------------------- /matlab/nScopeAPI.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/matlab/nScopeAPI.mexmaci64 -------------------------------------------------------------------------------- /matlab/nScopeAPI.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/matlab/nScopeAPI.mexw32 -------------------------------------------------------------------------------- /matlab/nScopeAPI.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/matlab/nScopeAPI.mexw64 -------------------------------------------------------------------------------- /matlab/nScopeAPI_MATLAB.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/matlab/nScopeAPI_MATLAB.zip -------------------------------------------------------------------------------- /matlab/nScopeAPI_MATLABv0.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/matlab/nScopeAPI_MATLABv0.6.zip -------------------------------------------------------------------------------- /matlab/nScopeReadAllChannels.m: -------------------------------------------------------------------------------- 1 | function [ data ] = nScopeReadAllChannels( sampleRate, numSamples, gains ) 2 | %[ data ] = nScopeReadAllChannels( sampleRate, numSamples ) 3 | % 4 | % read data from all channels of nScope 5 | % 6 | % requires nScope connection to be open with nScopeAPI('open',1); 7 | % 8 | % sampleRate: the sample rate in Hz of the channel 9 | % numSamples: the number of samples to take 10 | % gains: [ch1 ch2 ch3 ch4] vector input amplification gains 11 | % 12 | % nScope must have a connection open before running 13 | % run nScopeAPI('open',1) to open 14 | 15 | nScopeAPI('setChannelsOn',1,1,1,1); % turn on all Channels 16 | nScopeAPI('setChannelGains',gains(1),gains(2),gains(3),gains(4)); % set all channels with a gain of 1 17 | nScopeAPI('setSampleRateInHz',sampleRate); % set the sample rate 18 | nScopeAPI('requestData',numSamples); % request the samples from nScope 19 | nScopeAPI('sendP1Pulse',100000); 20 | data = zeros(numSamples,4); 21 | i = 0; 22 | while(nScopeAPI('requestHasData')) 23 | i=i+1; 24 | data(i,1) = nScopeAPI('readData',1); 25 | data(i,2) = nScopeAPI('readData',2); 26 | data(i,3) = nScopeAPI('readData',3); 27 | data(i,4) = nScopeAPI('readData',4); 28 | end 29 | 30 | 31 | end 32 | 33 | -------------------------------------------------------------------------------- /matlab/nScopeReadCh1.m: -------------------------------------------------------------------------------- 1 | function [ data ] = nScopeReadCh1( sampleRate, numSamples, gain) 2 | %[ data ] = nScopeReadCh1( sampleRate, numSamples, gain ) 3 | % 4 | % read data from Channel 1 of nScope 5 | % 6 | % requires nScope connection to be open with nScopeAPI('open',1); 7 | % 8 | % sampleRate: the sample rate in Hz of the channel 9 | % numSamples: the number of samples to take 10 | % gain: input amplification gain 11 | % 12 | % nScope must have a connection open before running 13 | % run nScopeAPI('open',1) to open 14 | 15 | nScopeAPI('setChannelsOn',1,0,0,0); % turn on Channel 1, and no others 16 | nScopeAPI('setCh1gain',gain); % set the gain on Channel 1 17 | nScopeAPI('setSampleRateInHz',sampleRate); % set the sample rate 18 | nScopeAPI('requestData',numSamples); % request the samples from nScope 19 | 20 | data = zeros(numSamples,1); 21 | i = 0; 22 | while(nScopeAPI('requestHasData')) 23 | i=i+1; 24 | data(i) = nScopeAPI('readData',1); 25 | end 26 | 27 | 28 | end 29 | 30 | -------------------------------------------------------------------------------- /matlab/nScopeTurnOnA1.m: -------------------------------------------------------------------------------- 1 | function nScopeTurnOnA1( frequency, iSunipolar, amplitude ) 2 | %nScopeTurnOnA1( frequency, iSunipolar, amplitude ) 3 | % 4 | % Turn on the A1 output of nScope 5 | % frequency: the frequency of the wave in Hz 6 | % isUnipolar: 1, output is positive with max amplitude 7 | % 0, output is bipolar with peak-to-peak amplitude twice the 8 | % given 9 | % 10 | % amplitude: peak voltage of output, bipolar output will swing to 11 | % negative levels 12 | % 13 | % nScope must have a connection open before running 14 | % run nScopeAPI('open',1) to open 15 | 16 | 17 | nScopeAPI('setA1frequencyInHz',frequency); % Set the frequency of A1 output 18 | nScopeAPI('setA1unipolar',iSunipolar); % Set the output to be unipolar or not 19 | nScopeAPI('setA1amplitude',amplitude); % Set the amplitude 20 | nScopeAPI('setA1on',1); % Set the A1 output on 21 | 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /matlab/nScopeTurnOnA2.m: -------------------------------------------------------------------------------- 1 | function nScopeTurnOnA2( frequency, iSunipolar, amplitude ) 2 | %nScopeTurnOnA2( frequency, iSunipolar, amplitude ) 3 | % 4 | % Turn on the A2 output of nScope 5 | % frequency: the frequency of the wave in Hz 6 | % isUnipolar: 1, output is positive with max amplitude 7 | % 0, output is bipolar with peak-to-peak amplitude twice the 8 | % given 9 | % 10 | % amplitude: peak voltage of output, bipolar output will swing to 11 | % negative levels 12 | % 13 | % nScope must have a connection open before running 14 | % run nScopeAPI('open',1) to open 15 | 16 | 17 | nScopeAPI('setA2frequencyInHz',frequency); % Set the frequency of A2 output 18 | nScopeAPI('setA2unipolar',iSunipolar); % Set the output to be unipolar or not 19 | nScopeAPI('setA2amplitude',amplitude); % Set the amplitude 20 | nScopeAPI('setA2on',1); % Set the A2 output on 21 | 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /matlab/nScopeTurnOnP1.m: -------------------------------------------------------------------------------- 1 | function nScopeTurnOnP1( frequency, duty ) 2 | %nScopeTurnOnP1( frequency, duty ) 3 | % 4 | % Turn on the P1 output of nScope 5 | % 6 | % frequency: the frequency of the pulse in Hz 7 | % duty: duty percentage of the pulse 8 | % 9 | % nScope must have a connection open before running 10 | % run nScopeAPI('open',1) to open 11 | 12 | warning ('off','all'); 13 | nScopeAPI('setP1frequencyInHz',frequency); %Set the frequency of P1 14 | nScopeAPI('setP1dutyPercentage',duty); %Set the P1 duty percentage 15 | nScopeAPI('setP1on',1); %Set P1 on 16 | 17 | 18 | end 19 | 20 | -------------------------------------------------------------------------------- /matlab/nScopeTurnOnP2.m: -------------------------------------------------------------------------------- 1 | function nScopeTurnOnP2( frequency, duty ) 2 | %nScopeTurnOnP2( frequency, duty ) 3 | % 4 | % Turn on the P2 output of nScope 5 | % 6 | % frequency: the frequency of the pulse in Hz 7 | % duty: duty percentage of the pulse 8 | % 9 | % nScope must have a connection open before running 10 | % run nScopeAPI('open',1) to open 11 | 12 | warning ('off','all'); 13 | nScopeAPI('setP2frequencyInHz',frequency); %Set the frequency of P1 14 | nScopeAPI('setP2dutyPercentage',duty); %Set the P1 duty percentage 15 | nScopeAPI('setP2on',1); %Set P1 on 16 | 17 | 18 | end 19 | 20 | -------------------------------------------------------------------------------- /nscopetest.cpp: -------------------------------------------------------------------------------- 1 | #include "include/nScopeAPI.h" 2 | #include 3 | #include 4 | 5 | // Headers needed for sleeping. 6 | #ifdef _WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | 13 | int main(int argc, char* argv[]) 14 | { 15 | // scopeHandle* handle = NULL; 16 | 17 | 18 | #ifdef WIN32 19 | UNREFERENCED_PARAMETER(argc); 20 | UNREFERENCED_PARAMETER(argv); 21 | #endif 22 | 23 | printf("API Version: %2.1f\n",nScope_check_API_version()); 24 | printf("FW Version: %2.1f\n",nScope_check_FW_version()); 25 | 26 | 27 | 28 | 29 | // handle = nScope_open(1); 30 | // if(!handle){ 31 | // printf("failed to connect\n"); 32 | // } else { 33 | // //printf("success\n"); 34 | // 35 | // nScope_set_A1_frequency_in_hz(handle,0.2); 36 | // nScope_set_A1_wave_type(handle,0); 37 | // nScope_set_A1_unipolar(handle,1); 38 | // nScope_set_A1_amplitude(handle,4); 39 | // nScope_set_A1_on(handle,1); 40 | // 41 | // 42 | // nScope_set_A2_frequency_in_hz(handle,1); 43 | // nScope_set_A2_wave_type(handle,1); 44 | // nScope_set_A2_unipolar(handle,0); 45 | // nScope_set_A2_amplitude(handle,1); 46 | // nScope_set_A2_on(handle,1); 47 | // 48 | // 49 | // 50 | // nScope_set_P1_frequency_in_hz(handle,2); 51 | // nScope_set_P1_duty_percentage(handle,3); 52 | // nScope_set_P2_frequency_in_hz(handle,1.5); 53 | // nScope_set_P2_duty_percentage(handle,50); 54 | // 55 | // nScope_set_P1_on(handle,1); 56 | // nScope_set_P2_on(handle,1); 57 | // 58 | // nScope_set_ch1_on(handle,1); 59 | // nScope_set_sample_rate_in_hz(handle,1); 60 | // request* req = nScope_request_data(handle,10,0); 61 | // while(nScope_request_has_data(handle, req)){ 62 | // printf("Check: %d\n",nScope_request_has_data(handle, req)); 63 | // printf("Ch: %2.2f\n",nScope_read_data(handle,req,1)); 64 | // printf("Ch: %2.2f\n",nScope_read_data(handle,req,2)); 65 | // printf("Ch: %2.2f\n",nScope_read_data(handle,req,3)); 66 | // printf("Ch: %2.2f\n",nScope_read_data(handle,req,4)); 67 | // } 68 | // printf("First Check: %d\n",nScope_request_has_data(handle, req)); 69 | // printf("Second Check: %d\n",nScope_request_has_data(handle, req)); 70 | // nScope_release_request(handle,req); 71 | // printf("Third Check: %d\n",nScope_request_has_data(handle, req)); 72 | // 73 | // 74 | // nScope_close(handle); 75 | // } 76 | 77 | 78 | #ifdef WIN32 79 | system("pause"); 80 | #endif 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /python/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include nscopeapi/lib/linux_amd64/libnscopeapi.so 2 | include nscopeapi/lib/linux_arm64/libnscopeapi.so 3 | include nscopeapi/lib/linux_armhf/libnscopeapi.so 4 | include nscopeapi/lib/linux_i386/libnscopeapi.so 5 | include nscopeapi/lib/mac/libnscopeapi.dylib 6 | include nscopeapi/lib/win32/libnscopeapi.dll 7 | include nscopeapi/lib/win64/libnscopeapi.dll 8 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # nScope python interface 2 | 3 | The nScope python interface is provided by a python package named `nscopeapi` 4 | 5 | ## Installing 6 | 7 | To clone and use this python package, you'll need [Git](https://git-scm.com) and [Python](https://www.python.org) installed on your system. 8 | 9 | 1. Clone the repository from the command line: 10 | ``` 11 | git clone https://github.com/nLabs-nScope/nScopeAPI 12 | ``` 13 | 2. Install the python package using the pip package manager 14 | ``` 15 | cd nScopeAPI/python 16 | pip install . 17 | ``` 18 | 3. Test the connection to the nScope. Be sure that no other application is currently connected to nScope. 19 | ``` 20 | python testConnection.py 21 | ``` 22 | 23 | ## Upgrading 24 | To upgrade the API and installation, you just need to pull recent changes from github, and upgrade the python module installation 25 | 26 | ## Using 27 | 28 | ## Troubleshooting 29 | 30 | -------------------------------------------------------------------------------- /python/nscopeapi/__init__.py: -------------------------------------------------------------------------------- 1 | from ctypes import byref 2 | from nscopeapi.nScopeDefs import * 3 | 4 | import nscopeapi.analogInputs 5 | import nscopeapi.analogOutputs 6 | import nscopeapi.pulseGenerators 7 | import nscopeapi.requests 8 | import nscopeapi.sampleTiming 9 | import nscopeapi.trigger 10 | 11 | def ERR(error): 12 | if error == 0: 13 | return 14 | if error == -100: 15 | raise RuntimeError("Unkown error") 16 | if error == -101: 17 | raise RuntimeError("nScope is not available") 18 | if error == -102: 19 | raise RuntimeError("") 20 | if error == -109: 21 | raise RuntimeError("Firmware and API are incompatible") 22 | 23 | 24 | 25 | class nScope( 26 | nscopeapi.nScopeDefs.Basics, 27 | nscopeapi.analogInputs.Implementation, 28 | nscopeapi.analogOutputs.Implementation, 29 | nscopeapi.pulseGenerators.Implementation, 30 | nscopeapi.requests.Implementation, 31 | nscopeapi.sampleTiming.Implementation, 32 | nscopeapi.trigger.Implementation): 33 | 34 | def __init__(self): 35 | 36 | self.handle = scopeHandle() 37 | self.request = scopeRequest() 38 | 39 | lib.nScope_open(True,byref(self.handle)) 40 | if self.handle: 41 | lib.nScope_initialize(self.handle) 42 | else: 43 | raise RuntimeError("Cannot connect to nScope") 44 | 45 | def readCh1(self,numsamples,samplerate): 46 | numsamples = int(numsamples) 47 | self.setChannelsOn(True,False,False,False) 48 | self.setSampleRateInHz(samplerate) 49 | self.requestData(numsamples) 50 | 51 | data = [] 52 | while self.requestHasData(): 53 | data.append(self.readData(1)) 54 | return data 55 | 56 | def readCh2(self,numsamples,samplerate): 57 | numsamples = int(numsamples) 58 | self.setChannelsOn(False,True,False,False) 59 | self.setSampleRateInHz(samplerate) 60 | self.requestData(numsamples) 61 | 62 | data = [] 63 | while self.requestHasData(): 64 | data.append(self.readData(2)) 65 | return data 66 | 67 | def readCh3(self,numsamples,samplerate): 68 | numsamples = int(numsamples) 69 | self.setChannelsOn(False,False,True,False) 70 | self.setSampleRateInHz(samplerate) 71 | self.requestData(numsamples) 72 | 73 | data = [] 74 | while self.requestHasData(): 75 | data.append(self.readData(3)) 76 | return data 77 | 78 | def readCh4(self,numsamples,samplerate): 79 | numsamples = int(numsamples) 80 | self.setChannelsOn(False,False,False,True) 81 | self.setSampleRateInHz(samplerate) 82 | self.requestData(numsamples) 83 | 84 | data = [] 85 | while self.requestHasData(): 86 | data.append(self.readData(4)) 87 | return data 88 | -------------------------------------------------------------------------------- /python/nscopeapi/analogInputs.py: -------------------------------------------------------------------------------- 1 | from ctypes import POINTER, byref, c_int, c_bool, c_double 2 | from nscopeapi.nScopeDefs import * 3 | 4 | lib.nScope_set_channels_on.restype = c_int 5 | lib.nScope_set_channels_on.argtypes = [POINTER(scopeDev),c_bool,c_bool,c_bool,c_bool] 6 | lib.nScope_get_channels_on.restype = c_int 7 | lib.nScope_get_channels_on.argtypes = [POINTER(scopeDev),POINTER(c_bool*4)] 8 | 9 | lib.nScope_get_num_channels_on.restype = c_int 10 | lib.nScope_get_num_channels_on.argtypes = [POINTER(scopeDev),POINTER(c_int)] 11 | 12 | lib.nScope_set_ChX_on.restype = c_int 13 | lib.nScope_set_ChX_on.argtypes = [POINTER(scopeDev), c_int, c_bool] 14 | lib.nScope_get_ChX_on.restype = c_int 15 | lib.nScope_get_ChX_on.argtypes = [POINTER(scopeDev), c_int, POINTER(c_bool)] 16 | 17 | lib.nScope_set_channel_gains.restype = c_int 18 | lib.nScope_set_channel_gains.argtypes = [POINTER(scopeDev),c_double,c_double,c_double,c_double] 19 | lib.nScope_get_channel_gains.restype = c_int 20 | lib.nScope_get_channel_gains.argtypes = [POINTER(scopeDev),POINTER(c_double*4)] 21 | 22 | lib.nScope_set_ChX_gain.restype = c_int 23 | lib.nScope_set_ChX_gain.argtypes = [POINTER(scopeDev), c_int, c_double] 24 | lib.nScope_get_ChX_gain.restype = c_int 25 | lib.nScope_get_ChX_gain.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 26 | 27 | lib.nScope_set_channel_levels.restype = c_int 28 | lib.nScope_set_channel_levels.argtypes = [POINTER(scopeDev),c_double,c_double,c_double,c_double] 29 | lib.nScope_get_channel_levels.restype = c_int 30 | lib.nScope_get_channel_levels.argtypes = [POINTER(scopeDev),POINTER(c_double*4)] 31 | 32 | lib.nScope_set_ChX_level.restype = c_int 33 | lib.nScope_set_ChX_level.argtypes = [POINTER(scopeDev), c_int, c_double] 34 | lib.nScope_get_ChX_level.restype = c_int 35 | lib.nScope_get_ChX_level.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 36 | 37 | # if rtrn == -101: 38 | # raise RuntimeError("nScope is not connected") 39 | # return 40 | 41 | # if rtrn == -112: 42 | # raise ValueError("nScope channel does not exist") 43 | # return 44 | 45 | # if rtrn == -110: 46 | # raise ValueError("requested gain is too low") 47 | # return 48 | # if rtrn == -111: 49 | # raise ValueError("requested gain is too high") 50 | # return 51 | 52 | class Implementation: 53 | def setChannelsOn(self,ch1on,ch2on,ch3on,ch4on): 54 | lib.nScope_set_channels_on(self.handle,ch1on,ch2on,ch3on,ch4on) 55 | return 56 | 57 | def getChannelsOn(self): 58 | channelsOn = (c_bool*4)() 59 | lib.nScope_get_channels_on(self.handle,byref(channelsOn)) 60 | return list(channelsOn) 61 | 62 | def getNumChannelsOn(self): 63 | numChannelsOn = c_int() 64 | lib.nScope_get_num_channels_on(self.handle,byref(numChannelsOn)) 65 | return numChannelsOn.value 66 | 67 | def setChannelOn(self,ch,chOn): 68 | chOn = bool(chOn) 69 | lib.nScope_set_ChX_on(self.handle,ch,chOn) 70 | return 71 | 72 | def getChannelOn(self,ch): 73 | chOn = c_bool() 74 | lib.nScope_get_ChX_on(self.handle,ch,byref(chOn)) 75 | return chOn.value 76 | 77 | def setChannelGains(self,ch1gain,ch2gain,ch3gain,ch4gain): 78 | lib.nScope_set_channel_gains(self.handle,ch1gain,ch2gain,ch3gain,ch4gain) 79 | return 80 | 81 | def getChannelGains(self): 82 | channelGains = (c_double*4)() 83 | lib.nScope_get_channel_gains(self.handle,byref(channelGains)) 84 | return list(channelGains) 85 | 86 | def setChannelGain(self,ch,chGain): 87 | lib.nScope_set_ChX_gain(self.handle,ch,chGain) 88 | return 89 | 90 | def getChannelGain(self,ch): 91 | chGain = c_double() 92 | lib.nScope_get_ChX_gain(self.handle,ch,byref(chGain)) 93 | return chGain.value 94 | 95 | def setChannelLevels(self,ch1level,ch2level,ch3level,ch4level): 96 | lib.nScope_set_channel_levels(self.handle,ch1level,ch2level,ch3level,ch4level) 97 | return 98 | 99 | def getChannelLevels(self): 100 | channelLevels = (c_double*4)() 101 | lib.nScope_get_channel_levels(self.handle,byref(channelLevels)) 102 | return list(channelLevels) 103 | 104 | def setChannelLevel(self,ch,chLevel): 105 | lib.nScope_set_ChX_level(self.handle,ch,chLevel) 106 | return 107 | 108 | def getChannelLevel(self,ch): 109 | chLevel = c_double() 110 | lib.nScope_get_ChX_level(self.handle,ch,byref(chLevel)) 111 | return chLevel.value 112 | -------------------------------------------------------------------------------- /python/nscopeapi/analogOutputs.py: -------------------------------------------------------------------------------- 1 | from ctypes import POINTER, c_int, c_bool, c_double 2 | from nscopeapi.nScopeDefs import * 3 | 4 | lib.nScope_set_AX_on.restype = c_int 5 | lib.nScope_set_AX_on.argtypes = [POINTER(scopeDev), c_int, c_bool] 6 | lib.nScope_get_AX_on.restype = c_int 7 | lib.nScope_get_AX_on.argtypes = [POINTER(scopeDev), c_int, POINTER(c_bool)] 8 | 9 | lib.nScope_set_AX_frequency_in_hz.restype = c_int 10 | lib.nScope_set_AX_frequency_in_hz.argtypes = [POINTER(scopeDev), c_int, c_double] 11 | lib.nScope_get_AX_frequency_in_hz.restype = c_int 12 | lib.nScope_get_AX_frequency_in_hz.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 13 | 14 | lib.nScope_set_AX_wave_type.restype = c_int 15 | lib.nScope_set_AX_wave_type.argtypes = [POINTER(scopeDev), c_int ,c_int] 16 | lib.nScope_get_AX_wave_type.restype = c_int 17 | lib.nScope_get_AX_wave_type.argtypes = [POINTER(scopeDev), c_int, POINTER(c_int)] 18 | 19 | lib.nScope_set_AX_unipolar.restype = c_int 20 | lib.nScope_set_AX_unipolar.argtypes = [POINTER(scopeDev), c_int, c_bool] 21 | lib.nScope_get_AX_unipolar.restype = c_int 22 | lib.nScope_get_AX_unipolar.argtypes = [POINTER(scopeDev), c_int, POINTER(c_bool)] 23 | 24 | lib.nScope_set_AX_amplitude.restype = c_int 25 | lib.nScope_set_AX_amplitude.argtypes = [POINTER(scopeDev), c_int, c_double] 26 | lib.nScope_get_AX_amplitude.restype = c_int 27 | lib.nScope_get_AX_amplitude.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 28 | 29 | # if rtrn == -101: 30 | # raise RuntimeError("nScope is not connected") 31 | # return 32 | # if wave.lower() == 'sine' or wave.lower() == 'sin': 33 | # rtrn = lib.nScope_set_A1_wave_type(self.handle,0) 34 | # elif wave.lower() == 'triangle' or wave.lower() == 'tri': 35 | # rtrn = lib.nScope_set_A1_wave_type(self.handle,1) 36 | # else: 37 | # raise ValueError("Unknown wave type: "+wave) 38 | # return 39 | # if rtrn is 0: 40 | # return 'Sine' 41 | # elif rtrn is 1: 42 | # return 'Triangle' 43 | 44 | class Implementation: 45 | def setAXOn(self,ax,axOn): 46 | axOn = bool(axOn) 47 | lib.nScope_set_AX_on(self.handle,ax,axOn) 48 | return 49 | 50 | def getAXOn(self,ax): 51 | axOn = c_bool() 52 | lib.nScope_get_AX_on(self.handle,ax,byref(axOn)) 53 | return axOn.value 54 | 55 | def setAXFrequencyInHz(self,ax,axFrequency): 56 | lib.nScope_set_AX_frequency_in_hz(self.handle,ax,axFrequency) 57 | return 58 | 59 | def getAXFrequencyInHz(self,ax): 60 | axFrequency = c_double() 61 | lib.nScope_get_AX_frequency_in_hz(self.handle,ax,byref(axFrequency)) 62 | return axFrequency.value 63 | 64 | def setAXWaveType(self,ax,axWave): 65 | lib.nScope_set_AX_wave_type(self.handle,ax,axWave) 66 | return 67 | 68 | def getAXWaveType(self,ax): 69 | axWave = c_int() 70 | lib.nScope_get_AX_wave_type(self.handle,ax,byref(axWave)) 71 | return axWave.value 72 | 73 | def setAXUnipolar(self,ax,axUnipolar): 74 | axUnipolar = bool(axUnipolar) 75 | lib.nScope_set_AX_unipolar(self.handle,ax,axUnipolar) 76 | return 77 | 78 | def getAXUnipolar(self,ax): 79 | axUnipolar = c_bool() 80 | lib.nScope_get_AX_unipolar(self.handle,ax,byref(axUnipolar)) 81 | return axUnipolar.value 82 | 83 | def setAXAmplitude(self,ax,axAmplitude): 84 | lib.nScope_set_AX_amplitude(self.handle,ax,axAmplitude) 85 | return 86 | 87 | def getAXAmplitude(self,ax): 88 | axAmplitude = c_double() 89 | lib.nScope_get_AX_amplitude(self.handle,ax,byref(axAmplitude)) 90 | return axAmplitude.value 91 | -------------------------------------------------------------------------------- /python/nscopeapi/lib/linux_amd64/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/linux_amd64/libnscopeapi.so -------------------------------------------------------------------------------- /python/nscopeapi/lib/linux_arm64/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/linux_arm64/libnscopeapi.so -------------------------------------------------------------------------------- /python/nscopeapi/lib/linux_armhf/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/linux_armhf/libnscopeapi.so -------------------------------------------------------------------------------- /python/nscopeapi/lib/linux_i386/libnscopeapi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/linux_i386/libnscopeapi.so -------------------------------------------------------------------------------- /python/nscopeapi/lib/mac/libnscopeapi.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/mac/libnscopeapi.dylib -------------------------------------------------------------------------------- /python/nscopeapi/lib/win32/libnscopeapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/win32/libnscopeapi.dll -------------------------------------------------------------------------------- /python/nscopeapi/lib/win32/libnscopeapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/win32/libnscopeapi.lib -------------------------------------------------------------------------------- /python/nscopeapi/lib/win64/libnscopeapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/win64/libnscopeapi.dll -------------------------------------------------------------------------------- /python/nscopeapi/lib/win64/libnscopeapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nLabs-nScope/nScopeAPI/176840146f9ad97895c5a744249b10c0f4db5228/python/nscopeapi/lib/win64/libnscopeapi.lib -------------------------------------------------------------------------------- /python/nscopeapi/nScopeDefs.py: -------------------------------------------------------------------------------- 1 | from ctypes import CDLL, Structure, POINTER, byref, c_double, c_int, c_bool 2 | import platform,os 3 | 4 | system = platform.system() 5 | machine = platform.machine() 6 | architecture = platform.architecture()[0] 7 | 8 | intelMachines = ["i386","x86","x86_64"] 9 | armMachines = ["arm","armv7","armv71","armv7","armv8b","armv8l","aarch64","aarch64_be"] 10 | 11 | if system == "Darwin": 12 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/mac/libnscopeapi.dylib")) 13 | 14 | elif system == "Windows": 15 | if architecture == "32bit": 16 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/win32/libnscopeapi.dll")) 17 | elif architecture == "64bit": 18 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/win64/libnscopeapi.dll")) 19 | else: 20 | raise(EnvironmentError("Unrecognized architecture: '%s'" % architecture)) 21 | 22 | elif system == "Linux": 23 | if machine in intelMachines: 24 | if architecture == "32bit": 25 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/linux_i386/libnscopeapi.so")) 26 | elif architecture == "64bit": 27 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/linux_amd64/libnscopeapi.so")) 28 | else: 29 | raise(EnvironmentError("Unrecognized architecture: '%s'" % architecture)) 30 | elif machine in armMachines: 31 | if architecture == "32bit": 32 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/linux_armhf/libnscopeapi.so")) 33 | elif architecture == "64bit": 34 | lib = CDLL(os.path.join(os.path.abspath(os.path.dirname(__file__)), "lib/linux_arm64/libnscopeapi.so")) 35 | else: 36 | raise(EnvironmentError("Unrecognized architecture: '%s'" % architecture)) 37 | else: 38 | raise(EnvironmentError("Unrecognized machine type: '%s'" % machine)) 39 | else: 40 | raise(EnvironmentError("Unrecognized system type: '%s'" % system)) 41 | 42 | class scopeDev(Structure): 43 | pass 44 | 45 | class requestObj(Structure): 46 | pass 47 | 48 | scopeHandle = POINTER(scopeDev) 49 | scopeRequest = POINTER(requestObj) 50 | 51 | lib.nScope_open.restype = c_int 52 | lib.nScope_open.argtypes = [c_bool, POINTER(POINTER(scopeDev))] 53 | 54 | lib.nScope_close.restype = c_int 55 | lib.nScope_close.argtypes = [POINTER(POINTER(scopeDev))] 56 | 57 | lib.nScope_clean.restype = c_int 58 | lib.nScope_clean.argtypes = [POINTER(POINTER(scopeDev))] 59 | 60 | lib.nScope_initialize.restype = c_int 61 | lib.nScope_initialize.argtypes = [POINTER(scopeDev)] 62 | 63 | lib.nScope_get_power_usage.restype = c_int 64 | lib.nScope_get_power_usage.argtypes = [POINTER(scopeDev), POINTER(c_double)] 65 | 66 | lib.nScope_get_power_state.restype = c_int 67 | lib.nScope_get_power_state.argtypes = [POINTER(scopeDev), POINTER(c_int)] 68 | 69 | lib.nScope_find_firmware_loader.restype = c_int 70 | lib.nScope_write_to_loader.restype = c_int 71 | lib.nScope_load_firmware.restype = c_int 72 | 73 | lib.nScope_check_API_version.restype = c_int 74 | lib.nScope_check_API_version.argtypes = [POINTER(c_double)] 75 | 76 | lib.nScope_check_FW_version.restype = c_int 77 | lib.nScope_check_FW_version.argtypes = [POINTER(c_double)] 78 | 79 | lib.nScope_check_API_build.restype = c_int 80 | lib.nScope_check_API_build.argtypes = [POINTER(c_int)] 81 | 82 | class Basics: 83 | def getPowerState(self): 84 | powerState = c_int() 85 | lib.nScope_get_power_state(self.handle,byref(powerState)) 86 | return powerState.value 87 | 88 | def checkAPIver(self): 89 | APIver = c_double() 90 | lib.nScope_check_API_version(byref(APIver)) 91 | return APIver.value 92 | 93 | def checkAPIbuild(self): 94 | APIbuild = c_int() 95 | lib.nScope_check_API_build(byref(APIbuild)) 96 | return APIbuild.value 97 | 98 | def checkFWver(self): 99 | FWver = c_double() 100 | lib.nScope_check_FW_version(byref(FWver)) 101 | return FWver.value 102 | 103 | def findFirmwareLoader(self): 104 | lib.nScope_find_firmware_loader() 105 | 106 | def writeToLoader(self): 107 | lib.nScope_write_to_loader() 108 | 109 | def loadFirmware(self): 110 | lib.nScope_load_firmware() 111 | -------------------------------------------------------------------------------- /python/nscopeapi/pulseGenerators.py: -------------------------------------------------------------------------------- 1 | from ctypes import POINTER, c_int, c_bool, c_double 2 | from nscopeapi.nScopeDefs import * 3 | 4 | lib.nScope_set_PX_on.restype = c_int 5 | lib.nScope_set_PX_on.argtypes = [POINTER(scopeDev), c_int, c_bool] 6 | lib.nScope_get_PX_on.restype = c_int 7 | lib.nScope_get_PX_on.argtypes = [POINTER(scopeDev), c_int, POINTER(c_bool)] 8 | 9 | lib.nScope_set_P1_P2_on.restype = c_int 10 | lib.nScope_set_P1_P2_on.argtypes = [POINTER(scopeDev),c_bool,c_bool] 11 | lib.nScope_get_P1_P2_on.restype = c_int 12 | lib.nScope_get_P1_P2_on.argtypes = [POINTER(scopeDev),POINTER(c_bool*2)] 13 | 14 | lib.nScope_set_PX_frequency_in_hz.restype = c_int 15 | lib.nScope_set_PX_frequency_in_hz.argtypes = [POINTER(scopeDev), c_int, c_double] 16 | lib.nScope_get_PX_frequency_in_hz.restype = c_int 17 | lib.nScope_get_PX_frequency_in_hz.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 18 | 19 | lib.nScope_set_P1_P2_frequencies_in_hz.restype = c_int 20 | lib.nScope_set_P1_P2_frequencies_in_hz.argtypes = [POINTER(scopeDev),c_double,c_double] 21 | lib.nScope_get_P1_P2_frequencies_in_hz.restype = c_int 22 | lib.nScope_get_P1_P2_frequencies_in_hz.argtypes = [POINTER(scopeDev),POINTER(c_double*2)] 23 | 24 | lib.nScope_set_PX_period_in_ms.restype = c_int 25 | lib.nScope_set_PX_period_in_ms.argtypes = [POINTER(scopeDev), c_int, c_double] 26 | lib.nScope_get_PX_period_in_ms.restype = c_int 27 | lib.nScope_get_PX_period_in_ms.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 28 | 29 | lib.nScope_set_P1_P2_periods_in_ms.restype = c_int 30 | lib.nScope_set_P1_P2_periods_in_ms.argtypes = [POINTER(scopeDev),c_double,c_double] 31 | lib.nScope_get_P1_P2_periods_in_ms.restype = c_int 32 | lib.nScope_get_P1_P2_periods_in_ms.argtypes = [POINTER(scopeDev),POINTER(c_double*2)] 33 | 34 | lib.nScope_set_PX_period_in_us.restype = c_int 35 | lib.nScope_set_PX_period_in_us.argtypes = [POINTER(scopeDev), c_int, c_double] 36 | lib.nScope_get_PX_period_in_us.restype = c_int 37 | lib.nScope_get_PX_period_in_us.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 38 | 39 | lib.nScope_set_P1_P2_periods_in_us.restype = c_int 40 | lib.nScope_set_P1_P2_periods_in_us.argtypes = [POINTER(scopeDev),c_double,c_double] 41 | lib.nScope_get_P1_P2_periods_in_us.restype = c_int 42 | lib.nScope_get_P1_P2_periods_in_us.argtypes = [POINTER(scopeDev),POINTER(c_double*2)] 43 | 44 | lib.nScope_set_PX_duty_percentage.restype = c_int 45 | lib.nScope_set_PX_duty_percentage.argtypes = [POINTER(scopeDev), c_int, c_double] 46 | lib.nScope_get_PX_duty_percentage.restype = c_int 47 | lib.nScope_get_PX_duty_percentage.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 48 | 49 | lib.nScope_set_P1_P2_duty_percentages.restype = c_int 50 | lib.nScope_set_P1_P2_duty_percentages.argtypes = [POINTER(scopeDev),c_double,c_double] 51 | lib.nScope_get_P1_P2_duty_percentages.restype = c_int 52 | lib.nScope_get_P1_P2_duty_percentages.argtypes = [POINTER(scopeDev),POINTER(c_double*2)] 53 | 54 | lib.nScope_set_PX_pulse_width_in_ms.restype = c_int 55 | lib.nScope_set_PX_pulse_width_in_ms.argtypes = [POINTER(scopeDev), c_int, c_double] 56 | lib.nScope_get_PX_pulse_width_in_ms.restype = c_int 57 | lib.nScope_get_PX_pulse_width_in_ms.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 58 | 59 | lib.nScope_set_P1_P2_pulse_widths_in_ms.restype = c_int 60 | lib.nScope_set_P1_P2_pulse_widths_in_ms.argtypes = [POINTER(scopeDev),c_double,c_double] 61 | lib.nScope_get_P1_P2_pulse_widths_in_ms.restype = c_int 62 | lib.nScope_get_P1_P2_pulse_widths_in_ms.argtypes = [POINTER(scopeDev),POINTER(c_double*2)] 63 | 64 | lib.nScope_set_PX_pulse_width_in_us.restype = c_int 65 | lib.nScope_set_PX_pulse_width_in_us.argtypes = [POINTER(scopeDev), c_int, c_double] 66 | lib.nScope_get_PX_pulse_width_in_us.restype = c_int 67 | lib.nScope_get_PX_pulse_width_in_us.argtypes = [POINTER(scopeDev), c_int, POINTER(c_double)] 68 | 69 | lib.nScope_set_P1_P2_pulse_widths_in_us.restype = c_int 70 | lib.nScope_set_P1_P2_pulse_widths_in_us.argtypes = [POINTER(scopeDev),c_double,c_double] 71 | lib.nScope_get_P1_P2_pulse_widths_in_us.restype = c_int 72 | lib.nScope_get_P1_P2_pulse_widths_in_us.argtypes = [POINTER(scopeDev),POINTER(c_double*2)] 73 | 74 | lib.nScope_send_PX_oneshot_pulse.restype = c_int 75 | lib.nScope_send_PX_oneshot_pulse.argtypes = [POINTER(scopeDev), c_int, c_double] 76 | lib.nScope_send_P1_P2_oneshot_pulses.restype = c_int 77 | lib.nScope_send_P1_P2_oneshot_pulses.argtypes = [POINTER(scopeDev),c_double,c_double] 78 | 79 | # if rtrn == -111: 80 | # raise ValueError("Requested frequency is too fast") 81 | # return 82 | # if rtrn == -110: 83 | # raise ValueError("Requested frequency is too slow") 84 | # return 85 | # return rtrn 86 | # if rtrn == -121: 87 | # raise Warning("Requested pulse width results in always high signal") 88 | # if rtrn == -120: 89 | # raise Warning("Requested pulse width results in always low signal") 90 | # if rtrn == -110: 91 | # raise ValueError("Requested period is too short") 92 | # return 93 | # if rtrn == -111: 94 | # raise ValueError("Requested period is too long") 95 | # return 96 | class Implementation: 97 | def setPXOn(self,px,pxOn): 98 | pxOn = bool(pxOn) 99 | lib.nScope_set_PX_on(self.handle,px,pxOn) 100 | return 101 | 102 | def getPXOn(self,px): 103 | pxOn = c_bool() 104 | lib.nScope_get_PX_on(self.handle,px,byref(pxOn)) 105 | return pxOn.value 106 | 107 | def setP1P2On(self,p1on,p2on): 108 | p1on = bool(p1on) 109 | p2on = bool(p2on) 110 | lib.nScope_set_P1_P2_on(self.handle,p1on,p2on) 111 | return 112 | 113 | def getP1P2On(self): 114 | pxOn = (c_bool*2)() 115 | lib.nScope_get_P1_P2_on(self.handle,byref(pxOn)) 116 | return list(pxOn) 117 | 118 | def setPXFrequencyInHz(self,px,pxFrequency): 119 | lib.nScope_set_PX_frequency_in_hz(self.handle,px,pxFrequency) 120 | return 121 | 122 | def getPXFrequencyInHz(self,px): 123 | pxFrequency = c_double() 124 | lib.nScope_get_PX_frequency_in_hz(self.handle,px,byref(pxFrequency)) 125 | return pxFrequency.value 126 | 127 | def setP1P2FrequenciesInHz(self,p1frequency,p2frequency): 128 | lib.nScope_set_P1_P2_frequencies_in_hz(self.handle,p1frequency,p2frequency) 129 | return 130 | 131 | def getP1P2FrequenciesInHz(self): 132 | pxFrequencies = (c_double*2)() 133 | lib.nScope_get_P1_P2_frequencies_in_hz(self.handle,byref(pxFrequencies)) 134 | return list(pxFrequencies) 135 | 136 | def setPXPeriodInMs(self,px,pxPeriod): 137 | lib.nScope_set_PX_period_in_ms(self.handle,px,pxPeriod) 138 | return 139 | 140 | def getPXPeriodInMs(self,px): 141 | pxPeriod = c_double() 142 | lib.nScope_get_PX_period_in_ms(self.handle,px,byref(pxPeriod)) 143 | return pxPeriod.value 144 | 145 | def setP1P2PeriodsInMs(self,p1period,p2period): 146 | lib.nScope_set_P1_P2_periods_in_ms(self.handle,p1period,p2period) 147 | return 148 | 149 | def getP1P2PeriodsInMs(self): 150 | pxPeriods = (c_double*2)() 151 | lib.nScope_get_P1_P2_periods_in_ms(self.handle,byref(pxPeriods)) 152 | return list(pxPeriods) 153 | 154 | def setPXPeriodInUs(self,px,pxPeriod): 155 | lib.nScope_set_PX_period_in_us(self.handle,px,pxPeriod) 156 | return 157 | 158 | def getPXPeriodInUs(self,px): 159 | pxPeriod = c_double() 160 | lib.nScope_get_PX_period_in_us(self.handle,px,byref(pxPeriod)) 161 | return pxPeriod.value 162 | 163 | def setP1P2PeriodsInUs(self,p1period,p2period): 164 | lib.nScope_set_P1_P2_periods_in_us(self.handle,p1period,p2period) 165 | return 166 | 167 | def getP1P2PeriodsInUs(self): 168 | pxPeriods = (c_double*2)() 169 | lib.nScope_get_P1_P2_periods_in_us(self.handle,byref(pxPeriods)) 170 | return list(pxPeriods) 171 | 172 | def setPXDutyPercentage(self,px,pxDuty): 173 | lib.nScope_set_PX_duty_percentage(self.handle,px,pxDuty) 174 | return 175 | 176 | def getPXDutyPercentage(self,px): 177 | pxDuty = c_double() 178 | lib.nScope_get_PX_duty_percentage(self.handle,px,byref(pxDuty)) 179 | return pxDuty.value 180 | 181 | def setP1P2DutyPercentages(self,p1duty,p2duty): 182 | lib.nScope_set_P1_P2_duty_percentages(self.handle,p1duty,p2duty) 183 | return 184 | 185 | def getP1P2DutyPercentages(self): 186 | pxDuties = (c_double*2)() 187 | lib.nScope_get_P1_P2_duty_percentages(self.handle,byref(pxDuties)) 188 | return list(pxDuties) 189 | 190 | def setPXPulseWidthInMs(self,px,pxPulseWidth): 191 | lib.nScope_set_PX_pulse_width_in_ms(self.handle,px,pxPulseWidth) 192 | return 193 | 194 | def getPXPulseWidthInMs(self,px): 195 | pxPulseWidth = c_double() 196 | lib.nScope_get_PX_pulse_width_in_ms(self.handle,px,byref(pxPulseWidth)) 197 | return pxPulseWidth.value 198 | 199 | def setP1P2PulseWidthsInMs(self,p1pulseWidth,p2pulseWidth): 200 | lib.nScope_set_P1_P2_pulse_widths_in_ms(self.handle,p1pulseWidth,p2pulseWidth) 201 | return 202 | 203 | def getP1P2PulseWidthsInMs(self): 204 | pxPulseWidths = (c_double*2)() 205 | lib.nScope_get_P1_P2_pulse_widths_in_ms(self.handle,byref(pxPulseWidths)) 206 | return list(pxPulseWidths) 207 | 208 | def setPXPulseWidthInUs(self,px,pxPulseWidth): 209 | lib.nScope_set_PX_pulse_width_in_us(self.handle,px,pxPulseWidth) 210 | return 211 | 212 | def getPXPulseWidthInUs(self,px): 213 | pxPulseWidth = c_double() 214 | lib.nScope_get_PX_pulse_width_in_us(self.handle,px,byref(pxPulseWidth)) 215 | return pxPulseWidth.value 216 | 217 | def setP1P2PulseWidthsInUs(self,p1pulseWidth,p2pulseWidth): 218 | lib.nScope_set_P1_P2_pulse_widths_in_us(self.handle,p1pulseWidth,p2pulseWidth) 219 | return 220 | 221 | def getP1P2PulseWidthsInUs(self): 222 | pxPulseWidths = (c_double*2)() 223 | lib.nScope_get_P1_P2_pulse_widths_in_us(self.handle,byref(pxPulseWidths)) 224 | return list(pxPulseWidths) 225 | 226 | def sendPXpulse(self,px,pulseWidth): 227 | lib.nScope_send_PX_oneshot_pulse(self.handle,px,pulseWidth) 228 | return 229 | 230 | def sendP1P2pulses(self,pulseWidth1,pulseWidth2): 231 | lib.nScope_send_P1_P2_oneshot_pulses(self.handle,pulseWidth1,pulseWidth2) 232 | return 233 | -------------------------------------------------------------------------------- /python/nscopeapi/requests.py: -------------------------------------------------------------------------------- 1 | from ctypes import POINTER, c_int, c_bool, c_double 2 | from nscopeapi.nScopeDefs import * 3 | ''' 4 | Requests 5 | ''' 6 | 7 | lib.nScope_request_data.restype = c_int 8 | lib.nScope_request_data.argtypes = [POINTER(scopeDev), POINTER(POINTER(requestObj)), c_int, c_bool] 9 | 10 | # Not yet implemented 11 | # lib.nScope_request_data_stream.restypes = c_int 12 | # lib.nScope_request_data_stream.argtypes = [POINTER(scopeDev), POINTER(POINTER(requestObj))] 13 | 14 | lib.nScope_stop_request.restype = c_int 15 | lib.nScope_stop_request.argtypes = [POINTER(scopeDev), POINTER(requestObj)] 16 | 17 | lib.nScope_release_request.restype = c_int 18 | lib.nScope_release_request.argtpyes = [POINTER(scopeDev), POINTER(POINTER(requestObj))] 19 | 20 | lib.nScope_wait_for_request_finish.restype = c_int 21 | lib.nScope_wait_for_request_finish.argtypes = [POINTER(scopeDev), POINTER(requestObj)] 22 | 23 | lib.nScope_request_xfer_has_completed.restype = c_int 24 | lib.nScope_request_xfer_has_completed.argtypes = [POINTER(scopeDev), POINTER(requestObj), POINTER(c_bool)] 25 | 26 | # Not yet implemented 27 | # lib.nScope_request_xfer_samples_remaining.restype = c_int 28 | # lib.nScope_request_xfer_samples_remaining.argtypes = [POINTER(scopeDev), POINTER(requestObj)] 29 | 30 | # Not yet implemented 31 | # lib.nScope_request_stop_data_stream.restype = c_int 32 | # lib.nScope_request_stop_data_stream.argtypes = [POINTER(scopeDev), POINTER(requestObj)] 33 | 34 | lib.nScope_read_data.restype = c_int 35 | lib.nScope_read_data.argtypes = [POINTER(scopeDev), POINTER(requestObj), c_int, POINTER(c_double)] 36 | 37 | lib.nScope_request_has_data.restype = c_int 38 | lib.nScope_request_has_data.argtypes = [POINTER(scopeDev), POINTER(requestObj), POINTER(c_bool)] 39 | 40 | # if self.request: 41 | # lib.nScope_release_request(self.handle,byref(self.request)) 42 | # self.request = lib.nScope_request_data(self.handle,numsamples,0) 43 | # if not self.request: 44 | # raise ValueError("Invalid request") 45 | # return 46 | 47 | # if rtrn == -106: 48 | # raise ValueError("Invalid request") 49 | # return 50 | # if rtrn == -112: 51 | # raise ValueError("nScope channel does not exist") 52 | # return 53 | # if rtrn == -104: 54 | # raise RuntimeWarning("No more data available") 55 | # return 56 | # if rtrn == -102: 57 | # raise RuntimeWarning("nScope channel was not on during request") 58 | # return 59 | # return rtrn 60 | 61 | 62 | class Implementation: 63 | def requestData(self,numSamples): 64 | lib.nScope_request_data(self.handle,byref(self.request),numSamples,False) 65 | return 66 | 67 | def stopRequest(self): 68 | lib.nScope_stop_request(self.handle,self.request) 69 | return 70 | 71 | def releaseRequest(self): 72 | lib.nScope_release_request(self.handle,byref(self.request)) 73 | return 74 | 75 | def waitForRequestFinish(self): 76 | lib.nScope_wait_for_request_finish(self.handle,self.request) 77 | return 78 | 79 | def requestTransferHasCompleted(self): 80 | hasCompleted = c_bool() 81 | lib.nScope_request_xfer_has_completed(self.handle,self.request,byref(hasCompleted)) 82 | return hasCompleted.value 83 | 84 | def readData(self,channel): 85 | channel = int(channel) 86 | data = c_double() 87 | lib.nScope_read_data(self.handle,self.request,channel,byref(data)) 88 | return data.value 89 | 90 | def requestHasData(self): 91 | hasData = c_bool() 92 | lib.nScope_request_has_data(self.handle,self.request,byref(hasData)) 93 | return hasData.value 94 | -------------------------------------------------------------------------------- /python/nscopeapi/sampleTiming.py: -------------------------------------------------------------------------------- 1 | from ctypes import POINTER, c_int, c_double 2 | from nscopeapi.nScopeDefs import * 3 | 4 | ''' 5 | Sample Timing 6 | ''' 7 | lib.nScope_set_sample_rate_in_hz.restype = c_int 8 | lib.nScope_set_sample_rate_in_hz.argtypes = [POINTER(scopeDev), c_double] 9 | lib.nScope_get_sample_rate_in_hz.restype = c_int 10 | lib.nScope_get_sample_rate_in_hz.argtypes = [POINTER(scopeDev), POINTER(c_double)] 11 | 12 | lib.nScope_set_time_between_samples_in_seconds.restype = c_int 13 | lib.nScope_set_time_between_samples_in_seconds.argtypes = [POINTER(scopeDev), c_double] 14 | lib.nScope_get_time_between_samples_in_seconds.restype = c_int 15 | lib.nScope_get_time_between_samples_in_seconds.argtypes = [POINTER(scopeDev), POINTER(c_double)] 16 | 17 | lib.nScope_set_time_between_samples_in_minutes.restype = c_int 18 | lib.nScope_set_time_between_samples_in_minutes.argtypes = [POINTER(scopeDev), c_double] 19 | lib.nScope_get_time_between_samples_in_minutes.restype = c_int 20 | lib.nScope_get_time_between_samples_in_minutes.argtypes = [POINTER(scopeDev), POINTER(c_double)] 21 | 22 | lib.nScope_set_time_between_samples_in_ms.restype = c_int 23 | lib.nScope_set_time_between_samples_in_ms.argtypes = [POINTER(scopeDev), c_double] 24 | lib.nScope_get_time_between_samples_in_ms.restype = c_int 25 | lib.nScope_get_time_between_samples_in_ms.argtypes = [POINTER(scopeDev), POINTER(c_double)] 26 | 27 | lib.nScope_set_time_between_samples_in_us.restype = c_int 28 | lib.nScope_set_time_between_samples_in_us.argtypes = [POINTER(scopeDev), c_double] 29 | lib.nScope_get_time_between_samples_in_us.restype = c_int 30 | lib.nScope_get_time_between_samples_in_us.argtypes = [POINTER(scopeDev), POINTER(c_double)] 31 | 32 | # if rtrn == -102: 33 | # raise RuntimeError("No scope channels are on") 34 | # return 35 | # if rtrn == -111: 36 | # raise ValueError("Requested sample rate is too fast") 37 | # return 38 | # if rtrn == -110: 39 | # raise ValueError("Requested sample rate is too slow") 40 | # return 41 | # if rtrn == -101: 42 | # raise RuntimeError("nScope is not connected") 43 | # return 44 | 45 | class Implementation: 46 | def setSampleRateInHz(self,sampleRate): 47 | lib.nScope_set_sample_rate_in_hz(self.handle,sampleRate) 48 | return 49 | 50 | def getSampleRateInHz(self): 51 | sampleRate = c_double() 52 | lib.nScope_get_sample_rate_in_hz(self.handle,byref(sampleRate)) 53 | return sampleRate.value 54 | 55 | def setTimeBetweenSamplesInSeconds(self,sampleTime): 56 | lib.nScope_set_time_between_samples_in_seconds(self.handle,sampleTime) 57 | return 58 | 59 | def getTimeBetweenSamplesInSeconds(self): 60 | sampleTime = c_double() 61 | lib.nScope_get_time_between_samples_in_seconds(self.handle,byref(sampleTime)) 62 | return sampleTime.value 63 | 64 | def setTimeBetweenSamplesInMinutes(self,sampleTime): 65 | lib.nScope_set_time_between_samples_in_minutes(self.handle,sampleTime) 66 | return 67 | 68 | def getTimeBetweenSamplesInMinutes(self): 69 | sampleTime = c_double() 70 | lib.nScope_get_time_between_samples_in_minutes(self.handle,byref(sampleTime)) 71 | return sampleTime.value 72 | 73 | def setTimeBetweenSamplesInMs(self,sampleTime): 74 | lib.nScope_set_time_between_samples_in_ms(self.handle,sampleTime) 75 | return 76 | 77 | def getTimeBetweenSamplesInMs(self): 78 | sampleTime = c_double() 79 | lib.nScope_get_time_between_samples_in_ms(self.handle,byref(sampleTime)) 80 | return sampleTime.value 81 | 82 | def setTimeBetweenSamplesInUs(self,sampleTime): 83 | lib.nScope_set_time_between_samples_in_us(self.handle,sampleTime) 84 | return 85 | 86 | def getTimeBetweenSamplesInUs(self): 87 | sampleTime = c_double() 88 | lib.nScope_get_time_between_samples_in_us(self.handle,byref(sampleTime)) 89 | return sampleTime.value 90 | -------------------------------------------------------------------------------- /python/nscopeapi/trigger.py: -------------------------------------------------------------------------------- 1 | from ctypes import POINTER, c_int, c_bool, c_double 2 | from nscopeapi.nScopeDefs import * 3 | 4 | ''' 5 | Trigger 6 | ''' 7 | lib.nScope_set_trigger_on.restype = c_int 8 | lib.nScope_set_trigger_on.argtypes = [POINTER(scopeDev), c_bool] 9 | lib.nScope_get_trigger_on.restype = c_int 10 | lib.nScope_get_trigger_on.argtypes = [POINTER(scopeDev), POINTER(c_bool)] 11 | 12 | lib.nScope_set_trigger_source.restype = c_int 13 | lib.nScope_set_trigger_source.argtypes = [POINTER(scopeDev), c_int] 14 | lib.nScope_get_trigger_source.restype = c_int 15 | lib.nScope_get_trigger_source.argtypes = [POINTER(scopeDev), POINTER(c_int)] 16 | 17 | lib.nScope_set_trigger_edge.restype = c_int 18 | lib.nScope_set_trigger_edge.argtypes = [POINTER(scopeDev), c_int] 19 | lib.nScope_get_trigger_edge.restype = c_int 20 | lib.nScope_get_trigger_edge.argtypes = [POINTER(scopeDev), POINTER(c_int)] 21 | 22 | lib.nScope_set_trigger_level.restype = c_int 23 | lib.nScope_set_trigger_level.argtypes = [POINTER(scopeDev), c_double] 24 | lib.nScope_get_trigger_level.restype = c_int 25 | lib.nScope_get_trigger_level.argtypes = [POINTER(scopeDev), POINTER(c_double)] 26 | 27 | # Not yet implemented 28 | # lib.nScope_set_trigger_delay_ms.restype = c_int 29 | # lib.nScope_set_trigger_delay_ms.argtypes = [POINTER(scopeDev), c_double] 30 | # lib.nScope_get_trigger_delay_ms.restype = c_int 31 | # lib.nScope_get_trigger_delay_ms.argtypes = [POINTER(scopeDev), POINTER(c_double)] 32 | # 33 | # lib.nScope_set_trigger_delay_us.restype = c_int 34 | # lib.nScope_set_trigger_delay_us.argtypes = [POINTER(scopeDev), c_double] 35 | # lib.nScope_get_trigger_delay_us.restype = c_int 36 | # lib.nScope_get_trigger_delay_us.argtypes = [POINTER(scopeDev), POINTER(c_double)] 37 | 38 | class Implementation: 39 | def setTriggerOn(self,triggerOn): 40 | chOn = bool(chOn) 41 | lib.nScope_set_trigger_on(self.handle,triggerOn) 42 | return 43 | 44 | def getTriggerOn(self): 45 | triggerOn = c_bool() 46 | lib.nScope_get_trigger_on(self.handle,byref(triggerOn)) 47 | return chOn.value 48 | 49 | def setTriggerSource(self,triggerSource): 50 | triggerSource = int(triggerSource) 51 | lib.nScope_set_trigger_source(self.handle,triggerSource) 52 | return 53 | 54 | def getTriggerSource(self): 55 | triggerSource = c_int() 56 | lib.nScope_get_trigger_source(self.handle,byref(triggerSource)) 57 | return triggerSource.value 58 | 59 | def setTriggerEdge(self,triggerEdge): 60 | triggerEdge = int(triggerEdge) 61 | lib.nScope_set_trigger_edge(self.handle,triggerEdge) 62 | return 63 | 64 | def getTriggerEdge(self): 65 | triggerEdge = c_int() 66 | lib.nScope_get_trigger_edge(self.handle,byref(triggerEdge)) 67 | return triggerEdge.value 68 | 69 | def setTriggerLevel(self,triggerLevel): 70 | lib.nScope_set_trigger_level(self.handle,triggerLevel) 71 | return 72 | 73 | def getTriggerLevel(self): 74 | triggerLevel = c_double() 75 | lib.nScope_get_trigger_level(self.handle,byref(triggerLevel)) 76 | return triggerLevel.value 77 | 78 | # def setTimeBetweenSamplesInMs(self,sampleTime): 79 | # lib.nScope_set_time_between_samples_in_ms(self.handle,sampleTime) 80 | # return 81 | # 82 | # def getTimeBetweenSamplesInMs(self): 83 | # sampleTime = c_double() 84 | # lib.nScope_get_time_between_samples_in_ms(self.handle,byref(sampleTime)) 85 | # return sampleTime.value 86 | # 87 | # def setTimeBetweenSamplesInUs(self,sampleTime): 88 | # lib.nScope_set_time_between_samples_in_us(self.handle,sampleTime) 89 | # return 90 | # 91 | # def getTimeBetweenSamplesInUs(self): 92 | # sampleTime = c_double() 93 | # lib.nScope_get_time_between_samples_in_us(self.handle,byref(sampleTime)) 94 | # return sampleTime.value 95 | -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='nscopeapi', 4 | version='0.8', 5 | description='Python API for using nScope', 6 | url='http://github.com/nLabs-nScope/nScopeAPI', 7 | author='David Meyer', 8 | author_email='contact@nscope.org', 9 | packages=['nscopeapi'], 10 | include_package_data=True, 11 | zip_safe=False) 12 | -------------------------------------------------------------------------------- /python/testConnection.py: -------------------------------------------------------------------------------- 1 | try: 2 | import nscopeapi as nsapi 3 | ns = nsapi.nScope() 4 | except Exception as e: 5 | print("Unable to communicate with nScope") 6 | print(e) 7 | else: 8 | print("Successfully opened connection to nScope!") --------------------------------------------------------------------------------