Drivewire... -> DWLOAD Server in Python

Hardware Hacking, Programming and Game Solutions/Cheats
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: Drivewire...

Post by tormod »

jedie wrote: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...
Don't forget DriveWIre4 is open-source so you can also fix these bugs there. But it seems like Aaron is going to fix this soon.
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire...

Post by jedie »

tormod wrote:
jedie wrote: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...
Don't forget DriveWIre4 is open-source so you can also fix these bugs there. But it seems like Aaron is going to fix this soon.
I didn't understand Java and i wouldn't like to learn it ;)

My destination was not to implement a second DriveWire. e.g.: I didn't want to create a GUI...

I would like to support only DWLOAD, first.

Currently i only support this:
$01 - handle filename
$d2 - Read Extended Transaction
$57 - Write Transaction

Now i woking on a useable distribution and useable CLI.

Then i would like to implement the dynamic file feature (see above: posting.php?mode=reply&f=8&t=4946#pr12139 )

The current idea is like this:
1. e.g. file "AUTOLOAD.DWL" is requested
2. the server looks, if there is a "AUTOLOAD.DWL.py" file
3. If exist: Start it and send the stdout output to the client
4. If not extst, look for "AUTOLOAD.DWL" the origin filename and send his content

So it'd possible to create different dynamic stuff, without to change the server in any way...

Maybe it's possible to create not only a "File load menu" like the demo "AUTOLOAD.DWL"... Maybe it's possible to create some "Wizzard" like menu things...
Or maybe a wizzard for your DW programm: viewtopic.php?f=5&t=4968&p=12164#p12164
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

OK, now it's useable...

It is platform independent, but its currently many time easier to install it under linux :?

I created a python virtualenv bootstrap file, so it's very easy to install it under linux, just:

Code: Select all

# Download 'boot_dwload_server.py' from github:
/home/FooBar$ wget https://raw.githubusercontent.com/DWLOAD/DwLoadServer/master/boot_dwload_server.py

# Create virtualenv and use read-only GIT:
/home/FooBar$ python3 boot_dwload_server.py ~/dwload_server_env --install_type git_readonly

# go into created virtualenv:
/home/FooBar$ cd ~/dwload_server_env/

# Create the server root dir (put all DWEEBS into it):
/home/FooBar/dwload_server_env$ mkdir root

# Start server:
/home/FooBar/dwload_server_env$ ./bin/python -m dwload_server.dwload_server --port /dev/ttyUSB0 --root_dir ./root --log_level 10
More info in README: https://github.com/DWLOAD/DwLoadServer#readme


In this case (using --install_type=git_readonly) the git repository are in: .../dwload_server_env/src/
So you can easy update them e.g.:

Code: Select all

/home/FooBar$ cd ~/dwload_server_env/src/dwload-server
/home/FooBar/dwload_server_env/src/dwload-server$ git pull
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

So, now it's useable under windows, too. Not really easy to install, but it's IMHO ok ;)

Startup the server can be made with a simple batch file, see: https://github.com/DWLOAD/DwLoadServer/ ... server.cmd

Details here: https://github.com/DWLOAD/DwLoadServer#windows
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

I started, in a branch, the generate on-the-fly, but not ready yet and no time to finish it, yet:

https://github.com/DWLOAD/DwLoadServer/compare/pyscript
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

I have moved the repro from DWLOAD to 6809 -> https://github.com/6809/DwLoadServer

All old links will be redirected to the new one ;)
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

I add bin2bas and bas2bin into the DragonLib for converting Dragon DOS Binary <-> ASCII listing :D
-> https://github.com/6809/dragonlib/compa ... ...21843c6

So now i see the example "AUTOLOAD.DWL":

Code: Select all

5 'AAAA
7 PRINT
10 PRINT"1  PLASMA   "
20 PRINT"2  STUDD"
30 PRINT"3  FLAGON BIRD"
40 PRINT"4  DONKEY KING"
50 PRINT"5  ZAXXON"
60 PRINT"6  ELCHANCE"
80 PRINT"8  INIT WP 80-COLS BOARD"
90 PRINT"9  ELISA"
100 PRINT"N  NITROS-9"
110 PRINT"H  HDB-DOS"
200 A$=INKEY$
205 IF A$="" GOTO 200
210 IF A$="1"THEN DLOAD"PLASMA"
220 IF A$="2"THEN DLOAD"STUDD"
230 IF A$="3"THEN DLOAD"FLAP"
240 IF A$="4"THEN DLOAD"KING"
250 IF A$="5"THEN DLOAD"ZAXXON"
260 IF A$="6" GOTO 500
280 IF A$="8"THEN CLEAR200,&H7DFF:DLOAD"WPT"
290 IF A$="9"THEN DLOAD"ELISA.BAS"
300 IF A$="N"THEN DLOAD"DOSN"
310 IF A$="H"THEN DLOAD"HDB"
390 IF A$<>" " GOTO 7
400 PRINT"TYPE 'RUN' FOR MENU"
410 END
500 PMODE4,1
510 DLOADN"ELCHANCE"
520 SCREEN1,1
530 IF INKEY$="" GOTO 530
540 GOTO 7
And now everything is together for a dynamic "AUTOLOAD.DWL" and for support ASCII listings without convertions in DWLOAD ;)

