|  Posted By
   SVS on 2012-02-23 05:56:03
   |   Device detecting
  Hello, is there a possible way to detect the existence of a connected device (say a serial), without to search for a Basic "?DEVICE NOT PRESENT ERROR" ?
  |   
 |  
Posted By
   Gaia on 2012-02-23 15:39:24
  |   Re: Device detecting
  Something like this should work:
  . 05FF  78       SEI                     . 0600  A9 04    LDA #$04       ; set ATN to low         . 0602  05 01    ORA $01                 . 0604  85 01    STA $01                 . 0606  A2 00    LDX #$00                . 0608  CA       DEX                     . 0609  D0 FD    BNE $0608              ; just wait a little . 060B  24 01    BIT $01                ; check highest bit of $01 (DATA low) . 060D  00       BRK                     G5FF                                    
 
 
  Now you'll have the highest bit of SR (status register) set if no serial device is present, and zero in case there is. Change the BRK to RTS and insert a CLI in case you are using it as a subroutine.
  |   
 |  
Posted By
   rudis on 2012-02-24 15:55:39
   |   Re: Device detecting
  $04 is in zeropage?
  |   
 |  
Posted By
   Csabo on 2012-02-24 16:09:27
  |   Re: Device detecting
  Yes, $04 is a zeropage address. Zeropage means addresses from $00-$FF. (Though Gaia wrote #$04 above, so that's an immediate value, not an address.)
  |   
 |  
Posted By
   SVS on 2012-02-26 04:10:08
   |   Re: Device detecting
  Hi, thank you all for your suggestions. I've find that the easy way for detecting existence/connection of a peripheral (serial and others) is testing ST after CLOSE operation. In fact for some reasons, ST is not affected by a simple OPEN (like OPEN 15,8,15) but indeed by a CLOSE. It is sufficient to do: OPEN, 15,9,15: CLOSE 15: IF ST THEN ... ST assumes the value of 0 if device is existing and replying, value of -128 when missing.
  P.S. Now I run to update SVS-Ultimate map!  
  |   
 |  
Posted By
   siz on 2012-02-26 05:57:12
  |   Re: Device detecting
  An OPEN without a command only prepares the channel for I/O. Actual communication happens only for a PRINT# or a CLOSE.  That's why you can detect a device not present only at CLOSE time. Perhaps try OPEN15,dd,15,"UI". (But be careful because my 1541-II with SpeedDOS halts for UI command. :/ )
  |   
 |  
  |   |   
  
 
 Copyright © Plus/4 World Team, 2001-2025. Support Plus/4 World on Patreon |