- 注册时间
- 2005-3-12
- 最后登录
- 1970-1-1
|
弄了一晚上,有点眉目了
写个伪代码,供大家参考
因为没有tc800的机器,用调试器挂着调试在有点累(主要原因是基本功不扎实),而且也不能保证正确,所以我不对下面的内容正确性负责
没有注释,将就着看吧
( PC perspective )
CMD_TEXT =1
CMD_CHDIR =2
CMD_DOWNLOAD =3
CMD_DOWNSIZE =4
CMD_ENDTRANSFER =5
CMD_ClOSE =6
CMD_UPLOAD =7
CMD_UPSIZE =8
mode=1
strText=" 开始通讯! "
;============================================
Sync():
in 'W'
out 0xB3
in 'Q'
out 0xB3
in 'X'
out 'L'
end
;============================================
Session(Cmd,Data,Mode):
if Mode=1 then wait{in 0x05}:Mode=0 else in 0x5
out cmd
out Data.size (2 byte)
if Data.size<>0 then
out Data.data
out Data.xorChk
in 'L' (success) / in 'X' (ChkFail)
end if
end
;============================================
upload()
Sync()
Session(CMD_TEXT,strText,mode)
uploadMain()
Session(CMD_ClOSE,NULL,mode)
end
;============================================
download()
Sync()
Session(CMD_TEXT,strText,mode)
downloadMain()
Session(CMD_ClOSE,NULL,mode)
end
;============================================
getFileBlock()
in 0x8
out 0x6
in FileSize,2
in Data,FileSize
out 0x6
if Data.xorChk<>0 then (fail) else success
end
;============================================
uploadMain()
Session(CMD_CHDIR,strPdaDir,mode)
Session(CMD_UPLOAD,0x2F+0xCE+strPdaFile,mode)
openPcFile()
L2:
switch( Session(CMD_UPSIZE,SHORT(1024),mode).return ){
case fail
writeBufToFile()
case ChkFail
out 0xCF
out 0xCB
goto L2
default(success)
getFileBlock()
if Data.size<>0 then ?copyDataToFileBufWithCoding() : FileBufPtr++ ;?表示这个东西还不明确
if Data.size<1024 break else goto L2
}
writeBufToFile()
Session(CMD_ENDTRANSFER,NULL,mode)
end
;============================================
downloadMain()
Session(CMD_CHDIR,strPdaDir,mode)
Session(CMD_DOWNLOAD,0xEF+0xEF+strPdaFile,mode)
openPcFile()
??下面还没看
end
;============================================
|
|