Aseba  1.5.5
consts.h
1 /*
2  Aseba - an event-based framework for distributed robot control
3  Copyright (C) 2007--2016:
4  Stephane Magnenat <stephane at magnenat dot net>
5  (http://stephane.magnenat.net)
6  and other contributors, see authors.txt for details
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation, version 3 of the License.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __ASEBA_CONSTS_H
22 #define __ASEBA_CONSTS_H
23 
28 
30 #define ASEBA_VERSION "1.5.5"
31 
33 #define ASEBA_VERSION_INT 10505
34 
36 #define ASEBA_PROTOCOL_VERSION 5
37 
39 #define ASEBA_MIN_TARGET_PROTOCOL_VERSION 4
40 
42 #define ASEBA_DEFAULT_LISTEN_TARGET "tcpin:33333"
43 
45 #define ASEBA_DEFAULT_TARGET "tcp:localhost;33333"
46 
48 #define ASEBA_DEFAULT_HOST "localhost"
49 
51 #define ASEBA_DEFAULT_PORT 33333
52 
53 
55 typedef enum
56 {
57  ASEBA_BYTECODE_STOP = 0x0,
58  ASEBA_BYTECODE_SMALL_IMMEDIATE = 0x1,
59  ASEBA_BYTECODE_LARGE_IMMEDIATE = 0x2,
60  ASEBA_BYTECODE_LOAD = 0x3,
61  ASEBA_BYTECODE_STORE = 0x4,
62  ASEBA_BYTECODE_LOAD_INDIRECT = 0x5,
63  ASEBA_BYTECODE_STORE_INDIRECT = 0x6,
64  ASEBA_BYTECODE_UNARY_ARITHMETIC = 0x7,
65  ASEBA_BYTECODE_BINARY_ARITHMETIC = 0x8,
66  ASEBA_BYTECODE_JUMP = 0x9,
67  ASEBA_BYTECODE_CONDITIONAL_BRANCH = 0xA,
68  ASEBA_BYTECODE_EMIT = 0xB,
69  ASEBA_BYTECODE_NATIVE_CALL = 0xC,
70  ASEBA_BYTECODE_SUB_CALL = 0xD,
71  ASEBA_BYTECODE_SUB_RET = 0xE
73 
75 typedef enum
76 {
77  // arithmetic
78  ASEBA_OP_SHIFT_LEFT = 0x0,
79  ASEBA_OP_SHIFT_RIGHT,
80  ASEBA_OP_ADD,
81  ASEBA_OP_SUB,
82  ASEBA_OP_MULT,
83  ASEBA_OP_DIV,
84  ASEBA_OP_MOD,
85  // binary arithmetic
86  ASEBA_OP_BIT_OR,
87  ASEBA_OP_BIT_XOR,
88  ASEBA_OP_BIT_AND,
89  // comparison
90  ASEBA_OP_EQUAL,
91  ASEBA_OP_NOT_EQUAL,
92  ASEBA_OP_BIGGER_THAN,
93  ASEBA_OP_BIGGER_EQUAL_THAN,
94  ASEBA_OP_SMALLER_THAN,
95  ASEBA_OP_SMALLER_EQUAL_THAN,
96  // logic
97  ASEBA_OP_OR,
98  ASEBA_OP_AND
100 
102 #define ASEBA_BINARY_OPERATOR_MASK 0xff
103 
105 typedef enum
106 {
107  ASEBA_UNARY_OP_SUB = 0x0,
108  ASEBA_UNARY_OP_ABS,
109  ASEBA_UNARY_OP_BIT_NOT,
110  ASEBA_UNARY_OP_NOT // < not used for the VM, only for parsing, reduced by compiler using de Morgan and comparison inversion
112 
114 #define ASEBA_UNARY_OPERATOR_MASK 0xff
115 
117 #define ASEBA_IF_IS_WHEN_BIT 8
118 
119 #define ASEBA_IF_WAS_TRUE_BIT 9
120 
122 typedef enum
123 {
131 
133 typedef enum
134 {
135  ASEBA_EVENT_INIT = 0xFFFF,
136  ASEBA_EVENT_LOCAL_EVENTS_START = 0xFFFE,
138 
140 #define AsebaBytecodeFromId(id) ((id) << 12)
141 
143 typedef enum
144 {
145  /* from bootloader control program to a specific node */
146  ASEBA_MESSAGE_BOOTLOADER_RESET = 0x8000,
147  ASEBA_MESSAGE_BOOTLOADER_READ_PAGE,
148  ASEBA_MESSAGE_BOOTLOADER_WRITE_PAGE,
149  ASEBA_MESSAGE_BOOTLOADER_PAGE_DATA_WRITE,
150 
151  /* from node to bootloader control program */
152  ASEBA_MESSAGE_BOOTLOADER_DESCRIPTION,
153  ASEBA_MESSAGE_BOOTLOADER_PAGE_DATA_READ,
154  ASEBA_MESSAGE_BOOTLOADER_ACK,
155 
156  /* from a specific node */
157  ASEBA_MESSAGE_DESCRIPTION = 0x9000,
158  ASEBA_MESSAGE_NAMED_VARIABLE_DESCRIPTION,
159  ASEBA_MESSAGE_LOCAL_EVENT_DESCRIPTION,
160  ASEBA_MESSAGE_NATIVE_FUNCTION_DESCRIPTION,
161  ASEBA_MESSAGE_DISCONNECTED,
162  ASEBA_MESSAGE_VARIABLES,
163  ASEBA_MESSAGE_ARRAY_ACCESS_OUT_OF_BOUNDS,
164  ASEBA_MESSAGE_DIVISION_BY_ZERO,
165  ASEBA_MESSAGE_EVENT_EXECUTION_KILLED,
166  ASEBA_MESSAGE_NODE_SPECIFIC_ERROR,
167  ASEBA_MESSAGE_EXECUTION_STATE_CHANGED,
168  ASEBA_MESSAGE_BREAKPOINT_SET_RESULT,
169  ASEBA_MESSAGE_NODE_PRESENT,
170 
171  /* from IDE to all nodes */
172  ASEBA_MESSAGE_GET_DESCRIPTION = 0xA000,
173 
174  /* from IDE to a specific node */
175  ASEBA_MESSAGE_SET_BYTECODE,
176  ASEBA_MESSAGE_RESET,
177  ASEBA_MESSAGE_RUN,
178  ASEBA_MESSAGE_PAUSE,
179  ASEBA_MESSAGE_STEP,
180  ASEBA_MESSAGE_STOP,
181  ASEBA_MESSAGE_GET_EXECUTION_STATE,
182  ASEBA_MESSAGE_BREAKPOINT_SET,
183  ASEBA_MESSAGE_BREAKPOINT_CLEAR,
184  ASEBA_MESSAGE_BREAKPOINT_CLEAR_ALL,
185  ASEBA_MESSAGE_GET_VARIABLES,
186  ASEBA_MESSAGE_SET_VARIABLES,
187  ASEBA_MESSAGE_WRITE_BYTECODE,
188  ASEBA_MESSAGE_REBOOT,
189  ASEBA_MESSAGE_SUSPEND_TO_RAM,
190  ASEBA_MESSAGE_GET_NODE_DESCRIPTION,
191 
192  /* from IDE to all nodes, here because it was added later */
193  ASEBA_MESSAGE_LIST_NODES,
194 
195  ASEBA_MESSAGE_INVALID = 0xFFFF
197 
199 typedef enum
200 {
201  ASEBA_DEST_DEBUG = 0,
202  ASEBA_DEST_INVALID = 0xFFFF
204 
206 typedef enum
207 {
209 } AsebaLimits;
210 
212 #define ASEBA_MAX_EVENT_ARG_SIZE (ASEBA_MAX_EVENT_ARG_COUNT*2)
213 
215 #define ASEBA_MAX_INNER_PACKET_SIZE (ASEBA_MAX_EVENT_ARG_SIZE+2)
216 
218 #define ASEBA_MAX_OUTER_PACKET_SIZE (ASEBA_MAX_INNER_PACKET_SIZE+4)
219 
221 #define ASEBA_MAX_PACKET_SIZE ASEBA_MAX_INNER_PACKET_SIZE
222 
224 #define ASEBA_UNUSED(x) (void)x;
225 
228 #endif
AsebaExecutionStates
List of masks for flags in AsebaVMState.
Definition: consts.h:122
This flag is enabled when the VM is running stey by step.
Definition: consts.h:127
AsebaUnaryOperator
List of unary operators.
Definition: consts.h:105
AsebaLimits
Limits for static buffers allocation.
Definition: consts.h:206
AsebaSystemMessagesTypes
Identifiers for remote bootloader and debug protocol.
Definition: consts.h:143
This flag is enabled when a thread is being executed.
Definition: consts.h:125
AsebaMessagesDests
Identifiers for destinations.
Definition: consts.h:199
Maximum number of arguments in an event (in word)
Definition: consts.h:208
This flag is enabled when an event is running inside the debugger&#39;s fast loop, and cleared to make th...
Definition: consts.h:129
AsebaBytecodeId
List of bytecodes identifiers.
Definition: consts.h:55
AsebaBinaryOperator
List of binary operators.
Definition: consts.h:75
AsebaSpecialEventId
List of special event ID.
Definition: consts.h:133