WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Serial
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Kermit Type Transfers

Keywords: 	 kermit serial extender

Question:

How can I set up my com port to act as a Kermit Server. I have a data collector that I need to transfer it's file via the com port. Does the wwser34i.dll have that capability. Any suggestions.

Answer:

Eeeep. I have a serial extender script *someplace* that is partially debugged and understands some basic Kermit.

But you *really* *really* have to want to do this (rather than work out some other solution).

Here is a Ketmit file recieve example with the serial extender. Mostly debugged.

;Kermit File Receive.
    BoxOpen("Kermit","Initializing")
    debugfile="c:\kermitdebug.txt"
CaptureFile="C:\Caputure.html"
filetoget="APF,171100"
filetosaveas="C:\apf.dat"


; Here is the basic example. I suggest you get this working first.
FileDelete(debugfile)
DebugTrace(@ON,debugfile)

acct="ES00446"
password="ES00446"
phone="0,131459"
handle = -1

BoxText("Loading Extender")
AddExtender("wwser34i.dll")           ; Load the serial extender
MaxPacket=1000

MyModemIsOn="COM1"                    ; Set to where your modem is

pCaptureOn(CaptureFile,0)

BoxText("Opening com port")

port=pComOpen(MyModemIsOn,0,57600,"8N1","RTSRTS")  ; Open com port

BoxText("Dialing Modem")

pModemDial(port,1,phone)
BoxText("Waiting for connect")

flag=pModemConnect(port)
if flag == @FALSE
   Message("eee","Modem did not connect")
   exit
endif

pTimeOut(port,4000)

BoxText("logging on")

pWaitFor(port,"<"," ",0,10000)
pPutLine(port,"LOGON %acct%,%password%")

;pWaitFor(port,"Username:"," ",0,10000)
;pPutLine(port,acct)

;BoxText("Password")

;pWaitFor(port,"Password:"," ",0,10000)
;pPutLine(port,password)

;BoxText("Menu CHoices")


;pWaitFor(port,"choice:"," ",0,10000)
;pPutLine(port,"3")

;pWaitFor(port,"choice:"," ",0,10000)
;pPutLine(port,"2")

;pWaitFor(port,"choice:"," ",0,10000)
;pPutLine(port,"5")

;BoxText("asking for file")

;pWaitFor(port,"download:"," ",0,10000)
;pPutLine(port,"CONFIG.SYS")

;pWaitFor(port,"RECEIVE..."," ",0,10000)
BoxText("asking for file")

pWaitFor(port,">"," ",0,10000)
pPutLine(port,"RETRIEVEK %filetoget%")

BoxText("into Kermit code we go")

gosub kermitgetfile

pPutLine(port,"LOGOFF")



pComClose(port,0)                     ; Close the com port

Message("Well","It seemed to work")

exit

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:kermitgetfile
    N=0
    SEQ=0
    EOL=13
    CTL=Char2Num("#")

    SNDBUF=Strcat(Num2Char(1),"# N3",@CR)

    gosub GetValidPacket5000

    if TYP!="S" then D=StrCat(TYP," Packet is S state (Error)")
                then goto bombout9500

    if StrLen(PKTDAT) > 4 then EOL=Char2Num(StrSub(PKTDAT,5,1)) - 32
    if StrLen(PKTDAT) > 5 then CTL = Char2Num(Strsub(PKTDAT,6,1))


    D = "H* @-N1"
    gosub sendDvalue8020

    :getheader3000
    ;Get a file header packet.  If a B packet comes we're all done
    gosub GetValidPacket5000
    if TYP=="B" then gosub sendackpacket8000
                then goto  normalexit9900
    if TYP!="F" then D = Strcat(TYP," packet in F state")
                then goto bombout9500
    BoxText(StrCat("Receiving ",StrSub(PKTDAT,1,L)))

    IntControl(53,0,0,0,0)   ; Tell FileWrite NOT to add CRLF
    handle=FileOpen(filetosaveas,"WRITE")
    gosub sendackpacket8000

    while 1
        ;Get data packets.  If a Z packet comes in, File is complete
        gosub GetValidPacket5000
        if TYP=="Z" then FileClose(handle)
                    then handle = -1
                    then gosub sendackpacket8000
                    then boxtext("File Complete")
                    then goto getheader3000
        if TYP != "D" then D = Strcat(TYP," packet in D state")
                      then goto bombout9500

        FileWrite(handle,strsub(PKTDAT,1,P))
        gosub sendackpacket8000
    endwhile


