mirror of https://github.com/wwarthen/RomWBW.git
2 changed files with 160 additions and 0 deletions
@ -0,0 +1,56 @@ |
|||
#!/usr/bin/python |
|||
import serial |
|||
|
|||
def memcmd(): |
|||
ser.flushInput() |
|||
str = "A" |
|||
ser.write(str) |
|||
print ser.read(1024) |
|||
|
|||
def menucmd(): |
|||
ser.flushInput() |
|||
str = "k" |
|||
ser.write(str) |
|||
print ser.read(1024) |
|||
|
|||
def portscmd(): |
|||
ser.flushInput() |
|||
str = "R" |
|||
ser.write(str) |
|||
print ser.read(1024) |
|||
|
|||
def dispcmd(beg,end): |
|||
ser.flushInput() |
|||
str = "D" + repr(beg) + " " + repr(end) + " " |
|||
ser.write(str) |
|||
# print ser.read(4096) |
|||
print ser.read( ((end+1-beg)/16*80)+100 ) |
|||
|
|||
def reset(): |
|||
ser.flushInput() |
|||
str = "GF000 " |
|||
ser.write(str) |
|||
print ser.read(256) |
|||
|
|||
def getpage(startaddr): |
|||
ser.flushInput() |
|||
str = "D" + repr(startaddr) + " " + repr(startaddr+255) + " " |
|||
print str |
|||
ser.write(str) |
|||
print ser.read(4096) |
|||
|
|||
|
|||
ser = serial.Serial('/dev/cu.PL2303-0000201D', 38400, timeout=2) |
|||
#reset() |
|||
#menucmd() |
|||
#portscmd() |
|||
#dispcmd(1000,1300) |
|||
#getpage(256) |
|||
#dispcmd(256,256+2) |
|||
#reset() |
|||
#getpage(0) |
|||
d1 = 100 |
|||
d2 = d1 + 255 |
|||
dispcmd(d1,d2) |
|||
|
|||
|
|||
@ -0,0 +1,104 @@ |
|||
#!/usr/bin/python |
|||
|
|||
|
|||
# Written by Douglas Goodall 17:25 Wed, Jan 30, 2013 |
|||
|
|||
import sys |
|||
import os |
|||
import serial |
|||
|
|||
filename = "rem.com" |
|||
|
|||
print "*******************************************************************" |
|||
print "sendsave.py 1/30/2013 dwg - deliver file to cp/m using save and ddt" |
|||
print "*******************************************************************" |
|||
# passing in a string either "12" or "0x12" |
|||
# return value is string of hex digits only (no 0x) |
|||
def safebyte(parm): |
|||
xyz = parm |
|||
myord = ord(xyz) |
|||
hexdata = hex(myord) |
|||
newstr = hexdata |
|||
if (hexdata[0] == '0'): |
|||
if(hexdata[1] == 'x'): |
|||
newstr = hexdata[2] |
|||
if(len(hexdata)>3): |
|||
newstr = newstr + hexdata[3] |
|||
return newstr |
|||
|
|||
# passing in a string either "1234" of "0x1234" |
|||
# return value is string of hex digits only (1234) (no 0x) |
|||
def safeword(parm): |
|||
xyz = parm |
|||
myint = int(xyz) |
|||
hexdata = hex(myint) |
|||
newstr = hexdata |
|||
if (hexdata[0] == '0'): |
|||
if(hexdata[1] == 'x'): |
|||
newstr = hexdata[2] |
|||
if(len(hexdata)>3): |
|||
newstr = newstr + hexdata[3] |
|||
if(len(hexdata)>4): |
|||
newstr = newstr + hexdata[4] |
|||
if(len(hexdata)>5): |
|||
newstr = newstr + hexdata[5] |
|||
return newstr |
|||
|
|||
statinfo = os.stat(filename) |
|||
filelen = statinfo.st_size |
|||
|
|||
beg = 0x100 |
|||
end = beg + filelen - 1 |
|||
|
|||
print "Target file is " + filename + " length is 0x" + hex(filelen) + "\n" |
|||
|
|||
infile = open(filename,'rb'); |
|||
data = infile.read() |
|||
infile.close() |
|||
|
|||
ser = serial.Serial('/dev/cu.PL2303-0000201D', 19200, timeout=1) |
|||
|
|||
# flush input queue |
|||
ser.read() |
|||
|
|||
ser.write("\n") |
|||
print ser.read(80) |
|||
|
|||
ser.write("save\n") |
|||
print ser.read(80) |
|||
|
|||
ser.write("ddt\n") |
|||
print ser.read(128) |
|||
|
|||
ser.write("s100\n") |
|||
print ser.read(20) |
|||
|
|||
for x in range(1,filelen): |
|||
ser.write(safebyte(data[x-1])) |
|||
ser.write("\n") |
|||
print ser.read(32) |
|||
|
|||
ser.write(".\n") |
|||
print ser.read(200) |
|||
|
|||
ser.write("g0\n") |
|||
print ser.read(160) |
|||
|
|||
ser.write(filename) |
|||
ser.write("\n") |
|||
print ser.read(128) |
|||
|
|||
ser.write("yes\n") |
|||
print ser.read(128) |
|||
|
|||
ser.write(safeword(beg)) |
|||
ser.write("\n") |
|||
print ser.read(128) |
|||
|
|||
ser.write(safeword(end)) |
|||
ser.write("\n") |
|||
print ser.read(128) |
|||
|
|||
ser.write("\n") |
|||
print ser.read(128) |
|||
|
|||
Loading…
Reference in new issue