File tree 3 files changed +12
-13
lines changed
3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change 25
25
*/
26
26
27
27
mergeInto ( LibraryManager . library , {
28
- mp_js_write : function ( ptr , len ) {
29
- const buffer = HEAPU8 . subarray ( ptr , ptr + len )
30
- if ( ENVIRONMENT_IS_NODE ) {
31
- process . stdout . write ( buffer ) ;
32
- } else {
33
- const printEvent = new CustomEvent ( 'micropython-print' , { detail : buffer } ) ;
34
- document . dispatchEvent ( printEvent ) ;
35
- }
36
- } ,
37
-
38
28
// This string will be emitted directly into the output file by Emscripten.
39
29
mp_js_ticks_ms__postset : "var MP_JS_EPOCH = Date.now()" ,
40
30
Original file line number Diff line number Diff line change 46
46
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
47
47
#define MICROPY_ENABLE_DOC_STRING (1)
48
48
#define MICROPY_WARNINGS (1)
49
+ #define MICROPY_ERROR_PRINTER (&mp_stderr_print)
49
50
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
50
51
#define MICROPY_USE_INTERNAL_ERRNO (1)
51
52
#define MICROPY_USE_INTERNAL_PRINTF (0)
60
61
#endif
61
62
#define MICROPY_VFS_POSIX (MICROPY_VFS)
62
63
#define MICROPY_PY_SYS_PLATFORM "webassembly"
63
- #define MICROPY_PY_SYS_STDFILES (0)
64
64
65
65
#define MICROPY_EVENT_POLL_HOOK \
66
66
do { \
@@ -102,4 +102,6 @@ typedef long mp_off_t;
102
102
#define _GNU_SOURCE
103
103
#endif
104
104
105
+ extern const struct _mp_print_t mp_stderr_print ;
106
+
105
107
uint32_t mp_js_random_u32 (void );
Original file line number Diff line number Diff line change 24
24
* THE SOFTWARE.
25
25
*/
26
26
27
+ #include <unistd.h>
27
28
#include "library.h"
28
29
#include "mphalport.h"
29
30
31
+ static void stderr_print_strn (void * env , const char * str , size_t len ) {
32
+ (void )env ;
33
+ write (2 , str , len );
34
+ }
35
+
36
+ const mp_print_t mp_stderr_print = {NULL , stderr_print_strn };
37
+
30
38
mp_uint_t mp_hal_stdout_tx_strn (const char * str , size_t len ) {
31
- mp_js_write (str , len );
32
- return len ;
39
+ return write (1 , str , len );
33
40
}
34
41
35
42
void mp_hal_delay_ms (mp_uint_t ms ) {
You can’t perform that action at this time.
0 commit comments