coredevice/comm_kernel: implement attributes writeback

This commit is contained in:
pca006132 2022-03-25 23:42:24 +08:00
parent aa8dfaf0f0
commit 457f3c72ce
2 changed files with 13 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import socket
import re
import linecache
import os
import json
from enum import Enum
from fractions import Fraction
from collections import namedtuple
@ -657,7 +658,17 @@ class CommKernel:
return_tags = self._read_bytes()
if service_id == 0:
def service(obj, attr, value): return setattr(obj, attr, value)
def service(header, *values):
counter = 0
for obj in json.loads(header):
old_val = embedding_map.globals_map[obj["id"]]
if "fields" in obj:
for name in obj["fields"]:
setattr(old_val, name, values[counter])
counter += 1
else:
old_val[:] = values[counter]
counter += 1
else:
service = embedding_map.retrieve_function(service_id)
logger.debug("rpc service: [%d]%r%s %r %r -> %s", service_id, service,

View File

@ -9,6 +9,7 @@ class EmbeddingMap:
self.string_map = {}
self.string_reverse_map = {}
self.function_map = {}
self.globals_map = {}
# preallocate exception names
# must be kept in sync with EXCEPTION_ID_LOOKUP in artiq/firmware/ksupport/eh_artiq.rs,