Here is a list of the commands that the current version of the Ser-USB
Driver can execute through its command pipe interface. This interface
supports run-time interrogation and configuration of the driver and is
intended to enable the development of utility software that does not require
detailed knowledge of the underlying hardware. When the necessary code
support is completed there will also be commands for mounting/unmounting
partitions.
This interface has primarily come about as a result of including run-time
debugging so I would be very interested to hear any views on its usefulness,
or what other features might be desirable.
usbcmd_get_dr_ver
$01 Get Driver Version
Command Size: Byte
Response Size: Long
Returns the Ser-USB Driver version as four characters.
usbcmd_get_hw_ver
$02 Get Hardware Version
Command Size: Byte
Response Size: Long
Returns the hardware (USBWiz) version as four characters.
usbcmd_get_hw_type
$03 Get Hardware Type
Command Size: Byte
Response Size: Long
Returns the hardware type as four characters.
USBWiz returns "USBW".
Other hardware types are supported as per the original QUBIDE defines
(though these are unlikely to be encountered).
usbcmd_get_q_stats
$04 Get I/O Queue Stats
Command Size: Byte
Response Size: Long
Returns statistics about the I/O Queue as a long word.
High word contains the maximum I/O Queue size in requests.
Low word contains the current number of entries in the queue.
usbcmd_get_io_state
$05 Get I/O State
Command Size: Byte
Response Size: Long
Returns information about the currently executing I/O operation.
High word contains the op code of the current operation (ip_op_read=1 or
io_op_write=2).
Low word contains the stage number in the operation.
usbcmd_get_flags
$06 Get Flags
Command Size: Byte
Response Size: Long
Returns all flag bytes as one long word.
High word contains the debug flags in the top 8 bits, the USBWiz flags in
the bottom 8.
Low word contains 0 in the top 8 bits, the Ser-USB Driver flags in the
bottom 8.
usbcmd_get_mphys_drv
$10 Get Mapped Physical Drive
Command Size: Byte with operand in low nibble ($11..$18)
Response Size: Long
Returns the physical drive/partition that is currently mapped to a USB drive
number.
High word contains the Logical Unit Number (LUN).
Low word contains the partition number.
The low nibble of command $10 is a logical drive number in the range 1..8;
other values always return 0.
usbcmd_clr_flag
$e0 Clear Flag
Command Size: Byte with operand in low nibble ($e0..$ef)
Response Size: Long
Clear a Ser-USB Driver or USBWiz flag.
Returns the previous state of the flag as 0 or 1.
The low nibble of command $e0 is broken down as follows:
Bits 0..2 = Flag number (0..7).
Bit 3 = 0 for Ser-USB Flags, or 1 for USBWiz Flags.
usbcmd_set_flag
$f0 Set Flag
Command Size: Byte with operand in low nibble ($f0..$ff)
Response Size: Long
Set a Ser-USB Driver or USBWiz flag.
Returns the previous state of the flag as 0 or 1.
The low nibble of command $f0 is broken down as follows:
Bits 0..2 = Flag number (0..7).
Bit 3 = 0 for Ser-USB Flags, or 1 for USBWiz Flags.
Here is a tidier version of the example S*BASIC program that I posted in my
last mail. It shows how to use the interface in its current form. Requires
SMSQ & Turbo Toolkit (and the Ser-USB Driver).
100 OPEN #4,"NUL"
110 OPEN #5,"NUL"
120 SET_CHANNEL #4,USB_PIPE_W
130 SET_CHANNEL #5,USB_PIPE_R
140 PRINT "The Response to Command $01 (Get Driver Version) was: " &
GetResponse$(1)
150 PRINT "The Response to Command $02 (Get Hardware Version) was: " &
GetResponse$(2)
160 PRINT "The Response to Command $03 (Get Hardware Type) was: " &
GetResponse$(3)
170 PRINT "The Response to Command $04 (Get I/O Queue Status) was: " &
GetDWordResponse$(4)
180 PRINT "The Response to Command $05 (Get I/O State) was: " &
GetDWordResponse$(5)
190 PRINT "The Response to Command $06 (Get Flags) was: " &
Get32BitResponse$(6)
200 PRINT "The Response to Command $11 (Get Mapped Physical Drive 1) was: "
& GetDWordResponse$(HEX("11"))
210 REMark =======================================================
220 DEFine FuNction GetResponse$(Cmd%)
230 LOCal Response$, This$, Bytes%
240 PRINT #4;CHR$(Cmd%);
250 Response$= ""
260 Bytes%= 0
270 REPeat GetResponse
280 This$= INKEY$(#5)
290 IF This$ = "" THEN NEXT GetResponse
300 Response$= Response$ & This$
310 Bytes%= Bytes% + 1
320 IF Bytes% = 4 THEN EXIT GetResponse
330 END REPeat GetResponse
340 RETurn Response$
350 END DEFine GetResponse$
360 REMark =======================================================
370 DEFine FuNction GetDWordResponse$(Cmd%)
380 LOCal Response$, High%, Low%
390 Response$= GetResponse$(Cmd%)
400 High%= CODE(Response$(1))*256 + CODE(Response$(2))
410 Low%= CODE(Response$(3))*256 + CODE(Response$(4))
420 RETurn High% & '/' & Low%
430 END DEFine GetDWordResponse$
440 REMark =======================================================
450 DEFine FuNction Get32BitResponse$(Cmd%)
460 LOCal Response$, High%, Low%
470 Response$= GetResponse$(Cmd%)
480 High%= CODE(Response$(1))*256 + CODE(Response$(2))
490 Low%= CODE(Response$(3))*256 + CODE(Response$(4))
500 RETurn BIN$(High%,16) & "/" & BIN$(Low%,16)
510 END DEFine Get32BitResponse$
ps The current driver version is 0.03 Build 005:
All legacy QUBIDE-era hard drive handling code has now been stripped out.
(The last remnants of the temporary ATAPI emulator layer are gone!)
Internal storage has been reorganised and significantly less RAM is now
used.
Driver logic has been separated from the hardware interface, so that the
re-implementation of just a few functions should make it possible to support
alternative hardware.
I hope to begin the first pass of performance and compatibility testing on
Aurora/QL this week.
Adrian
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm