[comp.sys.cbm] Using RS-232 & Serial Bus Simultaneously

bmhochberg@watnot.UUCP (04/05/87)

---

	When I originally purchased my Commodore 64, I was under the
impression that the RS-232 and the serial bus could not be operated at the
same time due to competing NMI's.  My understanding was that to download a
file from the modem, you had to hold the downloaded file in memory.  Upon
the end of transmission, the RS-232 device was closed and the file was
written to disk.  If necessary, the modem was then re-opened.  I knew that
this problem did not exist if the disk drive was hooked up through an IEEE
cartridge.

	Now that I have my 128 and a better modem (1670), I've been doing a
lot more telecommunicating.  Of the software I have, various up/download
protocols are supported (i.e. Punter, XMODEM, etc.).  What I have noticed,
though, is that the disk file is opened at the start of the file transmission
and is written to while the file is being transmitted over the modem.

	Can anybody explain how this simultaneous modem/disk activity is
possible?


-------------------------------------------------------------------------------
Bryan M. Hochberg             UUCP:  {abunchasystems}!watmath!watnot!bmhochberg
U. of Waterloo, Ont.          MAIL:  P.O. Box 460 E4-201
                                     Waterloo, Ontario
                                     N2J 4B6
                              BELL:  (519) 884-7527
-------------------------------------------------------------------------------
"Don't let your schooling interfere with your education." - Mark Twain

elg@killer.UUCP (04/15/87)

in article <12799@watnot.UUCP>, bmhochberg@watnot.UUCP says:
> 	When I originally purchased my Commodore 64, I was under the
> impression that the RS-232 and the serial bus could not be operated at the
> same time due to competing NMI's. 
  Right. When you do disk access, it disables the RS232 NMIs. The RS232 port
would otherwise be using the same timers needed for disk timing (just hate
bit-banging code, huh?). Which would not work right.

 My understanding was that to download a
> file from the modem, you had to hold the downloaded file in memory.  Upon
> the end of transmission, the RS-232 device was closed and the file was
> written to disk.
 Wrong. You merely can't do the two at the same time. You can get 10 bytes,
then write ten bytes to disk, then get 10 bytes more, if you have a
handshaking protocol going (e.g. XON-XOFF, Punter, or Xmodem). The disk drive
operates fine while the RS-232 device is open... 

> 	Now that I have my 128 and a better modem (1670), I've been doing a
> lot more telecommunicating.  Of the software I have, various up/download
> protocols are supported (i.e. Punter, XMODEM, etc.).  What I have noticed,
> though, is that the disk file is opened at the start of the file transmission
> and is written to while the file is being transmitted over the modem.
> 
> 	Can anybody explain how this simultaneous modem/disk activity is
> possible?

They aren't simultaneous. Take Xmodem (Punter is the same, but more
complicated). It sends an ACK to the sender telling it to send another 127
bytes of data. It recieves those 127 bytes, and checksums them. If they are
good, it writes them to disk and then ACKS for another 127 bytes. If bad, it
sends a NAK telling the sender to re-send. Note that the disk drive does NOT
have to be used at the exact same time as the modem, because those 127 bytes
are being held in memory (wouldn't do to write a bad block to disk! And you
can't know whether it's good or bad until you've recieved the last byte). 

Meanwhile, on the sending end, the sender gets an ACK. It then goes and reads
127 bytes off of disk into a memory buffer, and checksums it & makes a packet
out of it. And only THEN sends it to modem.

Look ma, no mirrors! Remember, things which APPEAR to be simultaneous, usually
aren't... 

--
Eric Green   elg%usl.CSNET     Hacker-in-training, University of SW Louisiana
{cbosgd,ihnp4}!killer!elg            Home of Bayou Telecommunications.
Snail Mail P.O. Box 92191        
Lafayette, LA 70509            BBS #: (318)-984-3854  1200 baud