Skip to content

Commit fca3308

Browse files
author
danicampora
committed
cc3200: Improvements to terminal duplication.
1 parent e19dfe1 commit fca3308

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

cc3200/hal/cc3200_hal.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@
3131
#include <stdio.h>
3232
#include <stdint.h>
3333
#include <string.h>
34+
35+
36+
#include "py/mpstate.h"
37+
#include MICROPY_HAL_H
38+
#include "py/runtime.h"
39+
#include "py/objstr.h"
3440
#include "inc/hw_types.h"
3541
#include "inc/hw_ints.h"
3642
#include "inc/hw_nvic.h"
3743
#include "hw_memmap.h"
38-
#include "py/mpstate.h"
39-
#include "py/runtime.h"
40-
#include MICROPY_HAL_H
4144
#include "rom_map.h"
4245
#include "interrupt.h"
4346
#include "systick.h"
@@ -142,7 +145,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
142145
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
143146
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
144147
} else {
145-
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_bytes((const byte*)str, len);
148+
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_str_of_type(&mp_type_str, (const byte *)str, len);
146149
mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->write);
147150
}
148151
}
@@ -181,10 +184,11 @@ int mp_hal_stdin_rx_chr(void) {
181184
}
182185
} else {
183186
MP_STATE_PORT(os_term_dup_obj)->read[2] = mp_obj_new_int(1);
184-
mp_obj_t rbytes = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read);
185-
if (rbytes != mp_const_none) {
187+
mp_obj_t data = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read);
188+
// data len is > 0
189+
if (mp_obj_is_true(data)) {
186190
mp_buffer_info_t bufinfo;
187-
mp_get_buffer_raise(rbytes, &bufinfo, MP_BUFFER_READ);
191+
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
188192
return ((int *)(bufinfo.buf))[0];
189193
}
190194
}

cc3200/mods/modussl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,
9191
goto arg_error;
9292
}
9393

94-
// retrieve the file paths (with an 6 byte offset because to strip the '/flash' prefix)
94+
// retrieve the file paths (with an 6 byte offset in order to strip it from the '/flash' prefix)
9595
const char *keyfile = (args[1].u_obj == mp_const_none) ? NULL : &(mp_obj_str_get_str(args[1].u_obj)[6]);
9696
const char *certfile = (args[2].u_obj == mp_const_none) ? NULL : &(mp_obj_str_get_str(args[2].u_obj)[6]);
9797
const char *cafile = (args[5].u_obj == mp_const_none || args[4].u_int != SSL_CERT_REQUIRED) ?

0 commit comments

Comments
 (0)