Next Previous Contents

2.1 cbmctrl

Synopsis: cbmctrl ACTION ...

cbmctrl is used to send commands to external devices.

Actions

Here's a list of all valid actions for cbmctrl:

listen device secadr

Tell device device to listen on secondary address secadr. Until the next unlisten command, everything written to the special device /dev/cbm will be received by this device.

This command corresponds to the following 6502 assembly code on a C64:


lda #device
jsr $ffb1
lda #secadr
ora #$60
jsr $ff93

talk device secadr

Tell device device to talk on secondary address secadr. Until the next untalk command, data from this device can be received device by reading from the special device /dev/cbm.

This command corresponds to the following 6502 assembly code on a C64:


lda #device
jsr $ffb4
lda #secadr
ora #$60
jsr $ff96

unlisten

Ends communication with listening devices after a listen command. This corresponds to the C64 kernel routine $ffae.

untalk

Ends communication with talking devices after a talk command. This corresponds to the C64 kernel routine $ffab.

open device secadr filename

Open file filename on device device. After opening, data can be read/written by sending a talk resp. listen command with the secondary address secadr.

If secadr is greater than 1, the file type and access mode must also be specified by appending ,type,mode to filename. Valid types are D, P, S, U, R (DEL, PRG, SEQ, USR, REL), valid modes are R for reading and W for writing.

close device secadr

Close the file associated with secondary address secadr on device device.

status device

Copies input from device device, secondary address 15 (command/status channel), to the standard output stream. Note that all upper case characters are changed to lower case. Carriage return (0x0d) is also changed to linefeed (0x0a).

This command is similar to (in this case, no character conversions would be made)


cbmctrl talk device 15
cat /dev/cbm
cbmctrl untalk

command device cmdstr

Sends cmdstr to device device, secondary address 15 (command/status channel). Since there is no PetSCII->ASCII conversion, commands must be sent in upper case (kind of poor man's PetSCII conversion). This is because charset conversion would break the M-W and M-E commands.

This command is identical to


cbmctrl listen device 15
echo -n cmdstr > /dev/cbm
cbmctrl unlisten

dir device

Read directory from disk in device device, print on standard out.

download device address count

Read count bytes from drive memory, starting at address via one or more M-R commands. Memory contents are written to standard out.

upload device address file

Send file to drive memory, starting at address via one or more M-W commands. If address is -1, the first to bytes from file are considered as start address.

reset

Triggers hardware reset on all attached devices. Control is returned after a five second delay to make sure all devices are ready.

detect

Identify connected devices (considers devices 8-15)

cbmctrl Examples

Send file contents to printer 4:


cbmctrl listen 4 0
cat file > /dev/cbm
cbmctrl unlisten

Copy file to disk drive 8:


cbmctrl open 8 2 FILENAME,P,W
cbmctrl listen 8 2
cat file > /dev/cbm
cbmctrl unlisten
cbmctrl close 8 2

Copy file from disk drive 8:


cbmctrl open 8 2 FILENAME,P,R
cbmctrl talk 8 2
cat /dev/cbm > file
cbmctrl untalk
cbmctrl close 8 2

Dump 1541 ROM:


cbmctrl download 8 0xc000 0x4000 > 1541.rom


Next Previous Contents