File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed
atmel-samd/common-hal/supervisor
nrf/common-hal/supervisor
shared-bindings/supervisor Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,7 @@ bool common_hal_get_serial_connected(void) {
32
32
return (bool ) usb_connected ();
33
33
}
34
34
35
+ bool common_hal_get_serial_bytes_available (void ) {
36
+ return (bool ) usb_bytes_available ();
37
+ }
38
+
Original file line number Diff line number Diff line change @@ -32,3 +32,7 @@ bool common_hal_get_serial_connected(void) {
32
32
return (bool ) serial_connected ();
33
33
}
34
34
35
+ bool common_hal_get_serial_bytes_available (void ) {
36
+ return (bool ) serial_bytes_available ();
37
+ }
38
+
Original file line number Diff line number Diff line change @@ -80,8 +80,28 @@ const mp_obj_property_t supervisor_serial_connected_obj = {
80
80
(mp_obj_t )& mp_const_none_obj },
81
81
};
82
82
83
+ /*Added to allow for polling of USB Console*/
84
+ STATIC mp_obj_t supervisor_get_serial_bytes_available (mp_obj_t self ){
85
+ if (!common_hal_get_serial_bytes_available ()) {
86
+ return mp_const_false ;
87
+ }
88
+ else {
89
+ return mp_const_true ;
90
+ }
91
+ }
92
+ MP_DEFINE_CONST_FUN_OBJ_1 (supervisor_get_serial_bytes_available_obj , supervisor_get_serial_bytes_available );
93
+
94
+ const mp_obj_property_t supervisor_serial_bytes_available_obj = {
95
+ .base .type = & mp_type_property ,
96
+ .proxy = {(mp_obj_t )& supervisor_get_serial_bytes_available_obj ,
97
+ (mp_obj_t )& mp_const_none_obj ,
98
+ (mp_obj_t )& mp_const_none_obj },
99
+ };
100
+
101
+
83
102
STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table [] = {
84
103
{ MP_ROM_QSTR (MP_QSTR_serial_connected ), MP_ROM_PTR (& supervisor_serial_connected_obj ) },
104
+ { MP_ROM_QSTR (MP_QSTR_serial_bytes_available ), MP_ROM_PTR (& supervisor_serial_bytes_available_obj ) },
85
105
};
86
106
87
107
STATIC MP_DEFINE_CONST_DICT (supervisor_runtime_locals_dict , supervisor_runtime_locals_dict_table );
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ const mp_obj_type_t supervisor_runtime_type;
35
35
36
36
bool common_hal_get_serial_connected (void );
37
37
38
+ bool common_hal_get_serial_bytes_available (void );
39
+
38
40
//TODO: placeholders for future functions
39
41
//bool common_hal_get_repl_active(void);
40
42
//bool common_hal_get_usb_enumerated(void);
You can’t perform that action at this time.
0 commit comments