overview.rst 2.9 KB
Newer Older
Rahix's avatar
Rahix committed
1
2
.. _pycardium_overview:

Rahix's avatar
Rahix committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Overview
========
Pycardium is what we call our MicroPython port for card10.  For the most part,
it will behave like a normal MicroPython, enhanced by a few modules to
interface with card10's hardware.  We have also included modules from Python's
standard library so you have lots of familiar functionality at hand to start
hacking!

.. note::

   Right now, MicroPython is only available via the serial console.  card10
   makes its console available as a CDC ACM device via USB or, if you have a
   debugger, on the debugging serial port.

schneider's avatar
schneider committed
17
18
   This means, you can only interact with Python through the REPL console for
   now. However, this will soon change, once `#10`_ and `#11`_ are implemented.
Rahix's avatar
Rahix committed
19
20
21
22

   .. _#10: https://git.card10.badge.events.ccc.de/card10/firmware/issues/10
   .. _#11: https://git.card10.badge.events.ccc.de/card10/firmware/issues/11

schneider's avatar
schneider committed
23
24
25
26
   In other words: It is currently not possible to execute Python code
   from .py files on the filesystem. You have to test new modules using the
   serial console.

Rahix's avatar
Rahix committed
27
28
29
30
31
32
33
34
35
Serial Console
--------------
If you have a debugger, you can just use the debuggers serial console.
Otherwise, card10 will open a serial usb-device on its usb-port. On most Linux
systems this device will be called ``/dev/ttyACM0`` or ``/dev/ttyACM1``.

Choose a terminal-emulator of your liking and open the above mentioned device.
Baud-rate is 115200.  Some options are:

Jens Timmerman's avatar
Jens Timmerman committed
36
37
* **screen**: ``sudo screen /dev/ttyACM0 115200``
* **picocom**: ``sudo picocom -b 115200 /dev/ttyACM0``
Rahix's avatar
Rahix committed
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
After connecting, reboot reset the card10 via the power button (left upper
corner) and you should see the output of **menu.py** script (it's located in
*preload/menu.py*). You can press CTRL-C to interrupt the script and jump into
the MicroPython prompt.

To switch on the blue fairy dust you must import the led python module::

   import leds

and power it on::

   leds.set_rocket(0, 31)


REPL modes
^^^^^^^^^^

MicroPython supports a different REPL modes over the serial console. The modes
can be changed on every new line.

Normal mode
"""""""""""
This is the mode you will first see. You can switch to it by pressing CTRL-B.
If you are in a other mode you can return to this mode by pressing CTRL-B too.

Paste mode
""""""""""
You can enter the paste mode by pressing CTRL-E and you can simple copy 'n'
paste your source code into the console and it will be interpreted and executed
line by line. Every new line will be reply by the prompt with **===**.

RAW mode
""""""""
The RAW mode to be intendend for the usage with tools. By pressing CTRL-A you
will enter the RAW REPL mode. The type in code will not printed. By pressing
CTRL-D the whole entered code will be evaluated and executed. The board will
reply with **OK** and print after that the output (print commands) of the code
or give you tracebacks if an error occured.

You can use **pycard10** (tools/pycard10.py) to execute python files from your
PC directly on the card10.
Rahix's avatar
Rahix committed
80

Rahix's avatar
Rahix committed
81