But i don't know if the load_address=0x1e01 and exec_address=0x1e01 is important. (There are from the example AUTOLOAD.DWL)
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

I now work on supporting the Becker Port Interface in a branch: https://github.com/6809/DwLoadServer/compare/becker

One strange thing is: The XRoar-Client doesn't send the checksum back. The checksum of a block is 16bit number. But there is only send 8bit:

The current logs look like this:
15 CRITICAL dwload_server 164 Waiting for a connection on 127.0.0.1:65504 ...
1998 CRITICAL dwload_server 166 Incoming connection from ('127.0.0.1', 46593)
1998 INFO dwload_server 195 Root directory is: '/home/jens/workspace/DWLOAD/dwload-demo-files'
1998 DEBUG dwload_server 289 Serve forever
1998 DEBUG dwload_server 169 READ 1:
3651 DEBUG dwload_server 176 hex: $01
3651 DEBUG dwload_server 292 Request type: $01
3651 DEBUG dwload_server 296 *** handle filename: ***
3651 DEBUG dwload_server 169 READ 1:
3652 DEBUG dwload_server 176 hex: $0c
3652 DEBUG dwload_server 115 Read block with a length of 12
3652 DEBUG dwload_server 169 READ 12:
3652 DEBUG dwload_server 176 hex: $41 $55 $54 $4f $4c $4f $41 $44 $2e $44 $57 $4c
3652 INFO dwload_server 208 Filename 12 attached to drive number: 255
3652 DEBUG dwload_server 180 WRITE 1:
3652 DEBUG dwload_server 183 hex: $ff
3652 DEBUG dwload_server 169 READ 1:
3653 DEBUG dwload_server 176 hex: $d2
3653 DEBUG dwload_server 292 Request type: $d2
3653 DEBUG dwload_server 302 *** Read Extended Transaction: ***
3653 DEBUG dwload_server 169 READ 1:
3689 DEBUG dwload_server 176 hex: $ff
3689 DEBUG dwload_server 213 Drive Number: $ff (dez.: 255)
3690 DEBUG dwload_server 223 Filename 'AUTOLOAD.DWL' path: '/home/jens/workspace/DWLOAD/dwload-demo-files/AUTOLOAD.DWL'
3690 DEBUG dwload_server 169 READ 3:
3690 DEBUG dwload_server 176 hex: $00 $00 $00
3690 DEBUG dwload_server 106 read 24 Bit integer: (0, 0, 0) = 0
3690 DEBUG dwload_server 226 Logical Sector Number (LSN): $00 (dez.: 0)
3690 INFO dwload_server 233 Send chunk of file '/home/jens/workspace/DWLOAD/dwload-demo-files/AUTOLOAD.DWL'
3692 DEBUG dwload_server 238 Filesize: 768 Bytes == 3 * 256 Bytes chunks
3692 DEBUG dwload_server 241 seek to: 0
3692 DEBUG dwload_server 243 read 256 bytes
3692 DEBUG dwload_server 180 WRITE 256:
3692 DEBUG dwload_server 183 hex: $55 $01 $1e $01 $02 $5c $1e $01 $aa $1e $0c $00 $05 $3a $83 $41 $41 $41 $41 $00 $1e $12 $00 $07 $87 $00 $1e $26 $00 $0a $87 $22 $31 $20 $20 $50 $4c $41 $53 $4d $41 $20 $20 $20 $22 $00 $1e $36 $00 $14 $87 $22 $32 $20 $20 $53 $54 $55 $44 $44 $22 $00 $1e $4c $00 $1e $87 $22 $33 $20 $20 $46 $4c $41 $47 $4f $4e $20 $42 $49 $52 $44 $22 $00 $1e $62 $00 $28 $87 $22 $34 $20 $20 $44 $4f $4e $4b $45 $59 $20 $4b $49 $4e $47 $22 $00 $1e $73 $00 $32 $87 $22 $35 $20 $20 $5a $41 $58 $58 $4f $4e $22 $00 $1e $86 $00 $3c $87 $22 $36 $20 $20 $45 $4c $43 $48 $41 $4e $43 $45 $22 $00 $1e $a6 $00 $50 $87 $22 $38 $20 $20 $49 $4e $49 $54 $20 $57 $50 $20 $38 $30 $2d $43 $4f $4c $53 $20 $42 $4f $41 $52 $44 $22 $00 $1e $b6 $00 $5a $87 $22 $39 $20 $20 $45 $4c $49 $53 $41 $22 $00 $1e $c9 $00 $64 $87 $22 $4e $20 $20 $4e $49 $54 $52 $4f $53 $2d $39 $22 $00 $1e $db $00 $6e $87 $22 $48 $20 $20 $48 $44 $42 $2d $44 $4f $53 $22 $00 $1e $e5 $00 $c8 $41 $24 $cb $ff $9a $00 $1e $f8 $00 $cd $85 $20 $41 $24 $cb $22 $22 $20 $81 $bc $20 $32 $30 $30 $00
3692 DEBUG dwload_server 169 READ 2:
3694 ERROR dwload_server 172 Receive 1 Bytes, but 2 are expected!
3694 DEBUG dwload_server 176 hex: $3c <- this should be the checksum
3694 DEBUG dwload_server 180 WRITE 1:
3694 DEBUG dwload_server 183 hex: $00
3694 DEBUG dwload_server 259 *** block send.
3694 DEBUG dwload_server 169 READ 1:
3694 DEBUG dwload_server 176 hex: $d5
3695 DEBUG dwload_server 292 Request type: $d5
3695 ERROR dwload_server 314 Request type $d5 (dez.: 213) is not supported, yet.
3695 DEBUG dwload_server 180 WRITE 1:
3695 DEBUG dwload_server 183 hex: $00
3695 DEBUG dwload_server 169 READ 1:
3704 DEBUG dwload_server 176 hex: $d2
3704 DEBUG dwload_server 292 Request type: $d2
3704 DEBUG dwload_server 302 *** Read Extended Transaction: ***
3705 DEBUG dwload_server 169 READ 1:
3741 DEBUG dwload_server 176 hex: $ff
3741 DEBUG dwload_server 213 Drive Number: $ff (dez.: 255)
3742 DEBUG dwload_server 223 Filename 'AUTOLOAD.DWL' path: '/home/jens/workspace/DWLOAD/dwload-demo-files/AUTOLOAD.DWL'
3742 DEBUG dwload_server 169 READ 3:
3742 DEBUG dwload_server 176 hex: $00 $00 $01
3742 DEBUG dwload_server 106 read 24 Bit integer: (0, 0, 1) = 1
3742 DEBUG dwload_server 226 Logical Sector Number (LSN): $01 (dez.: 1)
3742 INFO dwload_server 233 Send chunk of file '/home/jens/workspace/DWLOAD/dwload-demo-files/AUTOLOAD.DWL'
3742 DEBUG dwload_server 238 Filesize: 768 Bytes == 3 * 256 Bytes chunks
3742 DEBUG dwload_server 241 seek to: 256
3743 DEBUG dwload_server 243 read 256 bytes
3743 DEBUG dwload_server 180 WRITE 256:
3743 DEBUG dwload_server 183 hex: $1f $10 $00 $d2 $85 $20 $41 $24 $cb $22 $31 $22 $bf $20 $b9 $22 $50 $4c $41 $53 $4d $41 $22 $00 $1f $27 $00 $dc $85 $20 $41 $24 $cb $22 $32 $22 $bf $20 $b9 $22 $53 $54 $55 $44 $44 $22 $00 $1f $3d $00 $e6 $85 $20 $41 $24 $cb $22 $33 $22 $bf $20 $b9 $22 $46 $4c $41 $50 $22 $00 $1f $53 $00 $f0 $85 $20 $41 $24 $cb $22 $34 $22 $bf $20 $b9 $22 $4b $49 $4e $47 $22 $00 $1f $6b $00 $fa $85 $20 $41 $24 $cb $22 $35 $22 $bf $20 $b9 $22 $5a $41 $58 $58 $4f $4e $22 $00 $1f $7f $01 $04 $85 $20 $41 $24 $cb $22 $36 $22 $20 $81 $bc $20 $35 $30 $30 $00 $1f $a0 $01 $18 $85 $20 $41 $24 $cb $22 $38 $22 $bf $20 $96 $32 $30 $30 $2c $26 $48 $37 $44 $46 $46 $3a $b9 $22 $57 $50 $54 $22 $00 $1f $bb $01 $22 $85 $20 $41 $24 $cb $22 $39 $22 $bf $20 $b9 $22 $45 $4c $49 $53 $41 $2e $42 $41 $53 $22 $00 $1f $d1 $01 $2c $85 $20 $41 $24 $cb $22 $4e $22 $bf $20 $b9 $22 $44 $4f $53 $4e $22 $00 $1f $e6 $01 $36 $85 $20 $41 $24 $cb $22 $48 $22 $bf $20 $b9 $22 $48 $44 $42 $22 $00 $1f $f9 $01 $86 $85 $20 $41 $24 $cc $ca $22 $20 $22 $20 $81 $bc $20 $37
3743 DEBUG dwload_server 169 READ 2:
3747 ERROR dwload_server 172 Receive 1 Bytes, but 2 are expected!
3747 DEBUG dwload_server 176 hex: $4b <- this should be the checksum
3747 DEBUG dwload_server 180 WRITE 1:
3747 DEBUG dwload_server 183 hex: $00
3747 DEBUG dwload_server 259 *** block send.
3747 DEBUG dwload_server 169 READ 1:
3747 DEBUG dwload_server 176 hex: $28
3747 DEBUG dwload_server 292 Request type: $28
3747 ERROR dwload_server 314 Request type $28 (dez.: 40) is not supported, yet.
3747 DEBUG dwload_server 180 WRITE 1:
3747 DEBUG dwload_server 183 hex: $00
3748 DEBUG dwload_server 169 READ 1:
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

