DESCRIPTION OF USER PART OF REX 6000 MEMORY Last updated: Wed Feb 27 17:15:38 2002 (C) Marek Wodzinski (majekmamy.to) Update: John Heasley - a few grammatical and typographical corrections Probably any new version of this document will be available from: http://rex.mamy.to 0. TABLE OF CONTENTS 1. INTRODUCTION 2. KNOWN THINGS (PROVEN) 2.1 SESSION 2.2 LOGICAL PAGES 2.3 DSSR COMMAND 2.4 DSSW COMMAND 2.5 PAGE FORMAT 2.5.1 PAGE AND 'BIG' PAGE 2.5.2 DATA FIELDS IN PAGE 2.5.3 RECORD FORMAT 3. SPECULATIONS (UNPROVEN) 3.1 SPECIAL PAGES 3.1.1 PAGE FFFF 3.1.2 PAGE 0000 3.1.3 PAGE 0001 3.2 HOW TO FIND DATA 3.2.1 START 3.2.2 DATABASE DEFINITIONS 3.2.3 READING DATABASE 3.2.4 FIELD TYPES 3.2.5 DATABASE NUMBERS 4. WHAT IS NEEDED 1. INTRODUCTION This is summary from my work on serial communication with Rex 6k. User memory - logical pages of Rex memory witch we can read or write with DSSR or DSSW commands. All sync software use these commands to synchronize with Rex 6000. Please send all bugs, corrections or updates (in text too) to majekmamy.to. 2. KNOWN THINGS (PROVEN) 2.1 SESSION Every session starts from reading: a) page FFFF b) page 0000 c) page 0001 For descriptions of these pages see 3.1 2.2 LOGICAL PAGES a) every page has maximum 512 bytes b) for now, it is not known how many pages exist. c) pages are read with the DSSR command (details see 2.3) d) pages are written with the DSSW command (details see 2.4) e) these are on top of physical pages which you know from DSFR, DSFW or DSFE commands and they ARE NOT the same. 2.3 DSSR COMMAND format: DSSRxxxxyyyyzzzz0001cc\x0A (nl on end of line) xxxx - logical page yyyy - offset (where to start reading) zzzz - how much data you request cc - checksum (sum of all previous bytes modulo 256). all fields are in ascii hex. response: a) succesfull: OKzzzzcc\x0A datadatadatacc\x0A zzzz - how much data you get. This may be different from value requested. cc - checksum datadatacc - requested data (binary) ended with ascii checksum and nl (newline) b) unsuccesfull NGxxxxcc\x0A xxxx - error number cc - checksum This error ocurs when logical page are not yet used. 2.4 DSSW COMMAND I haven't tried this yet:-) 2.5 PAGE FORMAT a) each page contains records b) if a record is longer than one page (up to 512 bytes), then pages are linked together into one 'big' page. 2.5.1 PAGE AND 'BIG' PAGE First 3 words (6 bytes) from page are: offset:len:description 0000:2 total length of page (including this field). LSB is first. If this is a 'big' page and there is first page, then this field contains sum of the length of the first page and the logical length of other pages (page length-6). 0002:2 if the page is 'big', then you have pointer to next page. 0000 otherwise. 0004:2 if the page is 'big', then you have pointer to previous page. 0000 otherwise. Exceptions: page FFFF 2.5.2 DATA FIELDS IN PAGE offset:len:description 0006:2 number of records in page (word - 2 bytes) 0008:v record,record,record.... Exceptions: pages FFFF and 0000 2.5.3 RECORD FORMAT offset:len:description (offset in record - not in page!) 0000:2 total length of record 0002:v body end:2 total length of record example: 08 00 0C 00 00 00 08 00 For more info/speculations see 3.2 3. SPECULATIONS (UNPROVEN) 3.1 SPECIAL PAGES 3.1.1 PAGE FFFF example: DSSRFFFF00000200000197 C0 15 BD 14 C3 01 00 00 description: probably checksum? 3.1.2 PAGE 0000 example: DSSR00000000020000013F 0E 00 00 00 00 00 00 00 3D 01 00 00 00 00 description: pointer to first unused page? 3.1.3 PAGE 0001 example: DSSR000100000200000140 42 00 00 00 00 00 06 00 08 00 0C 00 00 00 08 00 B............... 0A 00 33 00 00 00 E8 03 0A 00 0A 00 0B 00 00 00 ..3............. EA 03 0A 00 0A 00 18 00 00 00 D2 07 0A 00 0A 00 ................ 24 00 00 00 BB 0B 0A 00 0A 00 2F 00 00 00 A4 0F $........./..... 0A 00 .. description: 6 user data: 1 pointer (000C) to other databases which id is not in this page. 2-6 pointers to other databases: page/database (see export database from RexToolsBeta) 0033/03E8(1000 - ?) 000B/03EA(1002 - adress categories) 0018/07D2(2002 - ?) 0024/0BBB(3003 - memos?) 002F/0FA4(4004 - pictures?) For details see 3.2 3.2 HOW TO FIND DATA 3.2.1 START Read page 0001. On this page you have only pointers to records with descriptions of databases. a) First record (with length 08): offset:len:description 0000:2 length (0008) 0002:2 pointer to page contains definitions of databases with id from 1 to XX, where XX is less than database_id in next record. 0004:2 ?? (usually 0000) 0006:2 length (0008) b) Rest of records offset:len:description 0000:2 length (000A) 0002:2 pointer to page cointains definitions of databases with id from YY to XX, where YY is in next field and XX is less than database_id in next record. 0004:2 ?? (usually 0000) 0006:2 YY 0008:2 length (000A) Now if you have database_id, you can find the page with definitions of this database. 3.2.2 DATABASE DEFINITIONS On page with database definition you can find several records. You must find suitable record with exact database_id. offset:len:description 0000:2 length of record 0002:2 0000 0004:2 ?? (usually 0000) 0006:2 database_id 0008:E ?? 0016:2 number of fields 0018:4 ?? 001C:1 field type (see 3.2.?) 001D:1 field size? 001E:2 ?? 0020:1 field type 0021:2 field size? 0022:2 ?? .... ????:2 pointer to page with data ????:?? ?END:2 length of record If you now have number of fields, fields types and pointer to data, you can read database. 3.2.3 READING DATABASE Now you have pointer to data, number of fields, types and sizes. Just get this page. You can get 3 types of records: a) pointer to data b) data c) mixed (only part of data and pointer to rest of data) And of course you must be prepared to read all these types... [to be continued] 3.2.4 FIELD TYPES These types are defined in Database.h from Z88DK. DB_INT8 1 (01) DB_INT16 2 (02) DB_INT32 3 (03) DB_FXDSTR 11 (0B) DB_FXDDAT 12 (0C) DB_VARSTR 21 (15) DB_VARDAT 22 (16) DB_RECID 90 (5A) 3.2.5 DATABASE NUMBERS (see export database from RexToolsBeta and Database.h from Z88DK) DBID_UNKNOWN = 0 (0000) DBID_COMMONSEARCHHISTORY = 120 (0078) DBID_SHELLADDIN = 150 (0096) DBID_SETUPINFO = 160 (00A0) DBID_DEVICEID = 170 (00AA) DBID_ADDRESS = 1000 (03E8) DBID_CALENDAR = 2000 (07D0) DBID_TODO = 3000 (0BB8) DBID_MEMO = 4000 (0FA0) DBID_MAIL = 5000 (1388) DBID_DICTIONARY = 7000 (1B58) DBID_CLOCK = 8000 (1F40) DBID_PICTURE = 10000 (2710) my additions: DBID_ADDRESS_CATEGORIES = 1002 (03EA) 4. WHAT IS NEEDED a) meaning of unknown fields b) testing ...