diff --git a/src/act.lisp b/src/act.lisp index 0d41eba..bf220af 100644 --- a/src/act.lisp +++ b/src/act.lisp @@ -21,11 +21,14 @@ (defun dispatch-action (action context) "Routes an approved action to its registered physical actuator." (when (and action (listp action)) - (let* ((target (or (ignore-errors (getf action :target)) *default-actuator*)) + (let* ((raw-target (or (ignore-errors (getf action :target)) + (ignore-errors (getf action :TARGET)) + *default-actuator*)) + (target (if (keywordp raw-target) raw-target (intern (string-upcase (string raw-target)) :keyword))) (actuator-fn (gethash target *actuator-registry*))) (if actuator-fn (funcall actuator-fn action context) - (harness-log "ACT ERROR: No actuator for ~a" target))))) + (harness-log "ACT ERROR: No actuator for ~s (from ~s)" target raw-target))))) (defun execute-system-action (action context) "Processes internal harness commands. (ACTUATOR)" diff --git a/src/communication.lisp b/src/communication.lisp index 88b59c8..bffe363 100644 --- a/src/communication.lisp +++ b/src/communication.lisp @@ -1,11 +1,12 @@ (in-package :opencortex) -(defvar *actuator-registry* (make-hash-table :test 'equal) +(defvar *actuator-registry* (make-hash-table :test 'equalp) "Global registry mapping target keywords to their physical actuator functions.") (defun register-actuator (name fn) "Registers an actuator function. Actuators receive: (ACTION CONTEXT)." - (setf (gethash name *actuator-registry*) fn)) + (let ((key (if (keywordp name) name (intern (string-upcase (string name)) :keyword)))) + (setf (gethash key *actuator-registry*) fn))) (defun frame-message (msg-string) "Prefixes MSG-STRING with a 6-character hex length.