1# SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2# SPDX-License-Identifier: Apache-2.0
3
4import os
5import re
6
7# Control-key characters
8CTRL_A = '\x01'
9CTRL_B = '\x02'
10CTRL_C = '\x03'
11CTRL_F = '\x06'
12CTRL_H = '\x08'
13CTRL_I = '\x09'
14CTRL_R = '\x12'
15CTRL_T = '\x14'
16CTRL_Y = '\x19'
17CTRL_P = '\x10'
18CTRL_X = '\x18'
19CTRL_L = '\x0c'
20CTRL_RBRACKET = '\x1d'  # Ctrl+]
21
22# Command parsed from console inputs
23CMD_STOP = 1
24CMD_RESET = 2
25CMD_MAKE = 3
26CMD_APP_FLASH = 4
27CMD_OUTPUT_TOGGLE = 5
28CMD_TOGGLE_LOGGING = 6
29CMD_ENTER_BOOT = 7
30CMD_TOGGLE_TIMESTAMPS = 8
31
32# Tags for tuples in queues
33TAG_KEY = 0
34TAG_SERIAL = 1
35TAG_SERIAL_FLUSH = 2
36TAG_CMD = 3
37
38__version__ = '1.1'
39
40# paths to scripts
41PANIC_OUTPUT_DECODE_SCRIPT = os.path.join(os.path.dirname(__file__), '..', 'gdb_panic_server.py')
42COREDUMP_SCRIPT = os.path.join(os.path.dirname(__file__), '..', '..', 'components', 'espcoredump', 'espcoredump.py')
43
44# regex matches an potential PC value (0x4xxxxxxx)
45MATCH_PCADDR = re.compile(r'0x4[0-9a-f]{7}', re.IGNORECASE)
46
47DEFAULT_TOOLCHAIN_PREFIX = 'xtensa-esp32-elf-'
48
49DEFAULT_PRINT_FILTER = ''
50
51# panic handler related messages
52PANIC_START = r'Core \s*\d+ register dump:'
53PANIC_END = b'ELF file SHA256:'
54PANIC_STACK_DUMP = b'Stack memory:'
55
56# panic handler decoding states
57PANIC_IDLE = 0
58PANIC_READING = 1
59
60# panic handler decoding options
61PANIC_DECODE_DISABLE = 'disable'
62PANIC_DECODE_BACKTRACE = 'backtrace'
63
64EVENT_QUEUE_TIMEOUT = 0.03  # timeout before raising queue.Empty exception in case of empty event queue
65
66ESPPORT_ENVIRON = str('ESPPORT')
67MAKEFLAGS_ENVIRON = 'MAKEFLAGS'
68
69GDB_UART_CONTINUE_COMMAND = '+$c#63'
70GDB_EXIT_TIMEOUT = 0.3  # time delay between exit and writing GDB_UART_CONTINUE_COMMAND
71
72# workaround for data sent without EOL
73# if no data received during the time, last line is considered finished
74LAST_LINE_THREAD_INTERVAL = 0.1
75
76MINIMAL_EN_LOW_DELAY = 0.005
77RECONNECT_DELAY = 0.5  # timeout between reconnect tries
78CHECK_ALIVE_FLAG_TIMEOUT = 0.25  # timeout for checking alive flags (currently used by serial reader)
79