Hm!

I found this:
Note that WireBug uses an 8-bit checksum instead of a 16 bit one.
from here: http://sourceforge.net/p/drivewireserve ... -algorithm

But this should not be the WireBug: http://sourceforge.net/p/drivewireserve ... rebug-mode

:?:


EDIT: I add the checksum stuff and now i see, what's wrong:
4293 DEBUG dwload_server 343 WRITE 256:
4293 DEBUG dwload_server 346 hex: $55 $01 $1e ... $30 $30 $00
4293 INFO dwload_server 199 Calculated checksum: $3cd5 dez: 15573 <- so it's $3c and $d5
4293 DEBUG dwload_server 332 READ 2:
4295 ERROR dwload_server 335 Receive 1 Bytes, but 2 are expected!
4295 DEBUG dwload_server 339 hex: $3c <- The first byte
4295 DEBUG dwload_server 343 WRITE 1:
4295 DEBUG dwload_server 346 hex: $00
4295 DEBUG dwload_server 212 *** block send.
4295 DEBUG dwload_server 332 READ 1:
4295 DEBUG dwload_server 339 hex: $d5 <- The second byte
So i get all, but not in the right order...

Think it's my fault... Maybe i use the socket stuff in a wrong way...


EDIT2: It was my mistake. I must wait until all bytes are received. Fixed with: https://github.com/6809/DwLoadServer/co ... ea61bbac8d :D
... 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: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Drivewire... -> DWLOAD Server in Python

