Commit 87e8bca5 authored by Michael Büsch's avatar Michael Büsch

coreserver: Handle symbol table as bytes

Signed-off-by: Michael Büsch's avatarMichael Buesch <[email protected]>
parent 4fc131f2
......@@ -294,8 +294,8 @@ class AwlSimClient(object):
raise AwlSimError("AwlSimClient: Failed to load code")
return True
def loadSymbolTable(self, symTabText):
msg = AwlSimMessage_LOAD_SYMTAB(symTabText)
def loadSymbolTable(self, symTabBytes):
msg = AwlSimMessage_LOAD_SYMTAB(symTabBytes)
status = self.__sendAndWaitFor_REPLY(msg)
if status != AwlSimMessage_REPLY.STAT_OK:
raise AwlSimError("AwlSimClient: Failed to load symbol table")
......
......@@ -201,24 +201,16 @@ class AwlSimMessage_EXCEPTION(AwlSimMessage):
return cls(text)
class AwlSimMessage_LOAD_SYMTAB(AwlSimMessage):
def __init__(self, symTabText):
def __init__(self, symTabBytes):
AwlSimMessage.__init__(self, AwlSimMessage.MSG_ID_LOAD_SYMTAB)
self.symTabText = symTabText
self.symTabBytes = symTabBytes
def toBytes(self):
try:
data = self.symTabText.encode()
return AwlSimMessage.toBytes(self, len(data)) + data
except UnicodeError:
raise TransferError("LOAD_SYMTAB: Unicode error")
return AwlSimMessage.toBytes(self, len(self.symTabBytes)) + self.symTabBytes
@classmethod
def fromBytes(cls, payload):
try:
symTabText = payload.decode()
except UnicodeError:
raise TransferError("LOAD_SYMTAB: Unicode error")
return cls(symTabText)
return cls(payload)
class AwlSimMessage_LOAD_CODE(AwlSimMessage):
def __init__(self, code):
......
......@@ -333,7 +333,7 @@ class AwlSimServer(object):
def __rx_LOAD_SYMTAB(self, client, msg):
status = AwlSimMessage_REPLY.STAT_OK
symbolTable = SymTabParser.parseData(msg.symTabText,
symbolTable = SymTabParser.parseData(msg.symTabBytes,
autodetectFormat = True,
mnemonics = self.sim.cpu.getSpecs().getMnemonics())
self.__setRunState(self.STATE_INIT)
......
......@@ -281,7 +281,8 @@ def runWithServerBackend(inputFile):
# Fire up the core
writeStdout("Initializing CPU...\n")
for symTabFile in project.symTabFiles:
client.loadSymbolTable(awlFileRead(symTabFile))
client.loadSymbolTable(awlFileRead(symTabFile,
encoding="binary"))
for awlFile in project.awlFiles:
client.loadCode(awlFileRead(awlFile))
client.setRunState(True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment