home *** CD-ROM | disk | FTP | other *** search
- *.............................................................................
- * Program Name: CTFI1400 Copyright: Magna Carta Software, Inc.
- * Date Created: 02-05-93 Language: FoxPro 2.x (DOS/Windows)
- *.............................................................................
- * Description: Same as FOXCOM11, except...
- * Use INT14h network modem protocol services to access a network modem.
- * NOTA BENE: This program requires that an INT14h network modem server be
- * installed. We have tested it with...
- * Cross Communications, Inc. "Lan+Modem" (303) 444-7799.
- * Please report results with other INT14h drivers. If you discover an
- * incompatibility, please call Pinnacle Technical Support at (206) 251-3513
- * and we will investigate supporting the driver you are using.
- * Many Thanks.
- *.............................................................................
- * Default system settings
- CLEAR ALL
- SET TALK OFF
- SET ESCAPE OFF
-
- * Load the right library
- foxid = VERS()
- IF "2.0 " $ foxid
- SET LIBR TO ctf && Identified FoxPro 2.0
- ELSE
- IF "2.5 " $ VERS()
- IF "Windows" $ foxid && Identified FoxPro 2.5 for Windows
- SET LIBR TO ctfw
- ELSE
- SET LIBR TO ctf25 && Identified FoxPro 2.5 for DOS
- ENDIF
- ENDIF
- ENDIF
-
- PUBLIC fhr, number, portid, version
- fhr = 0
- number = "555-1212" && phone number for modem to dial (change to suit
- portid = 0
- version = 5
-
- DO ctfhdr
- IF "2.0 " $ foxid
- DO ctfutil
- SET PROCEDURE TO CTFUTIL
- ELSE
- DO ctfutil0
- SET PROCEDURE TO CTFUTIL0
- ENDIF
-
- ACTIVATE WINDOW w_main
- ACTIVATE WINDOW w_status
- ACTIVATE WINDOW w_term
-
- * 'Lan+Modem' presence test. Omit if using another server.
- haddock = IS_NETDEV()
- IF haddock == 0
- @00, 00 SAY "Fishy, "Lan + Modem not detected"
- RETURN
- ELSE
- @00, 00 SAY "Lan + Modem INT14h redirector detected"
- @01, 00 SAY "Initializing channel. Please wait..."
- ENDIF
-
- * This is interesting. We only change one line of our FoxPro source.
- * Instead of initializing a "u8250..." family device, we initialize an INT14h
- * driver. The rest of our source code is the same.
- * Here we comment out the old initialization...
- * ret = u8250_init(portid, x2d("3e8"), 9600, 8, PARITY_NONE, 1)
- * Here, we replace it with our new one.
- ret = int14_init(portid, 9600, 8, PARITY_NONE, 1)
- IF ret < 0
- ? ret
- =INKEY(0)
- CANCEL
- ENDIF
-
- * Note: We NEVER install interrupts when using a network modem.
-
- @ 00,00 SAY "CommTools INT14h Network Modem Terminal Version " +;
- ALLTRIM(STR(version)) + ": Press CTRL-HOME for menu"
- @01, 00 SAY " "
-
-
- DEFINE PAD p_ct_modem OF main_menu PROMPT "\<Modem" AT 00, 51
- ON SELECTION PAD p_ct_modem OF main_menu =ct_modem(portid, 51)
-
- DEFINE PAD p_ct_fsend OF main_menu PROMPT "\<Send" AT 00, 60
- ON SELECTION PAD p_ct_fsend OF main_menu =do_file_send(portid, 60)
-
- DEFINE PAD p_ct_freceive OF main_menu PROMPT "\<Receive" AT 00, 67
- ON SELECTION PAD p_ct_freceive OF main_menu =do_file_receive(portid, 67)
-
- DEFINE PAD p_ct_emul OF main_menu PROMPT "\<Emulation" AT 00, 77
- ON SELECTION PAD p_ct_emul OF main_menu =do_term_emul(portid, 77)
-
-
-
- ACTIVATE MENU main_menu && start the event loop
-
-
-
- * CT_ONLINE -- We embed our call to c_term() (the terminal loop) inside
- * this function so that we can separate the WINDOW MANAGEMENT from the
- * TERMINAL OPERATIONS
- FUNCTION ct_online
- PARAMETERS portid
-
- ACTIVATE WINDOW w_term && Activate our terminal window
- =CT_SET_WIN(portid) && tell CommTools to use w_term
- @ 00,00 SAY "CommTools Terminal Version " + LTRIM(STR(version)) + ": Press CTRL-HOME to Exit"
- =c_term(portid) && switch to dumb terminal mode
- RETURN (0)
-
-
-
- *
- * C_TERM -- This is a dumb terminal loop in FoxPro. You will see this (and
- * its close siblings) in every terminal example in CommTools.
- * Purpose: Alternately poll the serial input buffer and the keyboard for data.
- * Send received data to a window (the screen)
- * Send key strokes out of the serial port.
- PROCEDURE c_term
- PARAMETERS portid
- PRIVATE c
-
- * WINDOWS ADDS A CR SO WE MUST DO SOME EOL FORMATTING
- * THE END-OF-LINE CONVERSION CR2LF CONVERTS A CR TO A LF. HOWEVER CRLF PAIRS ARE
- * CONVERTED TO A SINGLE LF.
- * WINDOWS ALSO MAY NOT DISPLAY CR PROPERLY
- IF _WINDOWS == .T.
- * =set_rx_xlat(portid, EOL, CR2LF)
- ENDIF
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE)
- ?
- DO WHILE .T.
- * CHECK SERIAL PORT FOR BYTE *
- c = c_getc(portid) && check the serial port for a byte
- IF c == ENQ && CIS download request
- fsize = 0
- fname = " "
- =set_rx_xlat(portid, LOCAL_ECHO, FALSE)
- * Define a Window to show file transfer status reports.
- * Note that the status window could be used for file transfer status
- * reports instead.
- =display_xfer(5, 5, fname, fsize)
- * RECEIVE STARTS HERE (buffer size may be adjusted)
- ret = freceive(portid, CISBPLUS, 4*1024, "xfer_progress")
- =status_msg(0, STR(ret))
- =SOUND_ON(100, 500)
- DEACTIVATE WINDOW w_xfer
- =status_msg(0, "FINISHED")
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE)
- ENDIF
-
- * CHECK KEYBOARD FOR A KEY PRESS *
- * THE GRAND COMPROMISE...
- * INKEY() IS SLOW, TO AVOID IT
- * CHRSAW() DOES NOT DISPLAY THE CURSOR, SO CALL INKEY() PERIODICALLY
- IF c == CT_EOF .OR. CHRSAW() == .T.
- c= INKEY() && check keyboard for a key
- DO CASE && evaluate the received key
- CASE c == DEL
- =c_putc(portid, BS) && Fox Does not handle back space nicely
- CASE c == 29 && CTRL-HOME pressed
- RETURN
- CASE c <> 0 && another key was pressed...
- =c_putc(portid, c) && out the port it goes
- ENDCASE
- ENDIF
- ENDDO && do while .t.
- @02,00 SAY "Exiting c_term()" && show our mastery of the obvious
- RETURN
-
-
- *** Modem command code ***
-
- * MODEM_MENU(expN portid, expC number)
- * Show a menu that allows the user to send commands to the modem.
- *
- FUNCTION ct_modem
- PARAMETERS portid, col
-
- DEFINE POPUP pop_modem FROM 02, col;
- IN WINDOW w_main;
- MARGIN;
- SHADOW
- DEFINE BAR 1 OF pop_modem PROMPT "Return"
- DEFINE BAR 2 OF pop_modem PROMPT "Initialize"
- DEFINE BAR 3 OF pop_modem PROMPT "Dial"
- DEFINE BAR 4 OF pop_modem PROMPT "Hang Up"
-
- ON SELECTION POPUP pop_modem =_ct_modem(portid, BAR())
- ACTIVATE POPUP pop_modem
- RELEASE pop_modem
- RETURN (0)
-
-
-
- FUNCTION _ct_modem
- PARAMETERS portid, choice
- PRIVATE motype
- DIMENSION modem_type[17]
-
- DO CASE
- CASE choice = 1
- CASE Choice = 2
- ret=status_msg(0, "Obtaining modem type information...")
- motype = modem_id(portid)
- ret=status_msg(0, "Modem Type is: " + get_modem(motype))
- =mspause(1000)
- ret=status_msg(0, "Initializing...")
- =modem_init(portid, motype)
- ret=status_msg(0, "Ready")
- CASE Choice = 3
- IF number == ""
- ret=status_msg(0, "No telephone number specified")
- =mspause(500)
- ELSE
- ret=status_msg(0, "Dialing: " + LTRIM(number))
- ret = modem_dial(portid, number)
- ret = status_msg(0, "Dial Return Code: " + STR(ret))
- =INKEY(0)
- IF ret < 0
- =status_msg(0, "Modem not initialized")
- =INKEY(0)
- ENDIF
- ENDIF
- CASE Choice = 4
- =status_msg(0, "Attempting to hang up modem")
- ret = modem_hangup(portid)
- IF ret >= 0
- =status_msg(0, "Modem successfully hung up")
- ELSE
- =status_msg(0, "Error while attempting to hang up modem")
- ENDIF
- ENDCASE
- DEACTIVATE POPUP pop_modem
- RETURN (Choice)
-
-
-
- FUNCTION get_modem
- PARAMETERS type
- PRIVATE strtype
-
- DO CASE
- CASE type = 0
- strtype = "UNKNOWN"
- CASE type = 300
- strtype = "Hayes Compatible 300 bps"
- CASE type = 1200
- strtype = "Hayes Compatible 1200 bps"
- CASE type = 1300
- strtype = "Hayes Compatible 1200EF"
- CASE type = 2400
- strtype = "Hayes Compatible 2400 bps"
- CASE type = 9600
- strtype = "Hayes Compatible 9600 bps"
- CASE type = 14400
- strtype = "Hayes Compatible 14400 bps"
- CASE type = 961
- strtype = "TELEBIT RA12C"
- CASE type = 962
- strtype = "TELEBIT RA12E"
- CASE type = 963
- strtype = "TELEBIT RM12C"
- CASE type = 964
- strtype = "TELEBIT T18PC"
- CASE type = 965
- strtype = "TELEBIT T18SA"
- CASE type = 966
- strtype = "TELEBIT T18RMM"
- CASE type = 901
- strtype = "UDS 9600"
- CASE type = 1
- strtype = "UDS V3224"
- CASE type = 2
- strtype = "UDS V3225"
- CASE type = 144
- strtype = "USR 9600 DUAL STD"
- OTHERWISE
- strtype = "UNKNOWN"
- ENDCASE
- RETURN (strtype)
-
-
-
- *
- * DO_FILE_RECEIVE(expN portid)
- * Show a menu to invoke file transmission.
- * Called from mainmenu()
- *
- FUNCTION do_file_receive
- PARAMETERS portid, col
- PRIVATE fname, fsize, ret, protocol
-
- ret = -1
- fsize = 0
- DO WHILE .T.
- protocol = get_protocol(col)
- IF protocol == 0
- EXIT
- ENDIF
- IF protocol == KERMIT .OR. protocol == YMODEM;
- .OR. protocol == ZMODEM .OR. protocol == YMODEM_G
- fname = " "
- ELSE
- fname = get_filnam(.F.)
- ENDIF
- IF LEN(fname) != 0
- =save_xlat(portid)
- =set_rx_xlat(portid, LOCAL_ECHO, FALSE) && optionally turn off RX local echo
- =set_tx_xlat(portid, LOCAL_ECHO, FALSE) && optionally don't echo TX data
-
- * USE XONXOFF FLOW CONTROL (THIS LETS THE RECEIVER WRITE TO DISK) *
- IF protocol = ASCII
- =set_rx_xlat(portid, FLOWCTL, XONXOFF) && better accept flow control if > 2400 bps
- =set_rx_xlat(portid, INTERBYTE_DELAY, 5000) && set interbyte delay to 5000 ms.
- ENDIF
- * Define a Window to show file transfer status reports.
- * Note that the status window could be used for file transfer status
- * reports instead.
- =display_xfer(5, 5, fname, fsize)
- * RECEIVE STARTS HERE (buffer size may be adjusted)
- ret = freceive(portid, protocol, 6*1024, "xfer_progress")
- * ret = freceive(portid, protocol, 4096, NULL) && no progress reporting
- =status_msg(0, STR(ret))
- =SOUND_ON(100, 500)
- DEACTIVATE WINDOW w_xfer
- =status_msg(0, "FINISHED")
- IF protocol = ASCII
- COPY FILE "TEMP0000.$$$" TO fname
- ENDIF
- DEACTIVATE WINDOW w_xfer
- =restore_xlat(portid)
- ELSE
- =status_msg(0, "File not found")
- ENDIF
- ENDDO
- RETURN (ret)
-
-
-
- *
- * DO_FILE_SEND(expN portid)
- * Show a menu to invoke file transmission.
- * Called from mainmenu()
- *
- FUNCTION do_file_send
- PARAMETERS portid, col
- PRIVATE fname, ret
-
- ret = -1
- DO WHILE .T.
- protocol = get_protocol(52)
- IF protocol == 0
- EXIT
- ENDIF
- FOR i = 0 TO 10
- fname = get_filnam(.T.)
- IF LEN(fname) != 0
- ret = fqueue(fname)
- IF ret != 0
- EXIT
- ENDIF
- IF protocol == ASCII .OR. protocol == XMODEM .OR. ;
- protocol == XMODEM_CRC .OR. protocol == XMODEM_1K
- EXIT
- ENDIF
- ELSE
- EXIT
- ENDIF
- NEXT
- IF ret == 0
- =save_xlat(0)
- * =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && optionally echo RX to screen
- * =set_tx_xlat(portid, LOCAL_ECHO, TRUE) && optionally turn on TX local echo
-
- * USE XONXOFF FLOW CONTROL (THIS LETS THE RECEIVER WRITE TO DISK) *
- IF protocol = ASCII
- =set_rx_xlat(portid, FLOWCTL, XONXOFF) && better accept flow control if > 2400 bps
- ENDIF
- fsize = NULL
- * =status_msg(0, "Sending: " + fname) && use this for status window
- =display_xfer(5, 5, fname, fsize)
- ret = fsend(portid, protocol, 4*1024, "xfer_progress") && send the file as ASCII
- =INKEY(0.5)
- DEACTIVATE WINDOW w_xfer
- =status_msg(0, "FINISHED!")
- =restore_xlat(0)
- ENDIF
- ENDDO
- RETURN (ret)
-
-
-
- *
- * DO_TERM_EMUL(expN portid)
- * Show a menu that allows the user to select a terminal to emulate.
- * Called from mainmenu()
- *
- FUNCTION do_term_emul
- PARAMETERS portid, col
- PRIVATE nChoice, termtype
-
- termtype = get_terminal(col)
- IF termtype != CT_EOF
- * USE XONXOFF FLOW CONTROL (THIS LETS US BUFFER RECEIVED DATA) *
- =set_tx_xlat(portid, FLOWCTL, XONXOFF) && better accept flow control if > 2400 bps
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && echo RX data to screen
- =set_tx_xlat(portid, LOCAL_ECHO, FALSE) && (optionally) don't echo TX data
- ret = term_init(portid, termtype)
- =term_set(portid, TERM_ROWS, WROWS("w_term")) && Must be interior height of window+1
- * =term_set(portid, TERM_ROWS, 25) && Won't work. Must be interior height of window+1
- =term_set(portid, TERM_COLS, 80)
- =term_set(portid, TERM_KEYCLICK, 0) && Drives you mad!
- IF ret < 0
- =status_msg(0, "Insufficient memory for terminal emulation")
- ENDIF
- ENDIF
- RETURN (ret)
-
-
-
- *
- * GET_TERMINAL(expN tr, expN lc)
- * Show a menu that allows the user to select a terminal to emulate.
- * Called from do_terminal_menu()
- *
- FUNCTION get_terminal
- PARAMETER col
- PRIVATE termtype
-
- termtype = 0
- DEFINE POPUP pop_terminal FROM 02, col;
- IN WINDOW w_main;
- SHADOW
- DEFINE BAR 1 OF pop_terminal PROMPT " \<TTY "
- DEFINE BAR 2 OF pop_terminal PROMPT " \<ANSI.SYS "
- DEFINE BAR 3 OF pop_terminal PROMPT " ANSI \<X3.64 "
- DEFINE BAR 4 OF pop_terminal PROMPT " T\<V925 "
- DEFINE BAR 5 OF pop_terminal PROMPT " VT\<52 "
- DEFINE BAR 6 OF pop_terminal PROMPT " VT\<100 "
- DEFINE BAR 7 OF pop_terminal PROMPT " VT\<220 "
-
- ON SELECTION POPUP pop_terminal termtype=_terminal_menu(BAR())
- ACTIVATE POPUP pop_terminal
- DEACTIVATE POPUP pop_terminal
- RELEASE POPUPS pop_terminal
- RETURN (termtype)
-
-
- FUNCTION _terminal_menu
- PARAMETERS nChoice
- PRIVATE termtype
-
- DO CASE
- CASE nChoice = 1
- termtype = TTY
- CASE nChoice = 2
- termtype = ANSI_SYS
- CASE nChoice = 3
- termtype = ANSI_X364
- CASE nChoice = 4
- termtype = TV925
- CASE nChoice = 5
- termtype = DEC_VT52
- CASE nChoice = 6
- termtype = DEC_VT100
- CASE nChoice = 7
- termtype = DEC_VT220
- OTHERWISE
- termtype = CT_EOF
- ENDCASE
- =status_msg(0, "Terminal: " + ALLTRIM(PROMPT()))
- RETURN (termtype)
-