Post by jedie »

Release v0.2.0 is out:
* Runable with becker and serial port (and update CLI for it)
* enhanced startup batch files for windows and shell script for linux

HowTo for Windows: https://github.com/6809/DwLoadServer#windows
HowTo for Linux: https://github.com/6809/DwLoadServer#linux

CLI Looks like this:

Code: Select all

DWLOAD Server written in Python (GNU GPL v3+) v0.2.0

usage: dwload_server_cli.py [-h] [--version] [--root_dir ROOT_DIR]
                            [--log_level {0,10,20,30,30,40,50,99,100}]
                            {becker,serial} ...

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --root_dir ROOT_DIR   Server root directory for load/store requested files
  --log_level {0,10,20,30,30,40,50,99,100}
                        Logging level: 10=DEBUG, 20=INFO, 30=WARNING,
                        40=ERROR, 50=CRITICAL/FATAL

Interface:
  {becker,serial}
    becker              Use the Becker interface
    serial              Use the serial interface

example usage:
    dwload_server_cli.py --root_dir=./dwload-files/ serial --port=/dev/ttyUSB0
    dwload_server_cli.py --root_dir=./dwload-files/ becker

Interface help:
    dwload_server_cli.py serial --help
    dwload_server_cli.py becker --help
... 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
Post Reply