<s> """<STR_LIT>""" <EOL> import platform <EOL> import ctypes <EOL> import os , atexit <EOL> import math <EOL> from time import time <EOL> import struct <EOL> WINDOWS = "<STR_LIT>" <EOL> ON_WINDOWS = ( os . name == '<STR_LIT>' ) <EOL> class U12Exception ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class BitField ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , rawByte = None , labelPrefix = "<STR_LIT>" , labelList = None , zeroLabel = "<STR_LIT:0>" , oneLabel = "<STR_LIT:1>" ) : <EOL> """<STR_LIT>""" <EOL> self . __dict__ [ '<STR_LIT>' ] = [ ] <EOL> self . labelPrefix = labelPrefix <EOL> if labelList is None : <EOL> self . labelList = list ( range ( <NUM_LIT:8> ) ) <EOL> else : <EOL> self . labelList = list ( reversed ( labelList ) ) <EOL> self . zeroLabel = zeroLabel <EOL> self . oneLabel = oneLabel <EOL> self . rawValue = <NUM_LIT:0> <EOL> self . rawBits = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> self . data = [ self . zeroLabel ] * <NUM_LIT:8> <EOL> items = min ( <NUM_LIT:8> , len ( self . labelList ) ) <EOL> for i in reversed ( list ( range ( items ) ) ) : <EOL> self . labels . append ( "<STR_LIT>" % ( self . labelPrefix , self . labelList [ i ] ) ) <EOL> if rawByte is not None : <EOL> self . fromByte ( rawByte ) <EOL> def fromByte ( self , raw ) : <EOL> """<STR_LIT>""" <EOL> self . rawValue = raw <EOL> self . rawBits = [ ] <EOL> self . data = [ ] <EOL> items = min ( <NUM_LIT:8> , len ( self . labelList ) ) <EOL> for i in reversed ( list ( range ( items ) ) ) : <EOL> self . rawBits . append ( ( ( raw >> ( i ) ) & <NUM_LIT:1> ) ) <EOL> self . data . append ( self . oneLabel if bool ( ( ( raw >> ( i ) ) & <NUM_LIT:1> ) ) else self . zeroLabel ) <EOL> def asByte ( self ) : <EOL> """<STR_LIT>""" <EOL> byteVal = <NUM_LIT:0> <EOL> for i , v in enumerate ( reversed ( self . rawBits ) ) : <EOL> byteVal += ( <NUM_LIT:1> << i ) * v <EOL> return byteVal <EOL> def asBin ( self ) : <EOL> result = "<STR_LIT>" <EOL> for i in self . rawBits : <EOL> result += "<STR_LIT:%s>" % i <EOL> return result <EOL> def __len__ ( self ) : <EOL> return len ( self . data ) <EOL> def __repr__ ( self ) : <EOL> result = "<STR_LIT:[>" <EOL> for i in range ( len ( self . data ) ) : <EOL> result += "<STR_LIT>" % ( self . labels [ i ] , self . data [ i ] , self . rawBits [ i ] ) <EOL> result = result . rstrip ( '<STR_LIT:U+002C>' ) <EOL> result += "<STR_LIT>" <EOL> return "<STR_LIT>" % result <EOL> def __str__ ( self ) : <EOL> result = "<STR_LIT:[>" <EOL> for i in range ( len ( self . data ) ) : <EOL> result += "<STR_LIT>" % ( self . labels [ i ] , self . data [ i ] ) <EOL> result = result . rstrip ( '<STR_LIT:U+002C>' ) <EOL> result += "<STR_LIT>" <EOL> return result <EOL> def __getattr__ ( self , label ) : <EOL> try : <EOL> i = self . labels . index ( label ) <EOL> return self . rawBits [ i ] <EOL> except ValueError : <EOL> raise AttributeError ( label ) <EOL> def __setattr__ ( self , label , value ) : <EOL> try : <EOL> i = self . labels . index ( label ) <EOL> self . rawBits [ i ] = int ( bool ( value ) ) <EOL> self . data [ i ] = self . oneLabel if bool ( value ) else self . zeroLabel <EOL> except ValueError : <EOL> self . __dict__ [ label ] = value <EOL> def __getitem__ ( self , key ) : <EOL> return self . rawBits [ key ] <EOL> def __setitem__ ( self , key , value ) : <EOL> self . rawBits [ key ] = int ( bool ( value ) ) <EOL> self . data [ key ] = self . oneLabel if bool ( value ) else self . zeroLabel <EOL> def __iter__ ( self ) : <EOL> return iter ( self . rawBits ) <EOL> def items ( self ) : <EOL> """<STR_LIT>""" <EOL> return list ( zip ( self . labels , self . data ) ) <EOL> def __int__ ( self ) : <EOL> return self . asByte ( ) <EOL> def __hex__ ( self ) : <EOL> return hex ( self . asByte ( ) ) <EOL> def __add__ ( self , other ) : <EOL> """<STR_LIT>""" <EOL> return other + self . asByte ( ) <EOL> def errcheck ( ret , func , args ) : <EOL> if ret == - <NUM_LIT:1> : <EOL> try : <EOL> ec = ctypes . get_errno ( ) <EOL> raise U12Exception ( "<STR_LIT>" % ec ) <EOL> except AttributeError : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> else : <EOL> return ret <EOL> def _loadLinuxSo ( ) : <EOL> try : <EOL> l = ctypes . CDLL ( "<STR_LIT>" , use_errno = True ) <EOL> except TypeError : <EOL> l = ctypes . CDLL ( "<STR_LIT>" ) <EOL> l . LJUSB_Stream . errcheck = errcheck <EOL> l . LJUSB_Read . errcheck = errcheck <EOL> return l <EOL> def _loadMacDylib ( ) : <EOL> try : <EOL> l = ctypes . CDLL ( "<STR_LIT>" , use_errno = True ) <EOL> except TypeError : <EOL> l = ctypes . CDLL ( "<STR_LIT>" ) <EOL> l . LJUSB_Stream . errcheck = errcheck <EOL> l . LJUSB_Read . errcheck = errcheck <EOL> return l <EOL> staticLib = None <EOL> if os . name == '<STR_LIT>' : <EOL> try : <EOL> staticLib = _loadLinuxSo ( ) <EOL> except OSError as e : <EOL> pass <EOL> except Exception as e : <EOL> raise U12Exception ( "<STR_LIT>" % e ) <EOL> try : <EOL> if staticLib is None : <EOL> staticLib = _loadMacDylib ( ) <EOL> except OSError as e : <EOL> raise U12Exception ( "<STR_LIT>" % e ) <EOL> except Exception as e : <EOL> raise U12Exception ( "<STR_LIT>" % e ) <EOL> else : <EOL> try : <EOL> staticLib = ctypes . windll . LoadLibrary ( "<STR_LIT>" ) <EOL> except : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> class U12 ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , id = - <NUM_LIT:1> , serialNumber = None , debug = False ) : <EOL> self . id = id <EOL> self . serialNumber = serialNumber <EOL> self . deviceName = "<STR_LIT>" <EOL> self . streaming = False <EOL> self . handle = None <EOL> self . debug = debug <EOL> self . _autoCloseSetup = False <EOL> if not ON_WINDOWS : <EOL> self . pwmAVoltage = <NUM_LIT:0> <EOL> self . pwmBVoltage = <NUM_LIT:0> <EOL> self . open ( id , serialNumber ) <EOL> def open ( self , id = - <NUM_LIT:1> , serialNumber = None ) : <EOL> """<STR_LIT>""" <EOL> if ON_WINDOWS : <EOL> pass <EOL> else : <EOL> if self . debug : print ( "<STR_LIT>" ) <EOL> devType = ctypes . c_ulong ( <NUM_LIT:1> ) <EOL> openDev = staticLib . LJUSB_OpenDevice <EOL> openDev . restype = ctypes . c_void_p <EOL> if serialNumber is not None : <EOL> numDevices = staticLib . LJUSB_GetDevCount ( devType ) <EOL> for i in range ( numDevices ) : <EOL> handle = openDev ( i + <NUM_LIT:1> , <NUM_LIT:0> , devType ) <EOL> if handle != <NUM_LIT:0> and handle is not None : <EOL> self . handle = ctypes . c_void_p ( handle ) <EOL> try : <EOL> serial = self . rawReadSerial ( ) <EOL> except Exception : <EOL> serial = self . rawReadSerial ( ) <EOL> if serial == int ( serialNumber ) : <EOL> break <EOL> else : <EOL> self . close ( ) <EOL> if self . handle is None : <EOL> raise U12Exception ( "<STR_LIT>" % serialNumber ) <EOL> elif id != - <NUM_LIT:1> : <EOL> numDevices = staticLib . LJUSB_GetDevCount ( devType ) <EOL> for i in range ( numDevices ) : <EOL> handle = openDev ( i + <NUM_LIT:1> , <NUM_LIT:0> , devType ) <EOL> if handle != <NUM_LIT:0> and handle is not None : <EOL> self . handle = ctypes . c_void_p ( handle ) <EOL> try : <EOL> unitId = self . rawReadLocalId ( ) <EOL> except Exception : <EOL> unitId = self . rawReadLocalId ( ) <EOL> if unitId == int ( id ) : <EOL> break <EOL> else : <EOL> self . close ( ) <EOL> if self . handle is None : <EOL> raise U12Exception ( "<STR_LIT>" % id ) <EOL> elif id == - <NUM_LIT:1> : <EOL> handle = openDev ( <NUM_LIT:1> , <NUM_LIT:0> , devType ) <EOL> if handle == <NUM_LIT:0> or handle is None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> else : <EOL> self . handle = ctypes . c_void_p ( handle ) <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:5> ] = <NUM_LIT> <EOL> try : <EOL> self . write ( command ) <EOL> self . read ( ) <EOL> except : <EOL> pass <EOL> self . id = self . rawReadLocalId ( ) <EOL> else : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if not self . _autoCloseSetup : <EOL> atexit . register ( self . close ) <EOL> self . _autoCloseSetup = True <EOL> def close ( self ) : <EOL> if ON_WINDOWS : <EOL> pass <EOL> else : <EOL> staticLib . LJUSB_CloseDevice ( self . handle ) <EOL> self . handle = None <EOL> def write ( self , writeBuffer ) : <EOL> if ON_WINDOWS : <EOL> pass <EOL> else : <EOL> if self . handle is None : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> if self . debug : print ( "<STR_LIT>" , hexWithoutQuotes ( writeBuffer ) ) <EOL> newA = ( ctypes . c_byte * len ( writeBuffer ) ) ( <NUM_LIT:0> ) <EOL> for i in range ( len ( writeBuffer ) ) : <EOL> newA [ i ] = ctypes . c_byte ( writeBuffer [ i ] ) <EOL> writeBytes = staticLib . LJUSB_Write ( self . handle , ctypes . byref ( newA ) , len ( writeBuffer ) ) <EOL> if ( writeBytes != len ( writeBuffer ) ) : <EOL> raise U12Exception ( "<STR_LIT>" % ( writeBytes , len ( writeBuffer ) ) ) <EOL> return writeBuffer <EOL> def read ( self , numBytes = <NUM_LIT:8> ) : <EOL> if ON_WINDOWS : <EOL> pass <EOL> else : <EOL> if self . handle is None : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> newA = ( ctypes . c_byte * numBytes ) ( ) <EOL> readBytes = staticLib . LJUSB_Read ( self . handle , ctypes . byref ( newA ) , numBytes ) <EOL> result = [ ( newA [ i ] & <NUM_LIT> ) for i in range ( readBytes ) ] <EOL> if self . debug : print ( "<STR_LIT>" , hexWithoutQuotes ( result ) ) <EOL> return result <EOL> def rawReadSerial ( self ) : <EOL> """<STR_LIT>""" <EOL> results = self . rawReadRAM ( ) <EOL> return struct . unpack ( "<STR_LIT>" , struct . pack ( "<STR_LIT>" , results [ '<STR_LIT>' ] , results [ '<STR_LIT>' ] , results [ '<STR_LIT>' ] , results [ '<STR_LIT>' ] ) ) [ <NUM_LIT:0> ] <EOL> def rawReadLocalId ( self ) : <EOL> """<STR_LIT>""" <EOL> results = self . rawReadRAM ( <NUM_LIT> ) <EOL> return results [ '<STR_LIT>' ] <EOL> def rawAISample ( self , channel0PGAMUX = <NUM_LIT:8> , channel1PGAMUX = <NUM_LIT:9> , channel2PGAMUX = <NUM_LIT:10> , channel3PGAMUX = <NUM_LIT:11> , UpdateIO = False , LEDState = True , IO3toIO0States = <NUM_LIT:0> , EchoValue = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = int ( channel0PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:0> ] & <NUM_LIT:7> <EOL> channel0Number = tempNum if ( command [ <NUM_LIT:0> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel0Gain = ( command [ <NUM_LIT:0> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:1> ] = int ( channel1PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:1> ] & <NUM_LIT:7> <EOL> channel1Number = tempNum if ( command [ <NUM_LIT:1> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel1Gain = ( command [ <NUM_LIT:1> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:2> ] = int ( channel2PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:2> ] & <NUM_LIT:7> <EOL> channel2Number = tempNum if ( command [ <NUM_LIT:2> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel2Gain = ( command [ <NUM_LIT:2> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:3> ] = int ( channel3PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:3> ] & <NUM_LIT:7> <EOL> channel3Number = tempNum if ( command [ <NUM_LIT:3> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel3Gain = ( command [ <NUM_LIT:3> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> bf = BitField ( ) <EOL> bf . bit1 = int ( UpdateIO ) <EOL> bf . bit0 = int ( LEDState ) <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf . fromByte ( <NUM_LIT:0> ) <EOL> bf . bit7 = <NUM_LIT:1> <EOL> bf . bit6 = <NUM_LIT:1> <EOL> bf . fromByte ( int ( bf ) | int ( IO3toIO0States ) ) <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> command [ <NUM_LIT:7> ] = EchoValue <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> bf = BitField ( ) <EOL> bf . fromByte ( results [ <NUM_LIT:0> ] ) <EOL> if bf . bit7 != <NUM_LIT:1> or bf . bit6 != <NUM_LIT:0> : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:0> ] ) <EOL> returnDict = { } <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] <EOL> returnDict [ '<STR_LIT>' ] = bool ( bf . bit4 ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:0> ] , "<STR_LIT>" , list ( range ( <NUM_LIT:3> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> channel0 = ( results [ <NUM_LIT:2> ] >> <NUM_LIT:4> ) & <NUM_LIT> <EOL> channel1 = ( results [ <NUM_LIT:2> ] & <NUM_LIT> ) <EOL> channel2 = ( results [ <NUM_LIT:5> ] >> <NUM_LIT:4> ) & <NUM_LIT> <EOL> channel3 = ( results [ <NUM_LIT:5> ] & <NUM_LIT> ) <EOL> channel0 = ( channel0 << <NUM_LIT:8> ) + results [ <NUM_LIT:3> ] <EOL> returnDict [ '<STR_LIT>' ] = self . bitsToVolts ( channel0Number , channel0Gain , channel0 ) <EOL> channel1 = ( channel1 << <NUM_LIT:8> ) + results [ <NUM_LIT:4> ] <EOL> returnDict [ '<STR_LIT>' ] = self . bitsToVolts ( channel1Number , channel1Gain , channel1 ) <EOL> channel2 = ( channel2 << <NUM_LIT:8> ) + results [ <NUM_LIT:6> ] <EOL> returnDict [ '<STR_LIT>' ] = self . bitsToVolts ( channel2Number , channel2Gain , channel2 ) <EOL> channel3 = ( channel3 << <NUM_LIT:8> ) + results [ <NUM_LIT:7> ] <EOL> returnDict [ '<STR_LIT>' ] = self . bitsToVolts ( channel3Number , channel3Gain , channel3 ) <EOL> return returnDict <EOL> def rawDIO ( self , D15toD8Directions = <NUM_LIT:0> , D7toD0Directions = <NUM_LIT:0> , D15toD8States = <NUM_LIT:0> , D7toD0States = <NUM_LIT:0> , IO3toIO0DirectionsAndStates = <NUM_LIT:0> , UpdateDigital = False ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = int ( D15toD8Directions ) <EOL> command [ <NUM_LIT:1> ] = int ( D7toD0Directions ) <EOL> command [ <NUM_LIT:2> ] = int ( D15toD8States ) <EOL> command [ <NUM_LIT:3> ] = int ( D7toD0States ) <EOL> command [ <NUM_LIT:4> ] = int ( IO3toIO0DirectionsAndStates ) <EOL> command [ <NUM_LIT:5> ] = <NUM_LIT> <EOL> command [ <NUM_LIT:6> ] = int ( bool ( UpdateDigital ) ) <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> returnDict = { } <EOL> if results [ <NUM_LIT:0> ] != <NUM_LIT> : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:0> ] ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:1> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:15> , <NUM_LIT:7> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:2> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:7> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:4> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:15> , <NUM_LIT:7> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:5> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:7> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:6> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:15> , <NUM_LIT:7> , - <NUM_LIT:1> ) ) ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:7> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:7> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( ( results [ <NUM_LIT:3> ] >> <NUM_LIT:4> ) , "<STR_LIT>" , list ( range ( <NUM_LIT:3> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> return returnDict <EOL> def rawCounter ( self , StrobeEnabled = False , ResetCounter = False ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> bf = BitField ( ) <EOL> bf . bit1 = int ( StrobeEnabled ) <EOL> bf . bit0 = int ( ResetCounter ) <EOL> command [ <NUM_LIT:0> ] = int ( bf ) <EOL> bf . fromByte ( <NUM_LIT:0> ) <EOL> bf . bit6 = <NUM_LIT:1> <EOL> bf . bit4 = <NUM_LIT:1> <EOL> bf . bit1 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> returnDict = { } <EOL> if results [ <NUM_LIT:0> ] != command [ <NUM_LIT:5> ] : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:0> ] ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:1> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:15> , <NUM_LIT:7> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:2> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:7> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( ( results [ <NUM_LIT:3> ] >> <NUM_LIT:4> ) , "<STR_LIT>" , list ( range ( <NUM_LIT:3> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> counter = results [ <NUM_LIT:7> ] <EOL> counter += results [ <NUM_LIT:6> ] << <NUM_LIT:8> <EOL> counter += results [ <NUM_LIT:5> ] << <NUM_LIT:16> <EOL> counter += results [ <NUM_LIT:4> ] << <NUM_LIT> <EOL> returnDict [ '<STR_LIT>' ] = counter <EOL> return returnDict <EOL> def rawCounterPWMDIO ( self , D15toD8Directions = <NUM_LIT:0> , D7toD0Directions = <NUM_LIT:0> , D15toD8States = <NUM_LIT:0> , D7toD0States = <NUM_LIT:0> , IO3toIO0DirectionsAndStates = <NUM_LIT:0> , ResetCounter = False , UpdateDigital = <NUM_LIT:0> , PWMA = <NUM_LIT:0> , PWMB = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = int ( D15toD8Directions ) <EOL> command [ <NUM_LIT:1> ] = int ( D7toD0Directions ) <EOL> command [ <NUM_LIT:2> ] = int ( D15toD8States ) <EOL> command [ <NUM_LIT:3> ] = int ( D7toD0States ) <EOL> command [ <NUM_LIT:4> ] = int ( IO3toIO0DirectionsAndStates ) <EOL> bf = BitField ( ) <EOL> bf . bit5 = int ( ResetCounter ) <EOL> bf . bit4 = int ( UpdateDigital ) <EOL> binPWMA = int ( ( <NUM_LIT> * ( float ( PWMA ) / <NUM_LIT> ) ) ) <EOL> binPWMB = int ( ( <NUM_LIT> * ( float ( PWMB ) / <NUM_LIT> ) ) ) <EOL> bf2 = BitField ( ) <EOL> bf2 . fromByte ( binPWMA & <NUM_LIT:3> ) <EOL> bf . bit3 = bf2 . bit1 <EOL> bf . bit2 = bf2 . bit0 <EOL> bf2 . fromByte ( binPWMB & <NUM_LIT:3> ) <EOL> bf . bit1 = bf2 . bit1 <EOL> bf . bit0 = bf2 . bit0 <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> command [ <NUM_LIT:6> ] = ( binPWMA >> <NUM_LIT:2> ) & <NUM_LIT> <EOL> command [ <NUM_LIT:7> ] = ( binPWMB >> <NUM_LIT:2> ) & <NUM_LIT> <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> returnDict = { } <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:1> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:15> , <NUM_LIT:7> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( results [ <NUM_LIT:2> ] , "<STR_LIT:D>" , list ( range ( <NUM_LIT:7> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> returnDict [ '<STR_LIT>' ] = BitField ( ( results [ <NUM_LIT:3> ] >> <NUM_LIT:4> ) , "<STR_LIT>" , list ( range ( <NUM_LIT:3> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> counter = results [ <NUM_LIT:7> ] <EOL> counter += results [ <NUM_LIT:6> ] << <NUM_LIT:8> <EOL> counter += results [ <NUM_LIT:5> ] << <NUM_LIT:16> <EOL> counter += results [ <NUM_LIT:4> ] << <NUM_LIT> <EOL> returnDict [ '<STR_LIT>' ] = counter <EOL> return returnDict <EOL> def rawAIBurst ( self , channel0PGAMUX = <NUM_LIT:8> , channel1PGAMUX = <NUM_LIT:9> , channel2PGAMUX = <NUM_LIT:10> , channel3PGAMUX = <NUM_LIT:11> , NumberOfScans = <NUM_LIT:8> , TriggerIONum = <NUM_LIT:0> , TriggerState = <NUM_LIT:0> , UpdateIO = False , LEDState = True , IO3ToIO0States = <NUM_LIT:0> , FeatureReports = False , TriggerOn = False , SampleInterval = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = int ( channel0PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:0> ] & <NUM_LIT:7> <EOL> channel0Number = tempNum if ( command [ <NUM_LIT:0> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel0Gain = ( command [ <NUM_LIT:0> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:1> ] = int ( channel1PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:1> ] & <NUM_LIT:7> <EOL> channel1Number = tempNum if ( command [ <NUM_LIT:1> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel1Gain = ( command [ <NUM_LIT:1> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:2> ] = int ( channel2PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:2> ] & <NUM_LIT:7> <EOL> channel2Number = tempNum if ( command [ <NUM_LIT:2> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel2Gain = ( command [ <NUM_LIT:2> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:3> ] = int ( channel3PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:3> ] & <NUM_LIT:7> <EOL> channel3Number = tempNum if ( command [ <NUM_LIT:3> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel3Gain = ( command [ <NUM_LIT:3> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> if NumberOfScans > <NUM_LIT> or NumberOfScans < <NUM_LIT:8> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> NumScansExponentMod = <NUM_LIT:10> - int ( math . ceil ( math . log ( NumberOfScans , <NUM_LIT:2> ) ) ) <EOL> NumScans = <NUM_LIT:2> ** ( <NUM_LIT:10> - NumScansExponentMod ) <EOL> bf = BitField ( rawByte = ( NumScansExponentMod << <NUM_LIT:5> ) ) <EOL> bf . bit2 = <NUM_LIT:0> <EOL> bf . bit1 = int ( bool ( UpdateIO ) ) <EOL> bf . bit0 = int ( bool ( LEDState ) ) <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf2 = BitField ( rawByte = int ( IO3ToIO0States ) ) <EOL> bf2 . bit7 = <NUM_LIT:1> <EOL> bf2 . bit5 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf2 ) <EOL> if SampleInterval < <NUM_LIT> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> bf3 = BitField ( rawByte = ( ( SampleInterval >> <NUM_LIT:8> ) & <NUM_LIT> ) ) <EOL> bf3 . bit7 = int ( bool ( FeatureReports ) ) <EOL> bf3 . bit6 = int ( bool ( TriggerOn ) ) <EOL> command [ <NUM_LIT:6> ] = int ( bf3 ) <EOL> command [ <NUM_LIT:7> ] = SampleInterval & <NUM_LIT> <EOL> self . write ( command ) <EOL> resultsList = [ ] <EOL> for i in range ( NumScans ) : <EOL> resultsList . append ( self . read ( ) ) <EOL> returnDict = { } <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> returnDict [ '<STR_LIT>' ] = list ( ) <EOL> for results in resultsList : <EOL> bf = BitField ( rawByte = results [ <NUM_LIT:0> ] ) <EOL> if bf . bit7 != <NUM_LIT:1> or bf . bit6 != <NUM_LIT:0> : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:0> ] ) <EOL> returnDict [ '<STR_LIT>' ] . append ( bool ( bf . bit5 ) ) <EOL> returnDict [ '<STR_LIT>' ] . append ( bool ( bf . bit4 ) ) <EOL> returnDict [ '<STR_LIT>' ] . append ( BitField ( results [ <NUM_LIT:0> ] , "<STR_LIT>" , list ( range ( <NUM_LIT:3> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> returnDict [ '<STR_LIT>' ] . append ( ( results [ <NUM_LIT:1> ] >> <NUM_LIT:5> ) ) <EOL> returnDict [ '<STR_LIT>' ] . append ( results [ <NUM_LIT:1> ] & <NUM_LIT> ) <EOL> channel0 = ( results [ <NUM_LIT:2> ] >> <NUM_LIT:4> ) & <NUM_LIT> <EOL> channel1 = ( results [ <NUM_LIT:2> ] & <NUM_LIT> ) <EOL> channel2 = ( results [ <NUM_LIT:5> ] >> <NUM_LIT:4> ) & <NUM_LIT> <EOL> channel3 = ( results [ <NUM_LIT:5> ] & <NUM_LIT> ) <EOL> channel0 = ( channel0 << <NUM_LIT:8> ) + results [ <NUM_LIT:3> ] <EOL> returnDict [ '<STR_LIT>' ] . append ( self . bitsToVolts ( channel0Number , channel0Gain , channel0 ) ) <EOL> channel1 = ( channel1 << <NUM_LIT:8> ) + results [ <NUM_LIT:4> ] <EOL> returnDict [ '<STR_LIT>' ] . append ( self . bitsToVolts ( channel1Number , channel1Gain , channel1 ) ) <EOL> channel2 = ( channel2 << <NUM_LIT:8> ) + results [ <NUM_LIT:6> ] <EOL> returnDict [ '<STR_LIT>' ] . append ( self . bitsToVolts ( channel2Number , channel2Gain , channel2 ) ) <EOL> channel3 = ( channel3 << <NUM_LIT:8> ) + results [ <NUM_LIT:7> ] <EOL> returnDict [ '<STR_LIT>' ] . append ( self . bitsToVolts ( channel3Number , channel3Gain , channel3 ) ) <EOL> return returnDict <EOL> def rawAIContinuous ( self , channel0PGAMUX = <NUM_LIT:8> , channel1PGAMUX = <NUM_LIT:9> , channel2PGAMUX = <NUM_LIT:10> , channel3PGAMUX = <NUM_LIT:11> , FeatureReports = False , CounterRead = False , UpdateIO = False , LEDState = True , IO3ToIO0States = <NUM_LIT:0> , SampleInterval = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = int ( channel0PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:0> ] & <NUM_LIT:7> <EOL> channel0Number = tempNum if ( command [ <NUM_LIT:0> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel0Gain = ( command [ <NUM_LIT:0> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:1> ] = int ( channel1PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:1> ] & <NUM_LIT:7> <EOL> channel1Number = tempNum if ( command [ <NUM_LIT:1> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel1Gain = ( command [ <NUM_LIT:1> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:2> ] = int ( channel2PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:2> ] & <NUM_LIT:7> <EOL> channel2Number = tempNum if ( command [ <NUM_LIT:2> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel2Gain = ( command [ <NUM_LIT:2> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> command [ <NUM_LIT:3> ] = int ( channel3PGAMUX ) <EOL> tempNum = command [ <NUM_LIT:3> ] & <NUM_LIT:7> <EOL> channel3Number = tempNum if ( command [ <NUM_LIT:3> ] & <NUM_LIT> ) > <NUM_LIT:7> else tempNum + <NUM_LIT:8> <EOL> channel3Gain = ( command [ <NUM_LIT:3> ] >> <NUM_LIT:4> ) & <NUM_LIT:7> <EOL> bf = BitField ( ) <EOL> bf . bit7 = int ( bool ( FeatureReports ) ) <EOL> bf . bit6 = int ( bool ( CounterRead ) ) <EOL> bf . bit1 = int ( bool ( UpdateIO ) ) <EOL> bf . bit0 = int ( bool ( LEDState ) ) <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf2 = BitField ( rawByte = int ( IO3ToIO0States ) ) <EOL> bf2 . bit7 = <NUM_LIT:1> <EOL> bf2 . bit4 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf2 ) <EOL> command [ <NUM_LIT:6> ] = ( SampleInterval >> <NUM_LIT:8> ) <EOL> command [ <NUM_LIT:7> ] = SampleInterval & <NUM_LIT> <EOL> byte0bf = BitField ( ) <EOL> returnDict = dict ( ) <EOL> self . write ( command ) <EOL> while True : <EOL> results = self . read ( ) <EOL> byte0bf . fromByte ( results [ <NUM_LIT:0> ] ) <EOL> returnDict [ '<STR_LIT>' ] = byte0bf <EOL> returnDict [ '<STR_LIT>' ] = ( results [ <NUM_LIT:1> ] >> <NUM_LIT:5> ) <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] & <NUM_LIT> <EOL> yield returnDict <EOL> def rawPulseout ( self , B1 = <NUM_LIT:10> , C1 = <NUM_LIT:2> , B2 = <NUM_LIT:10> , C2 = <NUM_LIT:2> , D7ToD0PulseSelection = <NUM_LIT:1> , ClearFirst = False , NumberOfPulses = <NUM_LIT:5> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = B1 <EOL> command [ <NUM_LIT:1> ] = C1 <EOL> command [ <NUM_LIT:2> ] = B2 <EOL> command [ <NUM_LIT:3> ] = C2 <EOL> command [ <NUM_LIT:4> ] = int ( D7ToD0PulseSelection ) <EOL> bf = BitField ( ) <EOL> bf . bit6 = <NUM_LIT:1> <EOL> bf . bit5 = <NUM_LIT:1> <EOL> bf . bit2 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> bf2 = BitField ( rawByte = ( NumberOfPulses >> <NUM_LIT:8> ) ) <EOL> bf2 . bit7 = int ( bool ( ClearFirst ) ) <EOL> command [ <NUM_LIT:6> ] = int ( bf2 ) <EOL> command [ <NUM_LIT:7> ] = NumberOfPulses & <NUM_LIT> <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> if command [ <NUM_LIT:5> ] != results [ <NUM_LIT:5> ] : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:5> ] ) <EOL> if results [ <NUM_LIT:4> ] != <NUM_LIT:0> : <EOL> errors = BitField ( rawByte = command [ <NUM_LIT:4> ] , labelPrefix = "<STR_LIT:D>" , zeroLabel = "<STR_LIT>" , oneLabel = "<STR_LIT>" ) <EOL> raise U12Exception ( "<STR_LIT>" % errors ) <EOL> return None <EOL> def rawReset ( self ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> bf = BitField ( ) <EOL> bf . bit6 = <NUM_LIT:1> <EOL> bf . bit4 = <NUM_LIT:1> <EOL> bf . bit3 = <NUM_LIT:1> <EOL> bf . bit2 = <NUM_LIT:1> <EOL> bf . bit1 = <NUM_LIT:1> <EOL> bf . bit0 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> self . write ( command ) <EOL> self . close ( ) <EOL> def rawReenumerate ( self ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> bf = BitField ( ) <EOL> bf . bit6 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> self . write ( command ) <EOL> self . close ( ) <EOL> def rawWatchdog ( self , IgnoreCommands = False , D0Active = False , D0State = False , D1Active = False , D1State = False , D8Active = False , D8State = False , ResetOnTimeout = False , WatchdogActive = False , Timeout = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> command [ <NUM_LIT:0> ] = int ( bool ( IgnoreCommands ) ) <EOL> bf = BitField ( ) <EOL> bf . bit7 = int ( D0Active ) <EOL> bf . bit6 = int ( D0State ) <EOL> bf . bit5 = int ( D1Active ) <EOL> bf . bit4 = int ( D1State ) <EOL> bf . bit3 = int ( D8Active ) <EOL> bf . bit2 = int ( D8State ) <EOL> bf . bit1 = int ( ResetOnTimeout ) <EOL> bf . bit0 = int ( WatchdogActive ) <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf2 = BitField ( ) <EOL> bf2 . bit6 = <NUM_LIT:1> <EOL> bf2 . bit4 = <NUM_LIT:1> <EOL> bf2 . bit1 = <NUM_LIT:1> <EOL> bf2 . bit0 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf2 ) <EOL> binTimeout = int ( ( float ( Timeout ) / <NUM_LIT> ) ) <EOL> command [ <NUM_LIT:6> ] = ( binTimeout >> <NUM_LIT:8> ) & <NUM_LIT> <EOL> command [ <NUM_LIT:7> ] = binTimeout & <NUM_LIT> <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> returnDict = dict ( ) <EOL> returnDict [ '<STR_LIT>' ] = "<STR_LIT>" % ( results [ <NUM_LIT:0> ] , results [ <NUM_LIT:1> ] ) <EOL> return returnDict <EOL> def rawReadRAM ( self , Address = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> bf = BitField ( ) <EOL> bf . bit6 = <NUM_LIT:1> <EOL> bf . bit4 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> command [ <NUM_LIT:6> ] = ( Address >> <NUM_LIT:8> ) & <NUM_LIT> <EOL> command [ <NUM_LIT:7> ] = Address & <NUM_LIT> <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> if results [ <NUM_LIT:0> ] != int ( bf ) : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:0> ] ) <EOL> if ( results [ <NUM_LIT:6> ] != command [ <NUM_LIT:6> ] ) or ( results [ <NUM_LIT:7> ] != command [ <NUM_LIT:7> ] ) : <EOL> receivedAddress = ( results [ <NUM_LIT:6> ] << <NUM_LIT:8> ) + results [ <NUM_LIT:7> ] <EOL> raise U12Exception ( "<STR_LIT>" % ( Address , receivedAddress ) ) <EOL> returnDict = dict ( ) <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:2> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:3> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:4> ] <EOL> return returnDict <EOL> def rawWriteRAM ( self , Data , Address ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> if not isinstance ( Data , list ) or len ( Data ) > <NUM_LIT:4> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> Data . reverse ( ) <EOL> command [ : len ( Data ) ] = Data <EOL> bf = BitField ( ) <EOL> bf . bit6 = <NUM_LIT:1> <EOL> bf . bit4 = <NUM_LIT:1> <EOL> bf . bit0 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf ) <EOL> command [ <NUM_LIT:6> ] = ( Address >> <NUM_LIT:8> ) & <NUM_LIT> <EOL> command [ <NUM_LIT:7> ] = Address & <NUM_LIT> <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> if results [ <NUM_LIT:0> ] != int ( bf ) : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:0> ] ) <EOL> if ( results [ <NUM_LIT:6> ] != command [ <NUM_LIT:6> ] ) or ( results [ <NUM_LIT:7> ] != command [ <NUM_LIT:7> ] ) : <EOL> receivedAddress = ( results [ <NUM_LIT:6> ] << <NUM_LIT:8> ) + results [ <NUM_LIT:7> ] <EOL> raise U12Exception ( "<STR_LIT>" % ( Address , receivedAddress ) ) <EOL> returnDict = dict ( ) <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:2> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:3> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:4> ] <EOL> return returnDict <EOL> def rawAsynch ( self , Data , AddDelay = False , TimeoutActive = False , SetTransmitEnable = False , PortB = False , NumberOfBytesToWrite = <NUM_LIT:0> , NumberOfBytesToRead = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> if not isinstance ( Data , list ) or len ( Data ) > <NUM_LIT:4> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> NumberOfBytesToWrite = NumberOfBytesToRead & <NUM_LIT> <EOL> NumberOfBytesToRead = NumberOfBytesToRead & <NUM_LIT> <EOL> if NumberOfBytesToWrite > <NUM_LIT> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> if NumberOfBytesToRead > <NUM_LIT> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> Data . reverse ( ) <EOL> command [ : len ( Data ) ] = Data <EOL> bf = BitField ( ) <EOL> bf . bit3 = int ( bool ( AddDelay ) ) <EOL> bf . bit2 = int ( bool ( TimeoutActive ) ) <EOL> bf . bit1 = int ( bool ( SetTransmitEnable ) ) <EOL> bf . bit0 = int ( bool ( PortB ) ) <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf2 = BitField ( ) <EOL> bf2 . bit6 = <NUM_LIT:1> <EOL> bf2 . bit5 = <NUM_LIT:1> <EOL> bf2 . bit0 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf2 ) <EOL> command [ <NUM_LIT:6> ] = NumberOfBytesToWrite <EOL> command [ <NUM_LIT:7> ] = NumberOfBytesToRead <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> if command [ <NUM_LIT:5> ] != results [ <NUM_LIT:5> ] : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:5> ] ) <EOL> returnDict = dict ( ) <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:0> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:2> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:3> ] <EOL> bfLabels = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> bf = BitField ( rawByte = results [ <NUM_LIT:4> ] , labelPrefix = "<STR_LIT>" , labelList = bfLabels ) <EOL> returnDict [ "<STR_LIT>" ] = bf <EOL> return returnDict <EOL> SPIModes = [ '<STR_LIT:A>' , '<STR_LIT:B>' , '<STR_LIT:C>' , '<STR_LIT:D>' ] <EOL> def rawSPI ( self , Data , AddMsDelay = False , AddHundredUsDelay = False , SPIMode = '<STR_LIT:A>' , NumberOfBytesToWriteRead = <NUM_LIT:0> , ControlCS = False , StateOfActiveCS = False , CSLineNumber = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> if not isinstance ( Data , list ) or len ( Data ) > <NUM_LIT:4> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> NumberOfBytesToWriteRead = NumberOfBytesToWriteRead & <NUM_LIT> <EOL> if NumberOfBytesToWriteRead == <NUM_LIT:0> : <EOL> NumberOfBytesToWriteRead = len ( Data ) <EOL> if NumberOfBytesToWriteRead > <NUM_LIT> or NumberOfBytesToWriteRead < <NUM_LIT:1> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> Data . reverse ( ) <EOL> command [ : len ( Data ) ] = Data <EOL> bf = BitField ( ) <EOL> bf . bit7 = int ( bool ( AddMsDelay ) ) <EOL> bf . bit6 = int ( bool ( AddHundredUsDelay ) ) <EOL> modeIndex = self . SPIModes . index ( SPIMode ) <EOL> bf [ <NUM_LIT:7> - modeIndex ] = <NUM_LIT:1> <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf2 = BitField ( ) <EOL> bf2 . bit6 = <NUM_LIT:1> <EOL> bf2 . bit5 = <NUM_LIT:1> <EOL> bf2 . bit1 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf2 ) <EOL> command [ <NUM_LIT:6> ] = NumberOfBytesToWriteRead <EOL> bf3 = BitField ( rawByte = CSLineNumber ) <EOL> bf3 . bit7 = int ( bool ( ControlCS ) ) <EOL> bf3 . bit6 = int ( bool ( StateOfActiveCS ) ) <EOL> command [ <NUM_LIT:7> ] = int ( bf3 ) <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> if results [ <NUM_LIT:5> ] != command [ <NUM_LIT:5> ] : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:5> ] ) <EOL> returnDict = dict ( ) <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:0> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:2> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:3> ] <EOL> bfLabels = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> bf = BitField ( rawByte = results [ <NUM_LIT:4> ] , labelPrefix = "<STR_LIT>" , labelList = bfLabels ) <EOL> returnDict [ "<STR_LIT>" ] = bf <EOL> return returnDict <EOL> def rawSHT1X ( self , Data = [ <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , WaitForMeasurementReady = True , IssueSerialReset = False , Add1MsDelay = False , Add300UsDelay = False , IO3State = <NUM_LIT:1> , IO2State = <NUM_LIT:1> , IO3Direction = <NUM_LIT:1> , IO2Direction = <NUM_LIT:1> , NumberOfBytesToWrite = <NUM_LIT:1> , NumberOfBytesToRead = <NUM_LIT:3> ) : <EOL> """<STR_LIT>""" <EOL> command = [ <NUM_LIT:0> ] * <NUM_LIT:8> <EOL> if NumberOfBytesToWrite != <NUM_LIT:0> : <EOL> if not isinstance ( Data , list ) or len ( Data ) > <NUM_LIT:4> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> Data . reverse ( ) <EOL> command [ : len ( Data ) ] = Data <EOL> if max ( NumberOfBytesToWrite , NumberOfBytesToRead ) > <NUM_LIT:4> : <EOL> raise U12Exception ( "<STR_LIT>" ) <EOL> bf = BitField ( ) <EOL> bf . bit7 = int ( bool ( WaitForMeasurementReady ) ) <EOL> bf . bit6 = int ( bool ( IssueSerialReset ) ) <EOL> bf . bit5 = int ( bool ( Add1MsDelay ) ) <EOL> bf . bit4 = int ( bool ( Add300UsDelay ) ) <EOL> bf . bit3 = int ( bool ( IO3State ) ) <EOL> bf . bit2 = int ( bool ( IO2State ) ) <EOL> bf . bit1 = int ( bool ( IO3Direction ) ) <EOL> bf . bit0 = int ( bool ( IO2Direction ) ) <EOL> command [ <NUM_LIT:4> ] = int ( bf ) <EOL> bf2 = BitField ( ) <EOL> bf2 . bit6 = <NUM_LIT:1> <EOL> bf2 . bit5 = <NUM_LIT:1> <EOL> bf2 . bit3 = <NUM_LIT:1> <EOL> command [ <NUM_LIT:5> ] = int ( bf2 ) <EOL> command [ <NUM_LIT:6> ] = NumberOfBytesToWrite <EOL> command [ <NUM_LIT:7> ] = NumberOfBytesToRead <EOL> self . write ( command ) <EOL> results = self . read ( ) <EOL> if results [ <NUM_LIT:5> ] != command [ <NUM_LIT:5> ] : <EOL> raise U12Exception ( "<STR_LIT>" % results [ <NUM_LIT:5> ] ) <EOL> returnDict = dict ( ) <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:0> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:1> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:2> ] <EOL> returnDict [ '<STR_LIT>' ] = results [ <NUM_LIT:3> ] <EOL> bfLabels = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> bf = BitField ( rawByte = results [ <NUM_LIT:4> ] , labelPrefix = "<STR_LIT>" , labelList = bfLabels ) <EOL> returnDict [ "<STR_LIT>" ] = bf <EOL> return returnDict <EOL> def eAnalogIn ( self , channel , idNum = None , demo = <NUM_LIT:0> , gain = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> if ON_WINDOWS : <EOL> ljid = ctypes . c_long ( idNum ) <EOL> ad0 = ctypes . c_long ( <NUM_LIT> ) <EOL> ad1 = ctypes . c_float ( <NUM_LIT> ) <EOL> ecode = staticLib . EAnalogIn ( ctypes . byref ( ljid ) , demo , channel , gain , ctypes . byref ( ad0 ) , ctypes . byref ( ad1 ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : ljid . value , "<STR_LIT>" : ad0 . value , "<STR_LIT>" : ad1 . value } <EOL> else : <EOL> channel0PGAMUX = ( ( gain & <NUM_LIT:7> ) << <NUM_LIT:4> ) <EOL> channel0PGAMUX += channel - <NUM_LIT:8> if channel > <NUM_LIT:7> else channel + <NUM_LIT:8> <EOL> results = self . rawAISample ( channel0PGAMUX = channel0PGAMUX ) <EOL> return { "<STR_LIT>" : self . id , "<STR_LIT>" : int ( results [ '<STR_LIT>' ] ) , '<STR_LIT>' : results [ '<STR_LIT>' ] } <EOL> def eAnalogOut ( self , analogOut0 , analogOut1 , idNum = None , demo = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> if ON_WINDOWS : <EOL> ljid = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . EAnalogOut ( ctypes . byref ( ljid ) , demo , ctypes . c_float ( analogOut0 ) , ctypes . c_float ( analogOut1 ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : ljid . value } <EOL> else : <EOL> if analogOut0 < <NUM_LIT:0> : <EOL> analogOut0 = self . pwmAVoltage <EOL> if analogOut1 < <NUM_LIT:0> : <EOL> analogOut1 = self . pwmBVoltage <EOL> self . rawCounterPWMDIO ( PWMA = analogOut0 , PWMB = analogOut1 ) <EOL> self . pwmAVoltage = analogOut0 <EOL> self . pwmBVoltage = analogOut1 <EOL> return { "<STR_LIT>" : self . id } <EOL> def eCount ( self , idNum = None , demo = <NUM_LIT:0> , resetCounter = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> if ON_WINDOWS : <EOL> ljid = ctypes . c_long ( idNum ) <EOL> count = ctypes . c_double ( ) <EOL> ms = ctypes . c_double ( ) <EOL> ecode = staticLib . ECount ( ctypes . byref ( ljid ) , demo , resetCounter , ctypes . byref ( count ) , ctypes . byref ( ms ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : ljid . value , "<STR_LIT:count>" : count . value , "<STR_LIT>" : ms . value } <EOL> else : <EOL> results = self . rawCounter ( ResetCounter = resetCounter ) <EOL> return { "<STR_LIT>" : self . id , "<STR_LIT:count>" : results [ '<STR_LIT>' ] , "<STR_LIT>" : ( time ( ) * <NUM_LIT:1000> ) } <EOL> def eDigitalIn ( self , channel , idNum = None , demo = <NUM_LIT:0> , readD = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> if ON_WINDOWS : <EOL> ljid = ctypes . c_long ( idNum ) <EOL> state = ctypes . c_long ( <NUM_LIT> ) <EOL> ecode = staticLib . EDigitalIn ( ctypes . byref ( ljid ) , demo , channel , readD , ctypes . byref ( state ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : ljid . value , "<STR_LIT:state>" : state . value } <EOL> else : <EOL> oldstate = self . rawDIO ( ) <EOL> if readD : <EOL> if channel > <NUM_LIT:7> : <EOL> channel = channel - <NUM_LIT:8> <EOL> direction = BitField ( rawByte = int ( oldstate [ '<STR_LIT>' ] ) ) <EOL> direction [ <NUM_LIT:7> - channel ] = <NUM_LIT:1> <EOL> results = self . rawDIO ( D15toD8Directions = direction , UpdateDigital = True ) <EOL> state = results [ '<STR_LIT>' ] [ <NUM_LIT:7> - channel ] <EOL> else : <EOL> direction = BitField ( rawByte = int ( oldstate [ '<STR_LIT>' ] ) ) <EOL> direction [ <NUM_LIT:7> - channel ] = <NUM_LIT:1> <EOL> results = self . rawDIO ( D7toD0Directions = direction , UpdateDigital = True ) <EOL> state = results [ '<STR_LIT>' ] [ <NUM_LIT:7> - channel ] <EOL> else : <EOL> results = self . rawDIO ( IO3toIO0DirectionsAndStates = <NUM_LIT:255> , UpdateDigital = True ) <EOL> state = results [ '<STR_LIT>' ] [ <NUM_LIT:3> - channel ] <EOL> return { "<STR_LIT>" : self . id , "<STR_LIT:state>" : state } <EOL> def eDigitalOut ( self , channel , state , idNum = None , demo = <NUM_LIT:0> , writeD = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> if ON_WINDOWS : <EOL> ljid = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . EDigitalOut ( ctypes . byref ( ljid ) , demo , channel , writeD , state ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : ljid . value } <EOL> else : <EOL> oldstate = self . rawDIO ( ) <EOL> if writeD : <EOL> if channel > <NUM_LIT:7> : <EOL> channel = channel - <NUM_LIT:8> <EOL> direction = BitField ( rawByte = int ( oldstate [ '<STR_LIT>' ] ) ) <EOL> direction [ <NUM_LIT:7> - channel ] = <NUM_LIT:0> <EOL> states = BitField ( rawByte = int ( oldstate [ '<STR_LIT>' ] ) ) <EOL> states [ <NUM_LIT:7> - channel ] = state <EOL> self . rawDIO ( D15toD8Directions = direction , D15toD8States = states , UpdateDigital = True ) <EOL> else : <EOL> direction = BitField ( rawByte = int ( oldstate [ '<STR_LIT>' ] ) ) <EOL> direction [ <NUM_LIT:7> - channel ] = <NUM_LIT:0> <EOL> states = BitField ( rawByte = int ( oldstate [ '<STR_LIT>' ] ) ) <EOL> states [ <NUM_LIT:7> - channel ] = state <EOL> self . rawDIO ( D7toD0Directions = direction , D7toD0States = states , UpdateDigital = True ) <EOL> else : <EOL> bf = BitField ( ) <EOL> bf [ <NUM_LIT:7> - ( channel + <NUM_LIT:4> ) ] = <NUM_LIT:0> <EOL> bf [ <NUM_LIT:7> - channel ] = state <EOL> self . rawDIO ( IO3toIO0DirectionsAndStates = bf , UpdateDigital = True ) <EOL> return { "<STR_LIT>" : self . id } <EOL> def aiSample ( self , numChannels , channels , idNum = None , demo = <NUM_LIT:0> , stateIOin = <NUM_LIT:0> , updateIO = <NUM_LIT:0> , ledOn = <NUM_LIT:0> , gains = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , disableCal = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if not isIterable ( channels ) : raise TypeError ( "<STR_LIT>" ) <EOL> if not isIterable ( gains ) : raise TypeError ( "<STR_LIT>" ) <EOL> if len ( channels ) < numChannels : raise ValueError ( "<STR_LIT>" ) <EOL> if len ( gains ) < numChannels : raise ValueError ( "<STR_LIT>" ) <EOL> channelsArray = listToCArray ( channels , ctypes . c_long ) <EOL> gainsArray = listToCArray ( gains , ctypes . c_long ) <EOL> overVoltage = ctypes . c_long ( <NUM_LIT> ) <EOL> longArrayType = ( ctypes . c_long * <NUM_LIT:4> ) <EOL> floatArrayType = ( ctypes . c_float * <NUM_LIT:4> ) <EOL> voltages = floatArrayType ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> stateIOin = ctypes . c_long ( stateIOin ) <EOL> ecode = staticLib . AISample ( ctypes . byref ( idNum ) , demo , ctypes . byref ( stateIOin ) , updateIO , ledOn , numChannels , ctypes . byref ( channelsArray ) , ctypes . byref ( gainsArray ) , disableCal , ctypes . byref ( overVoltage ) , ctypes . byref ( voltages ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : stateIOin . value , "<STR_LIT>" : overVoltage . value , "<STR_LIT>" : voltages [ <NUM_LIT:0> : numChannels ] } <EOL> def aiBurst ( self , numChannels , channels , scanRate , numScans , idNum = None , demo = <NUM_LIT:0> , stateIOin = <NUM_LIT:0> , updateIO = <NUM_LIT:0> , ledOn = <NUM_LIT:0> , gains = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , disableCal = <NUM_LIT:0> , triggerIO = <NUM_LIT:0> , triggerState = <NUM_LIT:0> , timeout = <NUM_LIT:1> , transferMode = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if len ( channels ) < numChannels : raise ValueError ( "<STR_LIT>" ) <EOL> if len ( gains ) < numChannels : raise ValueError ( "<STR_LIT>" ) <EOL> channelsArray = listToCArray ( channels , ctypes . c_long ) <EOL> gainsArray = listToCArray ( gains , ctypes . c_long ) <EOL> scanRate = ctypes . c_float ( scanRate ) <EOL> pointerArray = ( ctypes . c_void_p * <NUM_LIT:4> ) <EOL> arr4096_type = ctypes . c_float * <NUM_LIT> <EOL> voltages_type = arr4096_type * <NUM_LIT:4> <EOL> voltages = voltages_type ( ) <EOL> stateIOout = ( ctypes . c_long * <NUM_LIT> ) ( ) <EOL> overVoltage = ctypes . c_long ( <NUM_LIT> ) <EOL> ecode = staticLib . AIBurst ( ctypes . byref ( idNum ) , demo , stateIOin , updateIO , ledOn , numChannels , ctypes . byref ( channelsArray ) , ctypes . byref ( gainsArray ) , ctypes . byref ( scanRate ) , disableCal , triggerIO , triggerState , numScans , timeout , ctypes . byref ( voltages ) , ctypes . byref ( stateIOout ) , ctypes . byref ( overVoltage ) , transferMode ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : scanRate . value , "<STR_LIT>" : voltages , "<STR_LIT>" : stateIOout , "<STR_LIT>" : overVoltage . value } <EOL> def aiStreamStart ( self , numChannels , channels , scanRate , idNum = None , demo = <NUM_LIT:0> , stateIOin = <NUM_LIT:0> , updateIO = <NUM_LIT:0> , ledOn = <NUM_LIT:0> , gains = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , disableCal = <NUM_LIT:0> , readCount = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> staticLib . AIStreamStart . restype = ctypes . c_long <EOL> if len ( channels ) < numChannels : raise ValueError ( "<STR_LIT>" ) <EOL> if len ( gains ) < numChannels : raise ValueError ( "<STR_LIT>" ) <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> channelsArray = listToCArray ( channels , ctypes . c_long ) <EOL> gainsArray = listToCArray ( gains , ctypes . c_long ) <EOL> scanRate = ctypes . c_float ( scanRate ) <EOL> ecode = staticLib . AIStreamStart ( ctypes . byref ( idNum ) , demo , stateIOin , updateIO , ledOn , numChannels , ctypes . byref ( channelsArray ) , ctypes . byref ( gainsArray ) , ctypes . byref ( scanRate ) , disableCal , <NUM_LIT:0> , readCount ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> self . id = idNum . value <EOL> self . streaming = True <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : scanRate . value } <EOL> def aiStreamRead ( self , numScans , localID = None , timeout = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> if not self . streaming : <EOL> raise U12Exception ( - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> if localID is None : <EOL> localID = self . id <EOL> arr4096_type = ctypes . c_float * <NUM_LIT> <EOL> voltages_type = arr4096_type * <NUM_LIT:4> <EOL> voltages = voltages_type ( ) <EOL> stateIOout = ( ctypes . c_long * <NUM_LIT> ) ( ) <EOL> reserved = ctypes . c_long ( <NUM_LIT:0> ) <EOL> ljScanBacklog = ctypes . c_long ( <NUM_LIT> ) <EOL> overVoltage = ctypes . c_long ( <NUM_LIT> ) <EOL> ecode = staticLib . AIStreamRead ( localID , numScans , timeout , ctypes . byref ( voltages ) , ctypes . byref ( stateIOout ) , ctypes . byref ( reserved ) , ctypes . byref ( ljScanBacklog ) , ctypes . byref ( overVoltage ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : voltages , "<STR_LIT>" : stateIOout , "<STR_LIT>" : reserved . value , "<STR_LIT>" : ljScanBacklog . value , "<STR_LIT>" : overVoltage . value } <EOL> def aiStreamClear ( self , localID = None ) : <EOL> """<STR_LIT>""" <EOL> if not self . streaming : <EOL> raise U12Exception ( - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> if localID is None : <EOL> localID = self . id <EOL> ecode = staticLib . AIStreamClear ( localID ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> def aoUpdate ( self , idNum = None , demo = <NUM_LIT:0> , trisD = None , trisIO = None , stateD = None , stateIO = None , updateDigital = <NUM_LIT:0> , resetCounter = <NUM_LIT:0> , analogOut0 = <NUM_LIT:0> , analogOut1 = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if updateDigital > <NUM_LIT:0> : <EOL> if trisD is None : raise ValueError ( "<STR_LIT>" ) <EOL> if trisIO is None : raise ValueError ( "<STR_LIT>" ) <EOL> if stateD is None : raise ValueError ( "<STR_LIT>" ) <EOL> if stateIO is None : raise ValueError ( "<STR_LIT>" ) <EOL> if stateD is None : stateD = ctypes . c_long ( <NUM_LIT:0> ) <EOL> else : stateD = ctypes . c_long ( stateD ) <EOL> if stateIO is None : stateIO = ctypes . c_long ( <NUM_LIT:0> ) <EOL> else : stateIO = ctypes . c_long ( stateIO ) <EOL> count = ctypes . c_ushort ( <NUM_LIT> ) <EOL> ecode = staticLib . AOUpdate ( ctypes . byref ( idNum ) , demo , trisD , trisIO , ctypes . byref ( stateD ) , ctypes . byref ( stateIO ) , updateDigital , resetCounter , ctypes . byref ( count ) , ctypes . c_float ( analogOut0 ) , ctypes . c_float ( analogOut1 ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : stateD . value , "<STR_LIT>" : stateIO . value , "<STR_LIT:count>" : count . value } <EOL> def asynchConfig ( self , fullA , fullB , fullC , halfA , halfB , halfC , idNum = None , demo = None , timeoutMult = <NUM_LIT:1> , configA = <NUM_LIT:0> , configB = <NUM_LIT:0> , configTE = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . AsynchConfig ( ctypes . byref ( idNum ) , demo , timeoutMult , configA , configB , configTE , fullA , fullB , fullC , halfA , halfB , halfC ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def asynch ( self , baudrate , data , idNum = None , demo = <NUM_LIT:0> , portB = <NUM_LIT:0> , enableTE = <NUM_LIT:0> , enableTO = <NUM_LIT:0> , enableDel = <NUM_LIT:0> , numWrite = <NUM_LIT:0> , numRead = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if len ( data ) > <NUM_LIT> : raise ValueError ( "<STR_LIT>" ) <EOL> dataArray = [ <NUM_LIT:0> ] * <NUM_LIT> <EOL> for i in range ( <NUM_LIT:0> , len ( data ) ) : <EOL> dataArray [ i ] = data [ i ] <EOL> print ( dataArray ) <EOL> dataArray = listToCArray ( dataArray , ctypes . c_long ) <EOL> ecode = staticLib . Asynch ( ctypes . byref ( idNum ) , demo , portB , enableTE , enableTO , enableDel , baudrate , numWrite , numRead , ctypes . byref ( dataArray ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : int , "<STR_LIT:data>" : dataArray } <EOL> GainMapping = [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> def bitsToVolts ( self , chnum , chgain , bits ) : <EOL> """<STR_LIT>""" <EOL> if ON_WINDOWS : <EOL> volts = ctypes . c_float ( ) <EOL> ecode = staticLib . BitsToVolts ( chnum , chgain , bits , ctypes . byref ( volts ) ) <EOL> if ecode != <NUM_LIT:0> : print ( ecode ) <EOL> return volts . value <EOL> else : <EOL> if chnum < <NUM_LIT:8> : <EOL> return ( float ( bits ) * <NUM_LIT> / <NUM_LIT> ) - <NUM_LIT> <EOL> else : <EOL> volts = ( float ( bits ) * <NUM_LIT> / <NUM_LIT> ) - <NUM_LIT> <EOL> return volts / self . GainMapping [ chgain ] <EOL> def voltsToBits ( self , chnum , chgain , volts ) : <EOL> """<STR_LIT>""" <EOL> if ON_WINDOWS : <EOL> bits = ctypes . c_long ( <NUM_LIT> ) <EOL> ecode = staticLib . VoltsToBits ( chnum , chgain , ctypes . c_float ( volts ) , ctypes . byref ( bits ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return bits . value <EOL> else : <EOL> pass <EOL> def counter ( self , idNum = None , demo = <NUM_LIT:0> , resetCounter = <NUM_LIT:0> , enableSTB = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> stateD = ctypes . c_long ( <NUM_LIT> ) <EOL> stateIO = ctypes . c_long ( <NUM_LIT> ) <EOL> count = ctypes . c_ulong ( <NUM_LIT> ) <EOL> print ( idNum ) <EOL> ecode = staticLib . Counter ( ctypes . byref ( idNum ) , demo , ctypes . byref ( stateD ) , ctypes . byref ( stateIO ) , resetCounter , enableSTB , ctypes . byref ( count ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : stateD . value , "<STR_LIT>" : stateIO . value , "<STR_LIT:count>" : count . value } <EOL> def digitalIO ( self , idNum = None , demo = <NUM_LIT:0> , trisD = None , trisIO = None , stateD = None , stateIO = None , updateDigital = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if updateDigital > <NUM_LIT:0> : <EOL> if trisD is None : raise ValueError ( "<STR_LIT>" ) <EOL> if trisIO is None : raise ValueError ( "<STR_LIT>" ) <EOL> if stateD is None : raise ValueError ( "<STR_LIT>" ) <EOL> if stateIO is None : raise ValueError ( "<STR_LIT>" ) <EOL> if trisD is None : trisD = ctypes . c_long ( <NUM_LIT> ) <EOL> else : trisD = ctypes . c_long ( trisD ) <EOL> if stateD is None : stateD = ctypes . c_long ( <NUM_LIT> ) <EOL> else : stateD = ctypes . c_long ( stateD ) <EOL> if stateIO is None : stateIO = ctypes . c_long ( <NUM_LIT:0> ) <EOL> else : stateIO = ctypes . c_long ( stateIO ) <EOL> outputD = ctypes . c_long ( <NUM_LIT> ) <EOL> if trisIO is None : trisIO = <NUM_LIT:0> <EOL> ecode = staticLib . DigitalIO ( ctypes . byref ( idNum ) , demo , ctypes . byref ( trisD ) , trisIO , ctypes . byref ( stateD ) , ctypes . byref ( stateIO ) , updateDigital , ctypes . byref ( outputD ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : trisD . value , "<STR_LIT>" : stateD . value , "<STR_LIT>" : stateIO . value , "<STR_LIT>" : outputD . value } <EOL> def getDriverVersion ( self ) : <EOL> """<STR_LIT>""" <EOL> staticLib . GetDriverVersion . restype = ctypes . c_float <EOL> return staticLib . GetDriverVersion ( ) <EOL> def getFirmwareVersion ( self , idNum = None ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> staticLib . GetFirmwareVersion . restype = ctypes . c_float <EOL> firmware = staticLib . GetFirmwareVersion ( ctypes . byref ( idNum ) ) <EOL> if firmware > <NUM_LIT> : raise U12Exception ( firmware - <NUM_LIT> ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : firmware } <EOL> def getWinVersion ( self ) : <EOL> """<STR_LIT>""" <EOL> majorVersion = ctypes . c_ulong ( ) <EOL> minorVersion = ctypes . c_ulong ( ) <EOL> buildNumber = ctypes . c_ulong ( ) <EOL> platformID = ctypes . c_ulong ( ) <EOL> servicePackMajor = ctypes . c_ulong ( ) <EOL> servicePackMinor = ctypes . c_ulong ( ) <EOL> ecode = staticLib . GetWinVersion ( ctypes . byref ( majorVersion ) , ctypes . byref ( minorVersion ) , ctypes . byref ( buildNumber ) , ctypes . byref ( platformID ) , ctypes . byref ( servicePackMajor ) , ctypes . byref ( servicePackMinor ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : majorVersion . value , "<STR_LIT>" : minorVersion . value , "<STR_LIT>" : buildNumber . value , "<STR_LIT>" : platformID . value , "<STR_LIT>" : servicePackMajor . value , "<STR_LIT>" : servicePackMinor . value } <EOL> def listAll ( self ) : <EOL> """<STR_LIT>""" <EOL> productIDList = listToCArray ( [ <NUM_LIT:0> ] * <NUM_LIT> , ctypes . c_long ) <EOL> serialnumList = listToCArray ( [ <NUM_LIT:0> ] * <NUM_LIT> , ctypes . c_long ) <EOL> localIDList = listToCArray ( [ <NUM_LIT:0> ] * <NUM_LIT> , ctypes . c_long ) <EOL> powerList = listToCArray ( [ <NUM_LIT:0> ] * <NUM_LIT> , ctypes . c_long ) <EOL> arr127_type = ctypes . c_long * <NUM_LIT> <EOL> calMatrix_type = arr127_type * <NUM_LIT:20> <EOL> calMatrix = calMatrix_type ( ) <EOL> reserved = ctypes . c_long ( ) <EOL> numberFound = ctypes . c_long ( ) <EOL> ecode = staticLib . ListAll ( ctypes . byref ( productIDList ) , ctypes . byref ( serialnumList ) , ctypes . byref ( localIDList ) , ctypes . byref ( powerList ) , ctypes . byref ( calMatrix ) , ctypes . byref ( numberFound ) , ctypes . byref ( reserved ) , ctypes . byref ( reserved ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : serialnumList , "<STR_LIT>" : localIDList , "<STR_LIT>" : numberFound . value } <EOL> def localID ( self , localID , idNum = None ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . LocalID ( ctypes . byref ( idNum ) , localID ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def noThread ( self , noThread , idNum = None ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . NoThread ( ctypes . byref ( idNum ) , noThread ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def pulseOut ( self , bitSelect , numPulses , timeB1 , timeC1 , timeB2 , timeC2 , idNum = None , demo = <NUM_LIT:0> , lowFirst = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . PulseOut ( ctypes . byref ( idNum ) , demo , lowFirst , bitSelect , numPulses , timeB1 , timeC1 , timeB2 , timeC2 ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def pulseOutStart ( self , bitSelect , numPulses , timeB1 , timeC1 , timeB2 , timeC2 , idNum = None , demo = <NUM_LIT:0> , lowFirst = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . PulseOutStart ( ctypes . byref ( idNum ) , demo , lowFirst , bitSelect , numPulses , timeB1 , timeC1 , timeB2 , timeC2 ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def pulseOutFinish ( self , timeoutMS , idNum = None , demo = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . PulseOutFinish ( ctypes . byref ( idNum ) , demo , timeoutMS ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def pulseOutCalc ( self , frequency ) : <EOL> """<STR_LIT>""" <EOL> frequency = ctypes . c_float ( frequency ) <EOL> timeB = ctypes . c_long ( <NUM_LIT:0> ) <EOL> timeC = ctypes . c_long ( <NUM_LIT:0> ) <EOL> ecode = staticLib . PulseOutCalc ( ctypes . byref ( frequency ) , ctypes . byref ( timeB ) , ctypes . byref ( timeC ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : frequency . value , "<STR_LIT>" : timeB . value , "<STR_LIT>" : timeC . value } <EOL> def reEnum ( self , idNum = None ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . ReEnum ( ctypes . byref ( idNum ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def reset ( self , idNum = None ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> ecode = staticLib . Reset ( ctypes . byref ( idNum ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def resetLJ ( self , idNum = None ) : <EOL> """<STR_LIT>""" <EOL> return reset ( idNum ) <EOL> def sht1X ( self , idNum = None , demo = <NUM_LIT:0> , softComm = <NUM_LIT:0> , mode = <NUM_LIT:0> , statusReg = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> tempC = ctypes . c_float ( <NUM_LIT:0> ) <EOL> tempF = ctypes . c_float ( <NUM_LIT:0> ) <EOL> rh = ctypes . c_float ( <NUM_LIT:0> ) <EOL> ecode = staticLib . SHT1X ( ctypes . byref ( idNum ) , demo , softComm , mode , statusReg , ctypes . byref ( tempC ) , ctypes . byref ( tempF ) , ctypes . byref ( rh ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : tempC . value , "<STR_LIT>" : tempF . value , "<STR_LIT>" : rh . value } <EOL> def shtComm ( self , numWrite , numRead , datatx , idNum = None , softComm = <NUM_LIT:0> , waitMeas = <NUM_LIT:0> , serialReset = <NUM_LIT:0> , dataRate = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if len ( datatx ) != <NUM_LIT:4> : raise ValueError ( "<STR_LIT>" ) <EOL> datatx = listToCArray ( datatx , ctypes . c_ubyte ) <EOL> datarx = ( ctypes . c_ubyte * <NUM_LIT:4> ) ( ( <NUM_LIT:0> ) * <NUM_LIT:4> ) <EOL> ecode = staticLib . SHTComm ( ctypes . byref ( idNum ) , softComm , waitMeas , serialReset , dataRate , numWrite , numRead , ctypes . byref ( datatx ) , ctypes . byref ( datarx ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT>" : datarx } <EOL> def shtCRC ( self , numWrite , numRead , datatx , datarx , statusReg = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> datatx = listToCArray ( datatx , ctypes . c_ubyte ) <EOL> datarx = listToCArray ( datarx , ctypes . c_ubyte ) <EOL> return staticLib . SHTCRC ( statusReg , numWrite , numRead , ctypes . byref ( datatx ) , ctypes . byref ( datarx ) ) <EOL> def synch ( self , mode , numWriteRead , data , idNum = None , demo = <NUM_LIT:0> , msDelay = <NUM_LIT:0> , husDelay = <NUM_LIT:0> , controlCS = <NUM_LIT:0> , csLine = None , csState = <NUM_LIT:0> , configD = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if controlCS > <NUM_LIT:0> and csLine is None : raise ValueError ( "<STR_LIT>" ) <EOL> cData = [ <NUM_LIT:0> ] * <NUM_LIT> <EOL> for i in range ( <NUM_LIT:0> , len ( data ) ) : <EOL> cData [ i ] = data [ i ] <EOL> cData = listToCArray ( cData , ctypes . c_long ) <EOL> ecode = staticLib . Synch ( ctypes . byref ( idNum ) , demo , mode , msDelay , husDelay , controlCS , csLine , csState , configD , numWriteRead , ctypes . byref ( cData ) ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value , "<STR_LIT:data>" : cData } <EOL> def watchdog ( self , active , timeout , activeDn , stateDn , idNum = None , demo = <NUM_LIT:0> , reset = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if idNum is None : <EOL> idNum = self . id <EOL> idNum = ctypes . c_long ( idNum ) <EOL> if len ( activeDn ) is not <NUM_LIT:3> : raise ValueError ( "<STR_LIT>" ) <EOL> if len ( stateDn ) is not <NUM_LIT:3> : raise Value ( "<STR_LIT>" ) <EOL> ecode = staticLib . Watchdog ( ctypes . byref ( idNum ) , demo , active , timeout , reset , activeDn [ <NUM_LIT:0> ] , activeDn [ <NUM_LIT:1> ] , activeDn [ <NUM_LIT:2> ] , stateDn [ <NUM_LIT:0> ] , stateDn [ <NUM_LIT:1> ] , stateDn [ <NUM_LIT:2> ] ) <EOL> if ecode != <NUM_LIT:0> : raise U12Exception ( ecode ) <EOL> return { "<STR_LIT>" : idNum . value } <EOL> def readMem ( self , address , idnum = None ) : <EOL> """<STR_LIT>""" <EOL> if address is None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if idnum is None : <EOL> idnum = self . id <EOL> ljid = ctypes . c_ulong ( idnum ) <EOL> ad0 = ctypes . c_ulong ( ) <EOL> ad1 = ctypes . c_ulong ( ) <EOL> ad2 = ctypes . c_ulong ( ) <EOL> ad3 = ctypes . c_ulong ( ) <EOL> ec = staticLib . ReadMem ( ctypes . byref ( ljid ) , ctypes . c_long ( address ) , ctypes . byref ( ad3 ) , ctypes . byref ( ad2 ) , ctypes . byref ( ad1 ) , ctypes . byref ( ad0 ) ) <EOL> if ec != <NUM_LIT:0> : raise U12Exception ( ec ) <EOL> addr = [ <NUM_LIT:0> ] * <NUM_LIT:4> <EOL> addr [ <NUM_LIT:0> ] = int ( ad3 . value & <NUM_LIT> ) <EOL> addr [ <NUM_LIT:1> ] = int ( ad2 . value & <NUM_LIT> ) <EOL> addr [ <NUM_LIT:2> ] = int ( ad1 . value & <NUM_LIT> ) <EOL> addr [ <NUM_LIT:3> ] = int ( ad0 . value & <NUM_LIT> ) <EOL> return addr <EOL> def writeMem ( self , address , data , idnum = None , unlocked = False ) : <EOL> """<STR_LIT>""" <EOL> if address is None or data is None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if type ( data ) is not list or len ( data ) != <NUM_LIT:4> : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if idnum is None : <EOL> idnum = self . id <EOL> ljid = ctypes . c_ulong ( idnum ) <EOL> ec = staticLib . WriteMem ( ctypes . byref ( ljid ) , int ( unlocked ) , address , data [ <NUM_LIT:3> ] & <NUM_LIT> , data [ <NUM_LIT:2> ] & <NUM_LIT> , data [ <NUM_LIT:1> ] & <NUM_LIT> , data [ <NUM_LIT:0> ] & <NUM_LIT> ) <EOL> if ec != <NUM_LIT:0> : raise U12Exception ( ec ) <EOL> return ljid . value <EOL> def LJHash ( self , hashStr , size ) : <EOL> outBuff = ( ctypes . c_char * <NUM_LIT:16> ) ( ) <EOL> retBuff = '<STR_LIT>' <EOL> staticLib = ctypes . windll . LoadLibrary ( "<STR_LIT>" ) <EOL> ec = staticLib . LJHash ( ctypes . cast ( hashStr , ctypes . POINTER ( ctypes . c_char ) ) , <EOL> size , <EOL> ctypes . cast ( outBuff , ctypes . POINTER ( ctypes . c_char ) ) , <EOL> <NUM_LIT:0> ) <EOL> if ec != <NUM_LIT:0> : raise U12Exception ( ec ) <EOL> for i in range ( <NUM_LIT:16> ) : <EOL> retBuff += outBuff [ i ] <EOL> return retBuff <EOL> def isIterable ( var ) : <EOL> try : <EOL> iter ( var ) <EOL> return True <EOL> except : <EOL> return False <EOL> def listToCArray ( list , dataType ) : <EOL> arrayType = dataType * len ( list ) <EOL> array = arrayType ( ) <EOL> for i in range ( <NUM_LIT:0> , len ( list ) ) : <EOL> array [ i ] = list [ i ] <EOL> return array <EOL> def cArrayToList ( array ) : <EOL> list = [ ] <EOL> for item in array : <EOL> list . append ( item ) <EOL> return list <EOL> def getErrorString ( errorcode ) : <EOL> """<STR_LIT>""" <EOL> errorString = ctypes . c_char_p ( "<STR_LIT:U+0020>" * <NUM_LIT:50> ) <EOL> staticLib . GetErrorString ( errorcode , errorString ) <EOL> return errorString . value <EOL> def hexWithoutQuotes ( l ) : <EOL> """<STR_LIT>""" <EOL> return str ( [ hex ( i ) for i in l ] ) . replace ( "<STR_LIT:'>" , "<STR_LIT>" ) </s>
