Compare commits

..

No commits in common. "373eab52c988a3862d34d994d6b2aba2e8c92b62" and "37e05b8508b5eae251392ce290ab0d1f0dc9d15c" have entirely different histories.

View File

@ -122,11 +122,9 @@ def augment_filename(filename, ip):
# See if augmented filename exists, if so return that name
# otherwise return the unaugmented name
#
def select_filename(filename, addr):
def select_filename(filename, ip):
if serial_port:
return filename
ip = addr[0]
ip = ip[ip.rfind(":")+1:]
filename_with_ip = augment_filename(filename, ip)
try:
with open(filename_with_ip, 'r+b'):
@ -138,7 +136,7 @@ def select_filename(filename, addr):
#
# Read block with date/time update
#
def read3(dataport, addr, d):
def read3(dataport, addr, ip, d):
global packet
d = dataport.recvmore(d, 3)
@ -152,7 +150,7 @@ def read3(dataport, addr, d):
drv = 2
skip = skip2
filename = select_filename(filename, addr)
filename = select_filename(filename, ip)
blknum = d[2] + 256 * d[3]
@ -194,12 +192,12 @@ def read3(dataport, addr, d):
printinfo(drv, blknum, False, err, cs, filename)
b = dataport.sendto(bytearray(l), addr)
#print('Sent {} bytes to {}'.format(b, addr))
#print('Sent {} bytes to {}'.format(b, ip))
#
# Write block
#
def write(dataport, addr, d):
def write(dataport, addr, ip, d):
global packet
d = dataport.recvmore(d, BLKSZ + 4)
@ -213,7 +211,7 @@ def write(dataport, addr, d):
drv = 2
skip = skip2
filename = select_filename(filename, addr)
filename = select_filename(filename, ip)
cs = 0
for i in range (0, BLKSZ):
@ -252,7 +250,7 @@ def write(dataport, addr, d):
printinfo(drv, blknum, True, err, cs, filename)
b = dataport.sendto(bytearray(l), addr)
#print('Sent {} bytes to {}'.format(b, addr))
#print('Sent {} bytes to {}'.format(b, ip))
#
# See if file is a 2MG and, if so, that it contains .PO image
@ -379,12 +377,14 @@ with DataPort(serial_port, baud_rate) as dataport:
while True:
try:
data, address = dataport.recvfrom(2)
#print('Received {} bytes from {}'.format(len(data), address))
ip = address[0]
ip = ip[ip.rfind(":")+1:]
#print('Received {} bytes from {}'.format(len(data), ip))
if (data[0] == 0xc5):
if (data[1] == 0x03) or (data[1] == 0x05):
read3(dataport, address, data)
read3(dataport, address, ip, data)
elif (data[1] == 0x02) or (data[1] == 0x04):
write(dataport, address, data)
write(dataport, address, ip, data)
except DataPort.Timeout:
pass