int func_RxlottData(int iNo,char *sRet)
{
static DX_IOTT iott = {0};
static DV_TPT tpt;
ADSI_XFERSTRUC adsimode; printf("%s: In func_RxlottData()\n",dev[iNo].voxname); memset(&iott,0,sizeof(iott));
iott.io_type = IO_MEM|IO_EOT;
iott.io_fhandle = 0; //If IO_DEV is not set in io_type, io_fhandle should be set to 0.
iott.io_bufp = sRet; //Specifies a base memory address if IO_MEM is set in io_type.
iott.io_offset = 0; //if IO_MEM is specified in io_type, an offset from the base buffer address specified in io_bufp
iott.io_length = -1; //接收数据直到终止条件发生
adsimode.cbSize = sizeof(adsimode);
adsimode.dwRxDataMode = ADSI_NOALERT;
//清空DV_TPT 结构的内容
if (dx_clrtpt(&tpt, 1) == -1) {
;
}
tpt.tp_type = IO_EOT; //last structure
tpt.tp_termno = DX_MAXTIME; //超时
tpt.tp_length = RXLOTTDATA_TIMEOUT*100; //2000*10ms=20000ms=20s
tpt.tp_flags = TF_10MS; //单位 //异步接收数据
if (dx_RxIottData( dev[iNo].vox, //using dx_open()
&iott, //points to the I/O Transfer Table, DX_IOTT. The iottp parameter specifiesthe destination for the received data.
&tpt, //points to the Termination Parameter Table Structure, DV_TPT
DT_ADSI, //specifies the type of data to be received. To receive ADSI data, set wType to DT_ADSI.
&adsimode, //points to information specific to the data type specified in wType.
EV_ASYNC
) < 0) {
printf("%s: dx_RxIottData() failed on Channel %s; error: %s\n",
dev[iNo].voxname,ATDV_NAMEP(dev[iNo].vox), ATDV_ERRMSGP(dev[iNo].vox));
CGlobalFunc::WriteLog("%s: dx_RxIottData() failed",dev[iNo].voxname); return -1;
} printf("%s: dx_RxIottData() OK.\n",dev[iNo].voxname);
CGlobalFunc::WriteLog("%s: dx_RxIottData() OK.",dev[iNo].voxname); return 0;
}
{
static DX_IOTT iott = {0};
static DV_TPT tpt;
ADSI_XFERSTRUC adsimode; printf("%s: In func_RxlottData()\n",dev[iNo].voxname); memset(&iott,0,sizeof(iott));
iott.io_type = IO_MEM|IO_EOT;
iott.io_fhandle = 0; //If IO_DEV is not set in io_type, io_fhandle should be set to 0.
iott.io_bufp = sRet; //Specifies a base memory address if IO_MEM is set in io_type.
iott.io_offset = 0; //if IO_MEM is specified in io_type, an offset from the base buffer address specified in io_bufp
iott.io_length = -1; //接收数据直到终止条件发生
adsimode.cbSize = sizeof(adsimode);
adsimode.dwRxDataMode = ADSI_NOALERT;
//清空DV_TPT 结构的内容
if (dx_clrtpt(&tpt, 1) == -1) {
;
}
tpt.tp_type = IO_EOT; //last structure
tpt.tp_termno = DX_MAXTIME; //超时
tpt.tp_length = RXLOTTDATA_TIMEOUT*100; //2000*10ms=20000ms=20s
tpt.tp_flags = TF_10MS; //单位 //异步接收数据
if (dx_RxIottData( dev[iNo].vox, //using dx_open()
&iott, //points to the I/O Transfer Table, DX_IOTT. The iottp parameter specifiesthe destination for the received data.
&tpt, //points to the Termination Parameter Table Structure, DV_TPT
DT_ADSI, //specifies the type of data to be received. To receive ADSI data, set wType to DT_ADSI.
&adsimode, //points to information specific to the data type specified in wType.
EV_ASYNC
) < 0) {
printf("%s: dx_RxIottData() failed on Channel %s; error: %s\n",
dev[iNo].voxname,ATDV_NAMEP(dev[iNo].vox), ATDV_ERRMSGP(dev[iNo].vox));
CGlobalFunc::WriteLog("%s: dx_RxIottData() failed",dev[iNo].voxname); return -1;
} printf("%s: dx_RxIottData() OK.\n",dev[iNo].voxname);
CGlobalFunc::WriteLog("%s: dx_RxIottData() OK.",dev[iNo].voxname); return 0;
}
dx_TxIottData无论超时时间设置多大,总是立刻超时返回,不知道什么原因?
哪位大侠帮我看看,函数代码如下int func_TxlottData(int iNo,char *sRet,int lenMsg)
{
static DX_IOTT tx_diott = {0};
static DV_TPT tx_tpt;
ADSI_XFERSTRUC adsimode;
printf("%s: In func_TxlottData()\n",dev[iNo].voxname);
//*
//memset(&dx_diott,0,sizeof(dx_diott));
tx_diott.io_type = IO_MEM|IO_EOT;
tx_diott.io_fhandle = 0; //没有设置IO_DEV,所以为0
tx_diott.io_bufp = sRet; //要发送的数据
tx_diott.io_offset = 0; //从头发送
tx_diott.io_length = lenMsg; //发送数据长度
adsimode.cbSize = sizeof(adsimode);
adsimode.dwTxDataMode = ADSI_ALERT; // send out ADSI data with CAS
//清空DV_TPT 结构的内容
if (dx_clrtpt(&tx_tpt, 1) == -1) {
;
}
tx_tpt.tp_type = IO_EOT; //last structure
tx_tpt.tp_termno = DX_MAXTIME; //超时
tx_tpt.tp_length = 20*100;
tx_tpt.tp_flags = TF_MAXTIME|TF_10MS; //单位//异步发送
if (dx_TxIottData( dev[iNo].vox, //using dx_open()
&tx_diott, //发送数据属性
&tx_tpt, //终止条件
DT_ADSI,
&adsimode,
EV_ASYNC
) < 0) {
printf("%s: dx_TxIottData() failed on Channel %s; error: %s\n",
dev[iNo].voxname,ATDV_NAMEP(dev[iNo].vox), ATDV_ERRMSGP(dev[iNo].vox));
CGlobalFunc::WriteLog("%s: dx_TxIottData() failed on Channel %s; error: %s",
dev[iNo].voxname,ATDV_NAMEP(dev[iNo].vox), ATDV_ERRMSGP(dev[iNo].vox));
return -1;
}
printf("%s: dx_TxIottData() OK.\n",dev[iNo].voxname);
CGlobalFunc::WriteLog("%s: dx_TxIottData() OK.",dev[iNo].voxname);
return 0;
}用这个函数检测执行结果,立刻返回“Maximum function time exceeded”
int dt_ATDX_TERMMSK(int i)
{
long term;
//*
if((term=ATDX_TERMMSK(dev.vox))==-1){
printf("%s: ATDX_TERMMSK error\n",ATDV_NAMEP(dev.vox));
return -1;
}
//*/
// term=TM_EOD;
if(term&TM_EOD){
CGlobalFunc::WriteLog("%s: End of FSK data detected on receive.",dev.voxname);
printf("%s: End of FSK data detected on receive.\n",dev.voxname);
} else if (term&TM_MAXTIME) {
CGlobalFunc::WriteLog("%s: Maximum function time exceeded.", dev.voxname);
printf("%s: Maximum function time exceeded.\n", dev.voxname);
return -2;
}else if (term&TM_ERROR) {
CGlobalFunc::WriteLog("%s: I/O device error.", dev.voxname);
printf("%s: I/O device error.\n", dev.voxname);
return -3;
}else if (term&TM_MAXDATA) {
CGlobalFunc::WriteLog("%s: Maximum FSK data reached; returned when the last I/O function terminates on DX_MAXDATA.", dev.voxname);
printf("%s: Maximum FSK data reached; returned when the last I/O function terminates on DX_MAXDATA.\n", dev.voxname);
return -4;
}else if (term&TM_USRSTOP) {
CGlobalFunc::WriteLog("%s: Function stopped by user.", dev.voxname);
printf("%s: Function stopped by user.\n", dev.voxname);
return -5;
} else {
CGlobalFunc::WriteLog("%s: 未知终止条件发生.", dev.voxname);
printf("%s: 未知终止条件发生.\n", dev.voxname);
return -6;
}
return 0;
}