Drivewire... -> DWLOAD Server in Python

Hardware Hacking, Programming and Game Solutions/Cheats
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Drivewire... -> DWLOAD Server in Python

Post by jedie »

I would like to implement a minimal Drivewire Server in Python... Just to show how it really works. (And i didn't like Java... :P )

Does anyone have done this? Where are good documentation around Drivewire?
Last edited by jedie on Fri Nov 14, 2014 10:51 am, edited 1 time in total.
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
pser1
Posts: 1373
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Drivewire...

Post by pser1 »

hello,

maybe this link could shine a bit of light on this project:
https://sites.google.com/site/drivewire4/

good luck
regards
pere
KenH
Posts: 177
Joined: Fri Oct 12, 2012 9:50 am

Re: Drivewire...

Post by KenH »

See also

DriveWire Lite: a reimplementation in C of the server side of the DriveWire 3 protocol.
http://sourceforge.net/projects/dwlite/

and the DriveWire 3 Protocol Specification document:
http://www.frontiernet.net/~mmarlette/C ... cation.pdf
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

Thanks for the links!

I didn't know that there is a DriveWire lite written in C!
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

Now i think it would be good to implement a DriveWire Server specialy for DWLOAD...
That can handle the save file and skip the padding stuff...

Don't know how many work will this be...
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

Currently i ask myself if it possible to have a dynamic AUTOLOAD.DWL ?!?

The default AUTOLOAD.DWL from the examples (dwload-demo-files.tar.xz.zip from: viewtopic.php?f=5&t=4964 ) is nice.

It's a simple static BASIC program. Would be nice if the file select menu is dynamic, isn't it?

Why not collect all DWEEB filenames and "compile" a AUTOLOAD.DWL on-the-fly... Maybe it will be possible to add subdirectory support and pageing?!?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

I started to implement...

But i didn't understand the complete communication. In DriveWire 4 Server i enabled the raw bytes logging with:

Code: Select all

<LogDeviceBytes category="logging,advanced" type="boolean">true</LogDeviceBytes>
in the config.xml

Requesting AUTOLOAD.DWL via DLOAD looks like this:

Code: Select all

12 Nov 2014 10:56:54 DEBUG [dwproto-0-10  ] READ1: 0
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ1: 1
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ1: 12
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 12:  65 85 84 79 76 79 65 68 46 68 87 76
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE1: 255
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ1: 210
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 4:  255 0 0 0
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE 256: 85 1 30 1 2 92 30 1 170 30 12 0 5 58 131 65 65 65 65 0 30 18 0 7 135 0 30 38 0 10 135 34 49 32 32 80 76 65 83 77 65 32 32 32 34 0 30 54 0 20 135 34 50 32 32 83 84 85 68 68 34 0 30 76 0 30 135 34 51 32 32 70 76 65 71 79 78 32 66 73 82 68 34 0 30 98 0 40 135 34 52 32 32 68 79 78 75 69 89 32 75 73 78 71 34 0 30 115 0 50 135 34 53 32 32 90 65 88 88 79 78 34 0 30 134 0 60 135 34 54 32 32 69 76 67 72 65 78 67 69 34 0 30 166 0 80 135 34 56 32 32 73 78 73 84 32 87 80 32 56 48 45 67 79 76 83 32 66 79 65 82 68 34 0 30 182 0 90 135 34 57 32 32 69 76 73 83 65 34 0 30 201 0 100 135 34 78 32 32 78 73 84 82 79 83 45 57 34 0 30 219 0 110 135 34 72 32 32 72 68 66 45 68 79 83 34 0 30 229 0 200 65 36 203 255 154 0 30 248 0 205 133 32 65 36 203 34 34 32 129 188 32 50 48 48 0
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 2:  60 213
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE1: 0
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ1: 210
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 4:  255 0 0 1
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE 256: 31 16 0 210 133 32 65 36 203 34 49 34 191 32 185 34 80 76 65 83 77 65 34 0 31 39 0 220 133 32 65 36 203 34 50 34 191 32 185 34 83 84 85 68 68 34 0 31 61 0 230 133 32 65 36 203 34 51 34 191 32 185 34 70 76 65 80 34 0 31 83 0 240 133 32 65 36 203 34 52 34 191 32 185 34 75 73 78 71 34 0 31 107 0 250 133 32 65 36 203 34 53 34 191 32 185 34 90 65 88 88 79 78 34 0 31 127 1 4 133 32 65 36 203 34 54 34 32 129 188 32 53 48 48 0 31 160 1 24 133 32 65 36 203 34 56 34 191 32 150 50 48 48 44 38 72 55 68 70 70 58 185 34 87 80 84 34 0 31 187 1 34 133 32 65 36 203 34 57 34 191 32 185 34 69 76 73 83 65 46 66 65 83 34 0 31 209 1 44 133 32 65 36 203 34 78 34 191 32 185 34 68 79 83 78 34 0 31 230 1 54 133 32 65 36 203 34 72 34 191 32 185 34 72 68 66 34 0 31 249 1 134 133 32 65 36 204 202 34 32 34 32 129 188 32 55
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 2:  75 95
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE1: 0
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ1: 210
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 4:  255 0 0 2
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE 256: 0 32 20 1 144 135 34 84 89 80 69 32 39 82 85 78 39 32 70 79 82 32 77 69 78 85 34 0 32 26 1 154 138 0 32 35 1 244 183 52 44 49 0 32 52 1 254 185 78 34 69 76 67 72 65 78 67 69 34 0 32 61 2 8 174 49 44 49 0 32 80 2 18 133 32 255 154 203 34 34 32 129 188 32 53 51 48 0 32 89 2 28 129 188 32 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] READ 2:  24 245
12 Nov 2014 10:56:55 DEBUG [dwproto-0-10  ] WRITE1: 0

