Hello! Michał Pleban wrote: > If you need, I can dig my old code and try to remember what exacly > happened there and why I did this the way I did. Allright, I analyzed the code anyway, was not that hard. Bad news: the timeout/device not present error is not returned reliably from the IEEE routines at all. In fact, you will only get it in some very specific conditions, most likely when you instruct the device to TALK and it does not talk. The error is _not_ returned at all when you order it to LISTEN and it does not listen. So basically there is no simple method of determinig whether a device exists or not. Therefore what I did was to create a device detection routine which is called before TALK or LISTEN. The routine opens a channel to the device named "#9" which calls for reading a buffer number 9, which is supposed not to exist (the CBM floppies have at most 8 buffers as I recall). So if the device returns an error "file not found", you can safely assume that it exists on the bus. If there is no error returned, or timeout, or any other condition, I assume the device is not present (as you can see above, opening a file on nonexisting IEEE device does not return any error!!!). This status is then remembered in a status byte, so that another call to TALK/LISTEN does not invoke the routine again (this would be a big time overhead). In fact, I have a short FIFO of remembered statuses so that more than one can be stored (that is useful, for example, when copying files from one drive to another). Then, upon return from every IEC routine I check whether there is a timeout error. If there is, I clear the flag so the device will be rechecked again. I do not do this on return from IEEE routines because, as I said, they rarely ever return anything useful. All this has some unpleasant side effects: * It is doubtful whether the detection routine will work with printers. I have naver had any Commodore printer so I have no idea what would they do when I try to open a "#9" file on them. Hopefully they would return an error too, so the code would still work. * If a IEEE device is found, disconnected and IEC device with the same number is connected, the computer will not be able to detect this. I have not found aby convenient workaround for this since the IEEE routines do not return much information about error conditions. The only way here is for the user to clear the flag manually with a POKE. Fortunately at least the other way around works. Regards, Michau. Message was sent through the cbm-hackers mailing listReceived on 2014-11-07 14:00:02
Archive generated by hypermail 2.2.0.