-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserialdev.txt
165 lines (104 loc) · 5.5 KB
/
serialdev.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
All peripherals using serial connection must follow these standards
0. How to communicate
0.1 Master-to-Slave mode
- Master device must send enquiry query, and when slave device report READY, master must pull the answer from the slave
0.2 Master-to-Master mode
- One peer sends enquiry, and other peer writes the answer into the requester device. You know the transaction is done
when other peer reports READY, NOT READY, and READY again.
1. ENQUIRY commands
1.0 All ENQUIRY commands have following syntax:
<COMMAND-STRING> 0x17
<COMMAND-STRING> 0x1E <ARGUMENTS-STRINGS SEPARATED BY 0x1F> 0x17
In case of positive acknowledge:
0x06 <ANSWER-STRINGS SEPARATED BY 0x1F> 0x17
In case of negative acknowledge (e.g. error messages):
0x15 <ANSWER-STRINGS SEPARATED BY 0x1F> 0x17
All ENQUIRY commands are RECOMMENDED to be no larger than 4096 bytes
STRINGs only consists with printable ASCII subset
1.1 WHO-ARE-YOU commands
DEVTYP
Description: type of the device
Returns: type of the device, of which but not exhaustive:
- PRNT: Printer
- STOR: Storage device (floppy drive, etc.)
- COMM: Modem (slave-mode device)
- COMP: Modem (master-mode device, typically an other computer connected though a null-modem)
- HTTP: Internet Modem
DEVNAM
Description: enquires canonical device name
Returns: canonical device name in ASCII, maximum 4095 bytes
Note: non-standard device types must have LONGER THAN 4 characters of DEVTYP
1.2 CONTROL commands
DEVRST
Description: resets the device
Returns: none
DEVSTU
Description: reads status of the device, if applicable
Returns:
<status code> <0x1F> <message string> 0x17
Status Code is single byte number, negative numbers (or >= 128) is used for negative response by convention.
Also see section 1.0
2. Device-specific commands
2.0 Command formats
Device-specific commands does NOT have any header nor footer
2.1 STORage devices
2.1.0 NOTE
- comma-followed-by-drive-number can be omitted; drive number 1 will be substituted
- drive number always starts at 1
2.1.1 File Control
OPENR"<path to file>",<drive number>
Description: opens the file for reading
OPENW"<path to file>",<drive number>
Description: opens the file for writing
OPENA"<path to file>",<drive number>
Description: opens the file for appending (a variant of write)
WRITE<bytes to write>
Description: puts the device into WRITE mode and sets internal counter. Any subsequent messages will be interpreted
as-is, get written directly to the file, and will decrement the internal counter accordingly.
The number of bytes are required because of a nature of block-transfer, where every message is always in
the length of the block size.
FLUSH
Description: flushes any internal output buffer and no longer puts the device to WRITE mode
READ
Description: reads one block of file. Any subsequent read attempts will return next block. If file size is lesser
than a single block, rest of the bytes will be filled with zero, and size-of-the-block (see terranmon.txt)
will be set accordingly.
CLOSE
Description: closes any file that is open.
LOADBOOT,<drive number>
Description: loads a bootloader so that it can be read by the host device through the serial connection.
Technically there's no limit on the size of the bootloader but it's up to the BIOS to read more than
a single block.
CHTYPE,<file type>,<drive number>
Description: changes the open file's file type (or its extension)
GETLEN
Description: returns size of the file/number of files within the directory
LIST
Description: lists contents of the open (with OPENR) directory in READABLE FORMAT
(no 0x17 at the end, terminates string with zero)
When a file is opened instead of a directory, its filename should be printed
Raw filesystem (e.g. EPROM) should return first 4096 bytes of its contents.
LISTFILES
Description: same as the LIST, but in machine readable format, which follows the following format:
<file/dir type> <filename> [<0x1E for separator> <file/dir type> <filename> ...] <0x17>
file/dir type: 0x11 for file, 0x12 for directory
USAGE,<drive number>
Description: returns following values: TOTAL_SPACE 0x1E USED_SPACE 0x1D TOTAL_FILE_COUNT 0x1E TOTAL_DIRECTORY_COUNT in
ASCII string.
For non-hierarchical system, TOTAL_DIRECTORY_COUNT is always 0x30 (ASCII string "0")
FSTYPE,<drive number>
Description: returns filesystem type in plain string, of which but not limited to:
- TREE: any generic filesystem with recursive directories and multiple files.
When emulators use filesystem of running OS for the disk implementation (and not use proprietary binary
file), this type should be returned.
- FLAT: filesystem without directories and can hold multiple files. E.g. Commodore 64
- RAW: no filesystem is used. E.g. EPROM
When disk image is used for emulation, their identifier should be returned. E.g. FAT, TEVD
2.1.2 File type dictionary
- PRG: executable
- TXT: text document
- BIN: binary data
- SEC: pseudo-type used by an pseudo-file called "!BOOTSEC", which is a boot sector
File type is independent of the "extension", but just a marker for an auto-execution (firstmost PRG file will be
auto-run). If your file is neither PRG nor TXT, use BIN.
Operation system may choose to ignore this feature and handle the "extension" by itself