DOS下与MODEN使用FOX通信的问题(200分)

  • 主题发起人 主题发起人 qingxi
  • 开始时间 开始时间
Q

qingxi

Unregistered / Unconfirmed
GUEST, unregistred user!
对不起.因为我在别处找不到答案,所以贴到这里来了.

拨号成功.我想知道如何才能拨号后读写串口呢?

&&调用方式: DialPhon Ccomport,CphonEno
&&入口参数说明:CComport:字符串 串口号 'Auto'自动查找,1-4
&&CPhoneNo 字符串 拨打的电话.
&&例:Ccomport='Auto'
&& Cphoneno='013980511193'
&&功能:通过MODEN或其它COM设备拨号(不能拨号的设备不会报错!!!)

PARAMETER CCOMPORT, CPHONENO
PRIVATE NHANDLE, CAUTOPORT, CCOMPORT
ccomport='Auto'
cphoneno='2261159'
IF CCOMPORT='Auto'
FOR I = 1 TO 4
CAUTOPORT = 'COM'+STR(I,1)
NHANDLE = FOPEN(CAUTOPORT,2)
&&打开端口,并保存端口号
IF NHANDLE>0
EXIT
ENDIF
ENDFOR
ELSE
NHANDLE = FOPEN(CCOMPORT,2)
ENDIF
IF NHANDLE< 0
?? CHR(7)
WAIT WINDOW '打开(COM PORT)失败!按任意键退出.......'
RETURN
ENDIF
WAIT WINDOW "正在初始化 (COM PORT)" NOWAIT
CSTRING = 'ATDT '+CPHONENO+CHR(13)+CHR(10)
= FWRITE(NHANDLE,CSTRING)
&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
&amp;&amp;轮询直到在一秒内有"OK"返回,否则超时
&amp;&amp;
&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
CSTRING=''
=FSEEK(NHANDLE,0)
BeginTime=sys(2)
DO WHILE .not. (CSTRING $ ("OK"+CHR(13)+CHR(10)))
&amp;&amp;.OR. (Val(Subs(sys(2),4,2))-Val(subs(begintime,4,2))<10)
CSTRING=CSTRING+FREAD(NHANDLE,1)
?'cstring=',cstring
ENDDO
?cstring
if .Not. (CSTRING $ "OK")
WAIT WINDOW "拨号超时,不能拨通,按任意键返回.ttttttttt"
CSTRING = 'ATH '+CHR(13)
= FWRITE(NHANDLE,CSTRING) &amp;&amp;写入关闭MODen命令
= FCLOSE(NHANDLE)
Else
CSTRING="CARDID12313213END"+CHR(13)+CHR(10)
=FWRITE(NHANDLE,CSTRING)
&amp;&amp;候交易成功与否信号
CSTRING=''
DO WHILE CSTRING $ "SALE"
CSTRING=CSTRING+FREad(NHANDLE,1)
Enddo

CSTRING = 'ATH '+CHR(13)
= FWRITE(NHANDLE,CSTRING) &amp;&amp;写入关闭MODen命令
= FCLOSE(NHANDLE) &amp;&amp; 关闭MODEN
Endif

 
后退
顶部