In my current code ( https://gist.github.com/jedie/c6a066c102b3048c4d69 ) it looks like this:

Code: Select all

C:\Python34\python.exe V:/workspace/DwLoadServer/dwload_server.py
194       INFO dwload_server 64 Root directory is: 'dwload-demo-files'
Settings for serial 'COM3':
            baudrate : 57600
            bytesize : 8
              dsrdtr : False
    interCharTimeout : None
              parity : N
              rtscts : False
            stopbits : 1
             timeout : None
        writeTimeout : None
             xonxoff : False
257      DEBUG dwload_server 112 Serve forever
257      DEBUG dwload_server 48 READ 1:
13321    DEBUG dwload_server 50 	dez: 1
13321    DEBUG dwload_server 51 	hex: $01
13321    DEBUG dwload_server 114 Request type: $01
13321    DEBUG dwload_server 116 Request a file.
13321    DEBUG dwload_server 48 READ 1:
13321    DEBUG dwload_server 50 	dez: 12
13321    DEBUG dwload_server 51 	hex: $0c
13321    DEBUG dwload_server 88 Read block with a length of 12
13321    DEBUG dwload_server 48 READ 12:
13322    DEBUG dwload_server 50 	dez: 65 85 84 79 76 79 65 68 46 68 87 76
13322    DEBUG dwload_server 51 	hex: $41 $55 $54 $4f $4c $4f $41 $44 $2e $44 $57 $4c
13322    DEBUG dwload_server 94 Filename has 12 Bytes.
13322    DEBUG dwload_server 96 Filename: 'AUTOLOAD.DWL'
13322    DEBUG dwload_server 55 WRITE 1:
13322    DEBUG dwload_server 56 	dez: 255
13322    DEBUG dwload_server 57 	hex: $ff
13322    DEBUG dwload_server 48 READ 1:
13324    DEBUG dwload_server 50 	dez: 210
13324    DEBUG dwload_server 51 	hex: $d2
13324    DEBUG dwload_server 48 READ 4:
13324    DEBUG dwload_server 50 	dez: 255 0 0 0
13324    DEBUG dwload_server 51 	hex: $ff $00 $00 $00
13324    DEBUG dwload_server 103 Use filepath: 'dwload-demo-files\\AUTOLOAD.DWL'
13332    DEBUG dwload_server 108 File content are 768 bytes.
Traceback (most recent call last):
  File "V:/workspace/DwLoadServer/dwload_server.py", line 142, in <module>
    dwload.serve_forever()
  File "V:/workspace/DwLoadServer/dwload_server.py", line 118, in serve_forever
    raise NotImplementedError()
NotImplementedError


What i understand from the origin Logging (here a cut version):
READ1: 0
READ1: 1 <- request type (here read a file)
READ1: 12 <- filename byte count
READ 12: 65 85 84 79 76 79 65 68 46 68 87 76 <- filename, here: 'AUTOLOAD.DWL'
WRITE1: 255 <- maybe start transfer?!?
READ1: 210 <- == $D2 for read extended transaction!?!?
READ 4: 255 0 0 0 <- 255=Drive Number and 0 0 0 are LSN (Logical Sector Number) a 24 bit value
WRITE 256: 85 1 30 ... 48 48 0 <- 256 byte block of the file content
READ 2: 60 213 <- maybe the 16 bit checksum computed by Dragon?!?
WRITE1: 0 <- maybe confirm the checksum?!?
READ1: 210 <- == $D2 for read extended transaction!?!?
READ 4: 255 0 0 1 <- 255=Drive Number and 0 0 1 are LSN (Logical Sector Number) a 24 bit value
WRITE 256: 31 16 0 ... 188 32 55 <- 256 byte block of the file content
READ 2: 75 95 <- maybe the 16 bit checksum computed by Dragon?!?
WRITE1: 0 <- maybe confirm the checksum?!?
READ1: 210 <- == $D2 for read extended transaction!?!?
READ 4: 255 0 0 2 <- 255=Drive Number and 0 0 2 are LSN (Logical Sector Number) a 24 bit value
WRITE 256: 0 32 20 ... 0 0 0 <- 256 byte block of the file content
READ 2: 24 245 <- maybe the 16 bit checksum computed by Dragon?!?
WRITE1: 0 <- maybe confirm the checksum?!?
Between the block should be a block length and a checksum and some more meta information...
The "DriveWire 3 Specification.pdf" didn't help me... Is there somewhere other documentations?

EDIT: Add some more suggestions in last log...
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

OK, file sending works now!!!

I create a repro for it: https://github.com/DWLOAD/DwLoadServer

I use the github opensource organization: https://github.com/DWLOAD for it, see: viewtopic.php?f=5&t=4971 (Maybe it makes sence to mege it, if implementation is more useable...)

Logging output of two file Requests is here: https://gist.github.com/jedie/43245bd5ecb80eeeac87
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
jedie
Posts: 630
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: Drivewire...

Post by tormod »

Great stuff. It is always nice to have several options...

I think a nice milestone would be that you can run NitrOS-9 through your server. You basically need the read and write support (OP_WRITE, OP_REWRITE, OP_READEX, OP_REREADEX) and OP_TIME to provide the clock. And empty OP_SERREAD, OP_GETSTAT, OP_INIT, OP_DWINIT to keep it happy. I know this by experience, more on that later :p
Post Reply