Skip to content

Commit 983a38b

Browse files
authored
Merge pull request #171 from lymzzyh/master
add pyexec_str
2 parents 5193927 + 4f9e5d7 commit 983a38b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/utils/pyexec.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ STATIC bool repl_display_debugging_info = 0;
5353
#define EXEC_FLAG_PRINT_EOF (1)
5454
#define EXEC_FLAG_ALLOW_DEBUGGING (2)
5555
#define EXEC_FLAG_IS_REPL (4)
56-
#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8)
57-
#define EXEC_FLAG_SOURCE_IS_VSTR (16)
58-
#define EXEC_FLAG_SOURCE_IS_FILENAME (32)
56+
#define EXEC_FLAG_RERAISE (8)
57+
#define EXEC_FLAG_SOURCE_IS_RAW_CODE (16)
58+
#define EXEC_FLAG_SOURCE_IS_VSTR (32)
59+
#define EXEC_FLAG_SOURCE_IS_FILENAME (64)
5960

6061
// parses, compiles and executes the code in the lexer
6162
// frees the lexer before returning
@@ -550,6 +551,9 @@ int pyexec_friendly_repl(void) {
550551
int pyexec_file(const char *filename) {
551552
return parse_compile_execute(filename, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_FILENAME);
552553
}
554+
int pyexec_str(vstr_t *str) {
555+
return parse_compile_execute(str, MP_PARSE_FILE_INPUT, EXEC_FLAG_RERAISE | EXEC_FLAG_SOURCE_IS_VSTR);
556+
}
553557

554558
int pyexec_file_if_exists(const char *filename) {
555559
#if MICROPY_MODULE_FROZEN

port/mphalport.c

+8
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ int mp_hal_stdin_rx_chr(void) {
6363
// Send string of given length
6464
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
6565
mp_putsn(str, len);
66+
#ifdef PKG_USING_OPENMV_CP
67+
extern void serial_dbg_send_strn(const char *str, int len);
68+
serial_dbg_send_strn(str, len);
69+
#endif
6670
}
6771

6872
void mp_hal_stdout_tx_strn_stream(const char *str, size_t len) {
6973
mp_putsn_stream(str, len);
74+
#ifdef PKG_USING_OPENMV_CP
75+
extern void serial_dbg_send_strn_cooked(const char *str, int len);
76+
serial_dbg_send_strn_cooked(str, len);
77+
#endif
7078
}
7179

7280
mp_uint_t mp_hal_ticks_us(void) {

0 commit comments

Comments
 (0)