Result data type in async callback

Supporting 2.7 and 3.2+
Post Reply
jnbastoky
Phidgetsian
Posts: 13
Joined: Sun Apr 15, 2018 9:03 am
Contact:

Result data type in async callback

Post by jnbastoky »

The details parameter in the AsyncHandler callback for Phidget22.Devices.VoltageOutput.setVoltage_async() and Phidget22.Devices.DigitalOutput.setState_async() is returned as Python type bytes instead of type string.

Printing the value returned by the AysncHandler result value gives a byte string:

Code: Select all

b'Success'
Example:

Code: Select all

from Phidget22.Phidget import *
from Phidget22.Devices.DigitalOutput import *
from Phidget22.ErrorCode import *
from Phidget22.Net import *
import time

Net.addServer('phidget',
			  'phidget.localdomain',
			  5661,
			  '',
			  0)

ch = DigitalOutput()
ch.setDeviceSerialNumber(123456)
ch.setHubPort(0)
ch.setIsRemote(True)
ch.setIsHubPortDevice(False)
ch.setChannel(0)
ch.openWaitForAttachment(1000)

def AsyncResult(ch, res, details):
	# if res != ErrorCode.EPHIDGET_OK:
	print("Async results: %i : %s" % (res, details))


ch.setState_async(False, AsyncResult)
# NOTE: Make sure to wait for async call to complete before closing the channel
time.sleep(1)

ch.close()
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests