def close(self): if self.handle is not None: log_and_warn_on_error( sensel.stopScanning(self.handle), 'stop scanning before close for {}'.format(self.serial_num)) log_and_warn_on_error( sensel.freeFrameData(self.handle, self.frame), 'free frame data before close for {}'.format(self.serial_num)) log_and_warn_on_error( sensel.close(self.handle), 'close handle for {} ({})'.format(self.serial_num, self.handle)) self.handle = None else: logger.debug( 'Attempt to close Morph {} with None handle (already closed?)'. format(self.serial_num))
def closeSensel(frame): error = sensel.freeFrameData(handle, frame) error = sensel.stopScanning(handle) error = sensel.close(handle)
# The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. ########################################################################## import sensel import binascii if __name__ == "__main__": handle = None (error, device_list) = sensel.getDeviceList() if device_list.num_devices != 0: (error, handle) = sensel.openDeviceByID(device_list.devices[0].idx) if handle != None: (error, info) = sensel.getSensorInfo(handle) print "\nSensel Device: " + str( bytearray(device_list.devices[0].serial_num)) print "Width: " + str(info.width) + "mm" print "Height: " + str(info.height) + "mm" print "Cols: " + str(info.num_cols) print "Rows: " + str(info.num_rows) error = sensel.close(handle)
def _closeSensel(self): self.is_running = False error = sensel.freeFrameData(self.handle, self._frame) error = sensel.stopScanning(self.handle) error = sensel.close(self.handle)