WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-02-2012, 01:48 PM
mhead10 mhead10 is offline
Member
 
Join Date: Mar 2012
Posts: 40
obtaining "None" value in Schedule

Can I not assign values in a schedule loop? For instance, the following code prints out "data" correctly, but not the computed value "difference".

Code:
def CHK(err):
    if err < 0:
        buf_size = 100
        buf = ctypes.create_string_buffer('\000' * buf_size)
        nidaq.DAQmxGetErrorString(err,ctypes.byref(buf),buf_size)
        raise RuntimeError('nidaq call failed with error %d: %s'%(err,repr(buf.value)))

def mapping(): #obtains data, calculates difference
	while True:
		yield CHK(nidaq.DAQmxReadAnalogF64(taskHandle,1,float64(-1),DAQmx_Val_GroupByChannel,data.ctypes.data,max_num_samples,ctypes.byref(read),None))# obtain DAQ data, output is data[]
		print data #prints correctly
		difference = yield abs(data[1]-data[0]) #find difference in voltage between first two pots
		print difference #prints "None"
Thank you in advance.
Reply With Quote
  #2  
Old 10-03-2012, 12:39 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You seem to be confusing task functions with regular Python functions. There is no need to be yielding values in those functions. Just call the function and save the return value to a variable. I'd recommend reading through the Python Programming 101 tutorial in the documentation.

It's still difficult to understand what's going on in your script without seeing more code. However, try the following changes to see if it helps:
Code:
def CHK(err):
    if err < 0:
        buf_size = 100
        buf = ctypes.create_string_buffer('\000' * buf_size)
        nidaq.DAQmxGetErrorString(err,ctypes.byref(buf),buf_size)
        raise RuntimeError('nidaq call failed with error %d: %s'%(err,repr(buf.value)))

def mapping(): #obtains data, calculates difference
	while True:
		CHK(nidaq.DAQmxReadAnalogF64(taskHandle,1,float64(-1),DAQmx_Val_GroupByChannel,data.ctypes.data,max_num_samples,ctypes.byref(read),None))# obtain DAQ data, output is data[]
		print data #prints correctly
		difference = abs(data[1]-data[0]) #find difference in voltage between first two pots
		print difference #prints "None"
Reply With Quote
Reply

Tags
schedule

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:14 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC