Пример #1
0
    def _setFrequency(self, freq):
        """Set frequency of pwm-exp oscillator"""
        self.frequency = freq
        ret = pwmExp.setFrequency(freq)
        if (ret != 0):
            print 'ERROR: pwm-exp setFrequency not successful!'

        return ret
Пример #2
0
	def _setFrequency(self, freq):
		"""Set frequency of pwm-exp oscillator"""
		self.frequency 	= freq
		ret 	= pwmExp.setFrequency(freq);
		if (ret != 0):
			print 'ERROR: pwm-exp setFrequency not successful!'

		return ret

def ws_on_close(ws):
    print("### Disconnected from SignalR Server ###")


def ws_on_open(ws):
    print("### Connected to SignalR Server via WebSocket ###")

    # Do a handshake request
    print("### Performing handshake request ###")
    ws.send(encode_json({"protocol": "json", "version": 1}))

    # Handshake completed
    print("### Handshake request completed ###")


if __name__ == "__main__":
    pwmExp.driverInit()
    pwmExp.setFrequency(freq)
    websocket.enableTrace(True)

    ## Use wss as protocol for your url. for example, wss://localshot:44321/messagehub

    ws = websocket.WebSocketApp("[YOUR SIGNALR URL HERE]",
                                on_message=ws_on_message,
                                on_error=ws_on_error,
                                on_close=ws_on_close)
    ws.on_open = ws_on_open
    ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
Пример #4
0
import OmegaExpansion.pwmExp as pwm
import sys

status = pwm.driverInit()

if pwm.checkInit() == 0:
    print("PWM Init failed")
    exit

lr = float(sys.argv[1])
ud = float(sys.argv[2])

pwm.setFrequency(50)
pwm.setupDriver( 0, lr, 0)
pwm.setupDriver(15, ud, 0)
Пример #5
0
print '>> Using channel ', channel

pwmExp.setVerbosity(0)

# check initialization
#	should return 0 if the PWM Expansion has just been plugged in
ret = pwmExp.checkInit()
print "checking if initialized: ", ret

# initialize the pwm-exp
ret = pwmExp.driverInit()
print "driverInit return: ", ret
if (ret != 0):
    exit()
ret = pwmExp.setFrequency(50)
print "setFrequency return: ", ret
if (ret != 0):
    exit()

# check initialization
#	should return 1 since the Expansion was initialized above
ret = pwmExp.checkInit()
print "checking if initialized: ", ret
time.sleep(1)

# set channel 0
ret = pwmExp.setupDriver(channel, 9, 0)
print "setupDriver return: ", ret
if (ret != 0):
    exit()
Пример #6
0
    def _setFrequency(self, freq):
        """Set frequency of pwm-exp oscillator"""
        self.frequency     = freq
        ret     = pwmExp.setFrequency(freq);
		if (ret != 0):
Пример #7
0
print '>> Using channel ', channel

pwmExp.setVerbosity(0)

# check initialization
#	should return 0 if the PWM Expansion has just been plugged in
ret 	= pwmExp.checkInit()
print "checking if initialized: ", ret

# initialize the pwm-exp
ret 	= pwmExp.driverInit()
print "driverInit return: ", ret
if (ret != 0):
	exit()
ret 	= pwmExp.setFrequency(50)	
print "setFrequency return: ", ret
if (ret != 0):
	exit()

# check initialization
#	should return 1 since the Expansion was initialized above
ret 	= pwmExp.checkInit()
print "checking if initialized: ", ret
time.sleep(1)


# set channel 0
ret 	= pwmExp.setupDriver(channel, 9, 0)
print "setupDriver return: ", ret
if (ret != 0):