Commit fca3308c authored by danicampora's avatar danicampora

cc3200: Improvements to terminal duplication.

parent e19dfe1c
...@@ -31,13 +31,16 @@ ...@@ -31,13 +31,16 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/runtime.h"
#include "py/objstr.h"
#include "inc/hw_types.h" #include "inc/hw_types.h"
#include "inc/hw_ints.h" #include "inc/hw_ints.h"
#include "inc/hw_nvic.h" #include "inc/hw_nvic.h"
#include "hw_memmap.h" #include "hw_memmap.h"
#include "py/mpstate.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "rom_map.h" #include "rom_map.h"
#include "interrupt.h" #include "interrupt.h"
#include "systick.h" #include "systick.h"
...@@ -142,7 +145,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { ...@@ -142,7 +145,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) { if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len); uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
} else { } else {
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_bytes((const byte*)str, len); MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_str_of_type(&mp_type_str, (const byte *)str, len);
mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->write); mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->write);
} }
} }
...@@ -181,10 +184,11 @@ int mp_hal_stdin_rx_chr(void) { ...@@ -181,10 +184,11 @@ int mp_hal_stdin_rx_chr(void) {
} }
} else { } else {
MP_STATE_PORT(os_term_dup_obj)->read[2] = mp_obj_new_int(1); MP_STATE_PORT(os_term_dup_obj)->read[2] = mp_obj_new_int(1);
mp_obj_t rbytes = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read); mp_obj_t data = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read);
if (rbytes != mp_const_none) { // data len is > 0
if (mp_obj_is_true(data)) {
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;
mp_get_buffer_raise(rbytes, &bufinfo, MP_BUFFER_READ); mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
return ((int *)(bufinfo.buf))[0]; return ((int *)(bufinfo.buf))[0];
} }
} }
......
...@@ -91,7 +91,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args, ...@@ -91,7 +91,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,
goto arg_error; goto arg_error;
} }
// retrieve the file paths (with an 6 byte offset because to strip the '/flash' prefix) // retrieve the file paths (with an 6 byte offset in order to strip it from the '/flash' prefix)
const char *keyfile = (args[1].u_obj == mp_const_none) ? NULL : &(mp_obj_str_get_str(args[1].u_obj)[6]); const char *keyfile = (args[1].u_obj == mp_const_none) ? NULL : &(mp_obj_str_get_str(args[1].u_obj)[6]);
const char *certfile = (args[2].u_obj == mp_const_none) ? NULL : &(mp_obj_str_get_str(args[2].u_obj)[6]); const char *certfile = (args[2].u_obj == mp_const_none) ? NULL : &(mp_obj_str_get_str(args[2].u_obj)[6]);
const char *cafile = (args[5].u_obj == mp_const_none || args[4].u_int != SSL_CERT_REQUIRED) ? const char *cafile = (args[5].u_obj == mp_const_none || args[4].u_int != SSL_CERT_REQUIRED) ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment