Thanks sergesl,
I think I was confused by the shipping example behavior and similar behavior in my dll. I changed the error handling so that a channel error could be corrected in a text box and it seems to work OK.
This part of the code tries to use the channel from the calling program:
error = 1;
while (error){
error = DAQmxCreateAIVoltageChan(taskHandle,ADHdwr.AIchans,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL);
if(error){
DAQmxGetExtendedErrorInfo(errBuff,2048);
MessagePopup("DAQmx Error",errBuff);
PanelChan = BuildChanPANEL();
NIDAQmx_NewPhysChanAICtrl(PanelChan,PANEL_TACHOCHAN,1);
NIDAQmx_SetPhysChanCtrlAttribute (PanelChan,PANEL_TACHOCHAN, NIDAQmx_IOCtrl_ChanType, NIDAQmx_IOCtrl_Val_PhysChanIOTypeAI);
NIDAQmx_SetPhysChanCtrlAttribute (PanelChan,PANEL_TACHOCHAN, NIDAQmx_IOCtrl_Limit_Device, ADHdwr.AIchans);
NIDAQmx_SetPhysChanCtrlAttribute (PanelChan,PANEL_TACHOCHAN, NIDAQmx_IOCtrl_Limit_To_Device,1);
NIDAQmx_GetPhysChanCtrlAttribute (PanelChan,PANEL_TACHOCHAN, NIDAQmx_IOCtrl_PhysChanExternal, NULL);
SetCtrlVal (PanelChan,PANEL_TACHOCHAN, ADHdwr.AIchans);
DisplayPanel(PanelChan);
ui = RunUserInterface();
}
}
PanelChan is a panel that has the string control for NIDAQmx_NewPhysChanAICtrl and a QUIT button. The Quit button has the following callback:
int CVICALLBACK CloseTachoInterface (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (PanelChan,PANEL_TACHOCHAN, ADHdwr.AIchans);
QuitUserInterface (ui);
DiscardPanel(PanelChan);
PanelChan = 0;
break;
}
return 0;
}
This works for now but I'll probably change it later.
Duncan