;:bombout9000
;Error handler...nothing fancy...
;D = StrCat("error ",ERR," at Line",wberrorline)
;Message("error","Not implemented yet")



:bombout9500
;Error from packet sender
L = Strlen(D)
TYP="E"
gosub sendpacket6000

:normalexit9900
;Normal exit point
If handle != -1 then FileCLose(handle)
BoxText("Exiting")
Message("Last Msg",D)
return







;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:GetValidPacket5000
   gosub readanddecodepacket7000
   for TRY=1 to 5
       if SEQ == N && TYP!="Q" then return
       pPutString(port,SNDBUF)
       BoxText("eeep TRY number %TRY%")
       gosub readanddecodepacket7000
   next TRY
   TYP="T"
   return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:sendpacket6000
   ;Send packet D of length L type TYP sequence N
   SNDBUF=Strcat(Num2Char(1),Num2Char(L+35),Num2Char(N+32),TYP,D)
   CHKSUM=0
   for I = 2 to L+4
      CHKSUM = CHKSUM + Char2Num(StrSub(SNDBUF,I,1))
   next I
   CHKSUM = (CHKSUM + ((CHKSUM & 192) / 64) & 63)
   SNDBUF=StrCat(SNDBUF,Num2Char(CHKSUM+32),Num2Char(EOL))
   pPutString(port,SNDBUF)
   return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:readanddecodepacket7000
;Routine to read and decode a packet
    RCVBUF=pGetLine(port,maxpacket)
    I = StrIndex(RCVBUF,Num2Char(1),0,@fwdscan)
    if I == 0
       TYP="Q"
       return
    endif
    CHK=Char2Num(StrSub(RCVBUF,I+1,1))
    L = CHK - 35
    T=Char2Num(Strsub(RCVBUF,I+2,1))
    SEQ = T - 32
    CHK = CHK + T
    TYP=StrSub(RCVBUF,I+3,1)
    CHK = CHK + Char2Num(TYP)
    P=0
    FLAG=0
    ;;PKTDAT=StrFill(Num2Char(32),100)
    PKTDAT=""
    For J= (I+4) to (I+3+L)
       T=Char2Num(Strsub(RCVBUF,J,1))
       CHK = CHK + T
       if TYP == "S" then goto SKIP7300
       if FLAG ==0 && T==CTL then FLAG=1 ; WHAT IS CTL ????
                             then goto SKIP7400
       T7 = T & 127
       if FLAG!=0
          FLAG=0
          if T7 > 62 && T7 < 96 then T=T ^ 64
       endif
   :SKIP7300
       P = P + 1
       ;;pktdat1=strsub(PKTDAT,1,P-1)
       ;;pktdat2=strsub(PKTDAT,p+1,-1)
      ;; PKTDAT=strcat(pktdat1,Num2Char(T),pktdat2)
      PKTDAT=StrCat(PKTDAT,Num2Char(T))
   :SKIP7400
   NEXT J
   CHK = ( CHK + ((CHK & 192) / 64)) & 63
   CHKSUM=Char2Num(Strsub(RCVBUF,J,1)) - 32
   if CHKSUM <> CHK then TYP="Q"
   return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:sendackpacket8000
   D = ""
   gosub sendDvalue8020
   return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:sendDvalue8020
   TYP = "Y"
   L =  StrLen(D)
   gosub sendpacket6000
   N = (N + 1) & 63
   if (N & 3) == 0 then BoxText(".")
   return


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Article ID:   W14796
File Created: 2001:11:08:12:40:00
Last Updated: 2001:11:08:12:40:00