-
Notifications
You must be signed in to change notification settings - Fork 2
Protocol Extending the Driver
Read this when adding a new command to the driver, or weighing whether to touch the KAREL source at all.
- Add a ROUTINE in
driver/mappdk_ext.kl - Add a dispatch branch in
HANDLE_CMDindriver/mappdk_cmd.kl - If it uses a new built-in function,
mappdk_server.klandmappdk_logger.klneed a matching%ENVIRONMENT. The environment files are under WinOLPC'sVersions/V940-1/support; grepping there finds which.eva given function lives in -
cd driverand run ktrans; the output.pclands in the current directory. Copy it over the old file indriver/upload/, then load it from the TP, steps in driver/README.md - Add
encode_*/parse_*toprotocol.py, add a method torobot.py - Add a format test to
tests/test_protocol.py, no real hardware needed
To try a command out first, robot.send_raw() sends a raw string
directly, no need to wrap it into a method right away.
There are two.
First: as soon as any one is declared, ktrans stops auto-loading the
default extended environments, and things like $GROUP,
CALL_PROGLIN, MSG_CONNECT suddenly can't be found; everything
actually used has to be listed explicitly. But CORE and SYSTEM are
loaded by default, and declaring either of them again gets
Cannot load environment file, program already exists.
Second: there's an upper bound on the total count of directives plus
environments. It's currently 5 directives (%STACKSIZE,
%NOLOCKGROUP, %NOPAUSE, %ALPHABETIZE, %COMMENT) against 7
environments, already at the edge. Adding one more environment
produces the seemingly unrelated
Id must be defined before this use. Id: IO_RDO. Removing any one
directive or environment makes it pass, so it's not any particular
combination that's broken. Adding another environment means first
deciding which directive can be dropped.
This limit is also why the RDO access-range check lives in Python rather than KAREL, see driver limits.
Motion abort, pause, resume: evaluated, deferred. Unlike
"query/data" commands like reading and writing registers, this needs
cross-task control over the MAPPDK_SERVER currently executing a
motion (KAREL's PAUSE/ABORT <program name> cross-task syntax), and
the exact usage hasn't been verified; getting it wrong could leave the
robot stopped mid-motion or trigger a safety system, a much higher
cost than a register read/write mistake, not something to try on real
hardware with a "guess, compile, hang, RESET" approach. Restarting
this needs verified KAREL cross-task control documentation or an
example first, not something field trial-and-error can solve reliably
on its own.
Writing numeric system variables, string register SR[n], and the
joint-type position register are already in mappdk_ext.kl
(setsysvarnum/getsreg/setsreg/getjpreg/setjpreg, see
extended commands), all verified on real
hardware. Reading alarm history was tried; the ERR_DATA approach
hasn't found a working method yet, and it's fallen back to reading
only the most recent alarm, see
debugging notes.
Last updated: 2026-08-31
Controller Setup
Protocol
- Overview
- Commands (Upstream)
- Commands (Extended)
- Wire Format
- Connections
- Errors
- Driver Limits
- Reserved Resources
- Extending the Driver
- Debugging Notes
控制器設定
協定