Notable changes of tdmclient. Release versions refer to [https://pypi.org/project/tdmclient/].
- In transpiler, event name fixed in code generated for
emit
- Tool
info
to display the variables, events and native functions of a robot. - Existence of a variable in a node can be tested with
in
ornot in
. - In tool
list
, the product id (content of the node variable_productId
) is displayed if it's available, with its meaning if it's known. - In transpiler, as an alternative to the
onevent
decorator, functions can be declared as event handlers by callingonevent
as a function. For example the three code fragments below are equivalent:@onevent def timer0(): ...
def timer0(): ... onevent(timer0)
def task(): ... onevent(task, "timer0")
- Variable size returned in node description.
- In transpiler:
- Empty lists are now reported as unsupported instead of an obscure exception.
- Variable
prox_ground_ambient
was mapped to Thymio variableprox.ground.ambient
which is misspelled in the robot firmware asprox.ground.ambiant
; transpiled code was rejected by the Aseba compiler. Now bothprox_ground_ambient
andprox_ground_ambiant
are mapped toprox.ground.ambiant
to suit both new Python documentation with a correct spelling and programmers using Aseba documentation. - Deque functions are prefixed with
nf_
to be consistent with other native functions and with the documentation. - Typo in the name of variables
event.*
. - In user-defined event names in
@onevent def
andemit
, underscore characters are replaced with dots. These events are now consistant with the automatic definitions ofrun
.
- Option to browse zeroconf information on all interfaces instead of default one. Optional argument
all_interfaces
in constructors ofTDMZeroconfBrowser
,Client
andClientAsync
; and option--zcall
in toolsgui
,list
,repl
,run
,tdmdiscovery
andwatch
. - In tool
watch
, new options to filter the information to observe:--events
,--scratchpads
,--shared-event-descr
,--shared-variables
,--variables
,--vm-state
. - New tool
sendevent
.
- Default TDM is local on port 8596 (fixed port of TDM as launched by Thymio Suite). Zeroconf is used only if requested with
zeroconf=True
in the constructors ofClient
andClientAsync
and in methodtdmclient.notebook.start
, or--zeroconf
in the tools.
- Module
websockets
not needed anymore except to enable option--ws
in toolserver
. - In tool
gui
, connection closed on exit. - Group id instead of node id in TDM message
SendEvents
.
- In transpiler, syntax errors are displayed with context
- Module
tkinter
not needed anymore except for toolgui
- In transpiler, attribute syntax for scalar Thymio variables, such as
import thymio; x = thymio.button_center
- Exported
NodeLockError
- Dependency on package
websocket-client
removed (websocket-client
should be installed separately ifClient
orClientAsync
are instantiated withtdm_ws=True
)
- Optional connection to the TDM using a WebSocket instead of plain TCP
- In tools
gui
,list
,repl
,run
, andwatch
:- option
--tdmport default
stands for the default TDM TCP port 8596 - option
--tdmws
to connect to the TDM with a WebSocket
- option
- In server:
- improved support to use in other programs
- To make the tools easier to reuse from code, their entry point has been moved to the root of the module, and the tool name must be provided as the first argument. For example instead of
you must now type
python3 -m tdmclient.tools.run program.py
To call thepython3 -m tdmclient run program.py
main
function of a tool, import it withimport tdmclient.tools
instead of e.g.import tdmclient.tools.run
; and calltdmclient.tools.run.main([args...])
as before. Or use an alternativeimport
orfrom ... import
variant if you prefer.
- When closing the TCP connection, callback functions are all executed in turn when the connection is actually closed
- In transpiler:
- In
tdmclient.tools.transpile
and notebooks, option--warning-missing-global
to display warnings for local variables which hide global variables (a declaration as global could be missing) - Exception
NameError
replaced byTranspilerError
with node context to display the line number in the error message - Property
lineno
in exception classTranspilerError
- Transpiler exception for unsupported augmented assignments
/=
,**=
and@=
- Errors on undefined variables or invalid use of list variables or indexing in augmented assignments
- In
- In function
ClientAsync.wait_for_node
, optional argumenttimeout
- In server:
- options
--port
,--debug
,--zeroconf
- support for WebSocket
- code easier to use in other programs
- options
- In transpiler:
- Name of local list variables passed to native functions wasn't converted
- User functions called in arguments of
emit
,exit
andprint
caused an exception
- In server:
- Clean shutdown of connection thread
- Socket address reused
- Separate group id
- Transpiler exception for unsupported operators such as
/
,**
and@
- Options of tool
tdmclient.tools.gui
- In transpiler:
- Check that constants such as
RED
are not assigned to (clean error from transpiler instead of incorrect transpiled code) - When auxiliary statements are required to compute the condition of
elif
, the generated code iselse aux if ... end end
instead ofaux elseif ... end
- Check that constants such as
- Optional boolean argument
zeroconf
inClient
constructor and Jupyter functionsstart()
,list()
, andwatch()
- Class
NodeLockError
with the current node status raised when a node cannot be locked - Optional key argument
password
in the constructor ofClientAsync
to connect to remote TDM - In repl:
- Key argument
robot_index
in functions and option--robotindex
in Jupyter magic commands to specify the robot by index - Optional robot specification in
send_event
- Optional argument
all_nodes
in functionprocess_events
- Key argument
- In notebooks:
- Optional
debug
argument instart()
- Optional
password
argument instart()
,list()
,watch()
- Optional
timeout
argument inlist()
andget_nodes()
- Multiple targets in magic commands
%%run_python
and%%run_aseba
with comma-separated list of robots
- Optional
- Option
--password
in toolstdmclient.tools.guy
,tdmclient.tools.list
,tdmclient.tools.repl
,tdmclient.tools.run
,tdmclient.tools.watch
- In repl and Jupyter, callback
on_event_data
has a newnode
argument to better support interaction with multiple robots
- Method
Client.create_node()
referred to a symbol which wasn't imported - Watch flag changes sent by methods
ClientAsyncNode.watch
andClientAsyncNode.unwatch
- In repl, support for starred expressions
- Support for fragmented packets
- In notebooks, function
get_nodes()
must be called afterstart()
and with its tdm connection to avoid returning orphan nodes
- In
tdmclient.tools.watch
, options to select the tdm and the robot - In repl:
- in functions
run()
andstop()
, keyword argumentsrobot_id
orrobot_name
to specify another robot, which is locked during the call - the complete Python or Aseba source code of a program can be passed to function
run()
as an alternative to collecting @onevent functions and global variables
- in functions
- In notebooks:
- private symbols not defined anymore in
tdmclient.notebook
- docstrings for magic commands, displayed with e.g.
%%run_python?
- In magic commands
%%run_python
and%%run_aseba
, options--robot-id ID
or--robot-name NAME
to specify another robot, which is locked during the execution - functions
list()
andget_nodes()
can be called beforestart()
- function
tdmclient.notebook.watch()
, to be called asawait tdmclient.notebook.watch()
to display the robot variables with live update
- private symbols not defined anymore in
- In transpiler, support for lists given as
len(...)*[...]
or[...]*len(...)
- When decoding flatbuffer strings, illegal utf-8 sequences decoded as
U+FFFD
(replacement character) instead of raising an exception
- In notebooks, functions
list()
andget_nodes()
use by default the TDM connection established bystart()
instead of a local TDM advertized by zeroconf
- Local variables defined by the assignment of a global variable neither declared with
global
nor predefined as Thymio variables raised an exception
- Runtime VM errors reported in repl and
tdmclient.tools.run
- In transpiler, temporary variables in
for
loops overwrote the loop limit and step - Format of the tdm message for VM state changed
- In transpiler, support for lists given as
num*[...]
or[...]*num
- In transpiler, access to undeclared global variables when they aren't hidden by a local variable
- In repl and notebooks, synchronized user variables not forgotten when a program is run on the robot
- In
tdmclient.tools.repl
, launch code moved to a functionmain(argv=None)
so that it can be called from the Python shell - In repl and notebooks, shortened message when interrupting program
- In transpiler, module "clock" fixed
- In repl, better support for Python 3.6 and 3.10
- In transpiler:
- module
clock
with functionsseconds()
,ticks_50Hz()
andreset()
- module
- In repl:
- functions
get_client()
andget_node()
- functions
get_var
andset_var
- global variables defined in the robot program added to the list of variables to be synchronized
- functions
- In notebooks:
- functions
get_nodes()
andlist()
to get the list of nodes available in the TDM - decorator
@sync_var
to synchronize the robot variables accessed in the function - in
%%run_python
, option--clear-event-data
to callclear_event_data()
before starting the program
- functions
- In the
run()
function of repl and notebooks and intdmclient.tools.run
, the decision to wait or not when no explicit option is specified is now based only on custom events (events not predefined in the vm) - Better compatibility with Python 3.6:
- in transpiler, support of string constants as documentation strings or arguments of
print()
andemit()
- in repl, no warning for numbers and booleans
- in transpiler, support of string constants as documentation strings or arguments of
- Decoding of the size of array variables obtained from TDM
- In repl, underscores not converted to dots in name of global variables which don't correspond to a known Thymio variable
- Documentation improvements
- In transpiler, support for receiving custom events with arguments
- In repl, function
send_event
- In notebooks, functions
stop
,get_client
,get_node
- In transpiler:
%
in print string constants- in method
simple_transpile
, symbols from modulethymio
imported by default
- In transpiler, definitions for more native functions
- New notebook to illustrate the use of native functions
- Nul bytes in zeroconf property "ws-port" discarded
- In transpiler:
- support for
exit
- dict of events emitted by
emit
, with automatic declaration by tooltdmclient.tools.run
and functionrun
in repl and notebooks
- support for
- In documentation:
- note on the replacement of
run_async_program
withawait
in Jupyter notebooks
- note on the replacement of
- By default, locking the default node raises an error if it's busy instead of waiting
- Event output in tool
tdmclient.tools.run
written with CSV format
- In transpiler:
and
andor
- augmented assignments with indexed variable target
range
with negative step- list arguments in native function calls
- check for recursive function calls
- code generated for functions
math_clamp
andmath_muldiv
- In repl, event listeners reset when needed
- In transpiler:
- support for
print
- support for module
thymio
which can replace predefined Thymio variables and native functions
- support for
- In tdmclient.tools.run, support for events
- In transpiler:
- native functions without return value
- Support for Jupyter notebooks
- In repl:
- access to Aseba code
- function to forget definitions for the Thymio
- help and documentation
- In tools
gui
,repl
andrun
, new options--robotid
and--robotid
- In transpiler:
- decoding of indices
- compatibility with older versions
- In repl:
- user-defined functions
- initialization of global variables in robot code
- Tool
tdmclient.tools.variables
renamedtdmclient.tools.gui
- In transpiler:
- arguments, return value and local variables in function definitions;
- dot replaced with underscore in Thymio variable and native function names;
- Thymio variables must be declared as global in all function definitions;
- conditional expressions;
- chained comparisons;
- function
len
; - better error messages
- New methods Client.shutdown_tdm, ClientAsync.rename, ClientAsync.send_events
- New callbacks Client.on_events_received, Client.on_event_received
- Argument of callback Client.on_variables_changed simplified
- Dummy server
- Missing tools in binary distribution
- Python-to-Aseba transpiler.
- Node objects with significant refactoring.
Node-related methods of classes
Thymio
,Client
orClientAsync
which usednode_id_str
to identify the node have been replaced by methods of new classesNode
,ClientNode
andClientAsyncNode
, respectively. Their use is simpler. - Options to specify the TDM address and port and avoid zeroconf
- First release on PyPI.