我在做一个项目,需要在labwindows/cvi里把一个文件传送到USBRAW设备里,我先用OpenFile()打开文件,再用ReadFile()把文件里面的数据读到字符数组SendString里面,然后viWrite()发送出去,但是在viWrite()那里总是出现timeout的错误,数据不能发出去,usb设备是一个BULK -IN通道和一个BULK-OUT通道,请教我的问题在哪里呢?这里是一部分程序
int CVICALLBACK Send_select (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{ switch (event)
{
case EVENT_COMMIT:
if (FileSelectPopup ("", "", "","请选择发送文件",VAL_SELECT_BUTTON, 0, 0, 1, 1, Sendname)
!= VAL_NO_FILE_SELECTED)
{ SetCtrlVal (panelHandle,PANEL_STRING_1, Sendname);
GetFileInfo (Sendname, &Sendfilesize);
if(Sendfilesize>4053)
{ MessagePopup("ATEN??O","文件太大");
}
}
break;
}
return 0;
}
int CVICALLBACK Sendfile (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{ char SendString[512]={0,0};
switch (event)
{
case EVENT_COMMIT:
FileHandle = OpenFile (Sendname, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);
ReadFile (FileHandle, SendString, Sendfilesize);
STATUS=viWrite (USB_FIND, (ViBuf)SendString,64, &writeCount);
CloseFile (FileHandle);
break;
}
return 0;
} |