源码位置
files/demo/api/python/rcl/dist/lauterbach-trace32-rcl-1.0.2
研究 T32_NotifyXXXX
T32_NotifyEventEnable 相当于 cmm 脚本中的“ON” 但 rcl 中并没有实现! 但在 _rc/_library.py 中却发现了相关的代码:
def t32_notifystateenable(self, event_code, callback_function):
"""Enables notification at remote server and registers locally callback_function"""
if event_code > 7:
raise err.ApiNotificationEventCountExceedError(event_code)
event_mask_value = 1 << event_code
try:
if event_code == T32_E_EDIT:
result = self.generic_api_call(rapi_cmd=RAPI_CMD_EDITNOTIFY, opt_arg=0x00, payload=b"\x01\x00")
else:
result = self.generic_api_call(
rapi_cmd=RAPI_CMD_DEVICE_SPECIFIC,
opt_arg=RAPI_DSCMD_STATE_SETNOTIFIER,
payload=event_mask_value.from_bytes(2, byteorder="little"),
)
except err.ApiError as e:
raise err.ApiNotificationEnableFail() from e
else:
self._notification_callback.update({event_code: callback_function})
return result
简单修改后,发现没有用!原来是要调用 t32_checkstatenotify
参考的是:t32notifications.c 源码 rcl.py 的 class Debugger中 添加:
# manfeel add
def on_breakpoint(self, callback):
return self.__library.t32_notifystateenable(0x00, callback)
def poll_event(self, param):
self.__library.t32_checkstatenotify(param)
同时修改 _library.py 的一处错误:
def t32_notifystateenable(self, event_code, callback_function):
"""Enables notification at remote server and registers locally callback_function"""
if event_code > 7:
raise err.ApiNotificationEventCountExceedError(event_code)
event_mask_value = 1 << event_code
try:
if event_code == T32_E_EDIT:
result = self.generic_api_call(rapi_cmd=RAPI_CMD_EDITNOTIFY, opt_arg=0x00, payload=b"\x01\x00")
else:
result = self.generic_api_call(
rapi_cmd=RAPI_CMD_DEVICE_SPECIFIC,
opt_arg=RAPI_DSCMD_STATE_SETNOTIFIER,
payload=event_mask_value.to_bytes(2, byteorder="little"),
)
except err.ApiError as e:
raise err.ApiNotificationEnableFail() from e
else:
self._notification_callback.update({event_code: callback_function})
return result
legacy: AttributeError: dlsym(0x7faefa59bfb0, T32_NotifyEventEnable): symbol not found
可能是 ENABLE_NOTIFICATION 开关在编译 api 的时候没有打开! 进入:/Volumes/extworks/TRACE32_R_2021_02_000136263/files/demo/api/capi/dll 通过比较 makefile.linux 和 makefile.macosx,发现macosx里面并没有 使能 ENABLE_NOTIFICATION 但!makefile.linux 中是有定义的!!! 于是,修改 makefile.macosx
CFLAGS := -c -fPIC -DENABLE_NOTIFICATION
最后运行: make -f makefile.macosx all
|