Short: Timer for serial port Carrier Detection Author: simon@studio.woden.com (Simon N Goodwin) Uploader: simon@studio.woden.com (Simon N Goodwin) Version: 1.3 Type: dev/basic OVERVIEW This simple HiSoft BASIC program from my Amiga Format series 'Banging The Metal' shows a low-level way to record time spent online, for communication software like TERM as well as TCP/IP stacks. It works by reading the standard serial port hardware. Similar hacks are possible for other interfaces, if you know their port addresses. There are two versions - the simple one counts in seconds, while the other counts in traditional Babylonian hours, minutes and seconds ;-) CAVEATS Both get confused by signed arithmetic at midnight. They are bare-bones examples and intended to show how low-level information can be obtained, not what to do with it, or when it might be useful: typically only on your own system, for your own purposes - metal bashing is otherwise rightly disparaged because it leads to unrepresentative and incompatible software. OPERATION The example directly reads a bit in port A on CIAB, so it suits all real Amigas and accurate emulations - but not clones like Draco that lack CIAs. Signals are generally 'active low' - so a 0 level on bit 5 of CIAB port A indicates modem carrier detection, for instance. In assembler you'd write: btst #5,$BFD000 bne NoCarrier The BASIC equivalent is: IF PEEK(12570624) AND 32 THEN PRINT "No Carrier" The example is an elaborated version of this test. Notice that it does NOT busy-wait - the WAIT command ensures that the majority of CPU time is made available to other tasks and processes. Hardware PEEKs need not be system-hostile! HISTORY Originally written by Simon N Goodwin (simon@silicon.studio.co.uk) for the Amiga Format Banging The Metal tutorial, first published May 1999. Aminet release by mutual agreement of the author and first publisher. No exclusive rights relate to this example. It may be freely copied only in its entirety. DIVERSION When programming the serial or parallel port, utilities like MapDevice may divert calls for SER: or PRT: to alternative hardware. Opening the standard name doesn't necessarily allocate the default hardware. Check this with another PEEK, using the eponymous command from Aminet/util/cli/PEEK_POKE.lha PEEK DEV=serial long 10 string This returns the name of the /real/ device selected when you open the device named after DEV= above, such as "pit.device".for Multiface parallel redirection, or "duart.device" for GVP serial ports.