
File transfer over a com port.
Quote:
> >I am working on a problem that I have and I think someone in these two
> >groups may be able to help me. Can somone write a simple file transfer
> >program that would allow me to send mode.com to a laptop with a bad floppy
> >and without a copy of mode? it needs to go from the pc's com2 to the
> >laptops com1 throuhg the use of ctty on the laptop. it does not need to be
> >fast 2400 is the fastest i want to try 300 baud would be good. is this
> >possible and would someone please help me ? I only have the dos 6.22
> >version of qbasic.
Do you have Windows? The Windows terminal program is great for
transfering binaries (make sure you use hardware flow control--I don't think
XON/XOFF works with binaries).
You could also write your own CTS/RTS hardware handshaking routine
for binary transfers. Modify this prog a little:
'BY STEVEN SENSARN
DIM BYTE AS STRING * 1
CLS
'change this line to your settings
OPEN "COM2:9600,N,8,1,CD600,CS1,OP0" FOR RANDOM AS #1
DO
'instead of reading the byte from the keyboard, read it from the file
BYTE = INKEY$
IF BYTE <> " " THEN
'i don't know what the ascii code for an EOF is--change 27 to that
IF BYTE = CHR$(27) THEN CLOSE : END
'waits for thr empty in lsr (i think--i forget)
'notice &H2F8--change this to the base port address of your modem:
'COM1:3F8h
'COM2:2F8h
'COM3:3E8h\may have gotten these mixed up--but your not using them
'COM4:2E8h/anyways
WAIT (&H2F8 + 5), 32
'send byte across port
'change this &h2F8 too
OUT &H2F8, ASC(BYTE)
END IF
'if char in rbr then it is read
'change this &h2F8 too
IF (INP(&H2F8 + 5) AND 1) = 1 THEN
'read byte
'change this &h2f8 too
BYTE = CHR$(INP(&H2F8))
'instead of sending the byte to the screen, save it to the file
PRINT BYTE;
END IF
LOOP
Even after changing that program, I'm not sure if it would work due to the
EOF thing (I haven't done much file transfer stuff).
Quote:
> On one machine:
> OPEN "COM1:1200,N,8,1" FOR BINARY AS #1
> OPEN "mode.com" for output As #2
> DO
> LOOP WHILE EOF(1)
> DO
> A$=GET$(1,LOF(1))
> Print #2, A$;
> LOOP UNTIL EOF(1)
> END
> On the other
> OPEN "COM2:1200,N,8,1" FOR RANDOM AS #1
> OPEN "mode.com" for input as #2
> DO
> A$=INPUT$(2,1)
> PRINT #1, A$;
> LOOP UNTIL EOF(2)
> END
> This should work - however, it is 1:38am. The major screwup will
> come if I forgot which input/output verbs go with which file modes.
> I believe with binary it is GET$/PUT. With every mode, print should
> work.
> However, if I did screwup the syntax, just look in the online help.
> The basic (pun not intended) is that the receiving end opens the
> port, waits for bytes to start arriving, writes them one-by-one to
> the output file and quits when they stop. The sender opens the file
> and starts pumping out bytes until done and then quits.
--
______________________________
Steven Sensarn
______________________________