Skip to content

Commit f816841

Browse files
author
Daniel Campora
committed
cc3200: Implement os.uname() to get details of the OS and hardware.
1 parent 6fefd5d commit f816841

9 files changed

Lines changed: 46 additions & 44 deletions

File tree

cc3200/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ Once the software is running, you have two options to access the MicroPython REP
4343
- Through the UART.
4444
**Connect to PORT 22, baud rate = 115200, parity = none, stop bits = 1**
4545
- Through telnet.
46-
* Connect to the network created by the board (as boots up in AP mode), **ssid = "wipy-wlan", key = "www.wipy.io"** in the case of the WiPy
47-
and **ssid = "launchpad-wlan", key = "micropython"** in the case of the Launchpad.
46+
* Connect to the network created by the board (as boots up in AP mode), **ssid = "wipy-wlan", key = "www.wipy.io"**.
4847
* You can also reinitialize the WLAN in station mode and connect to another AP, or in AP mode but with a
4948
different ssid and/or key.
5049
* Use your favourite telnet client with the following settings: **host = 192.168.1.1, port = 23.**

cc3200/boards/LAUNCHXL/mpconfigboard.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#include "version.h"
29-
3028
#define LAUNCHXL
3129

32-
#define BOARD_NAME "LaunchPad "
33-
#define MICROPY_HW_BOARD_NAME VERSION_E(BOARD_NAME, VERSION_NUMBER)
30+
#define MICROPY_HW_BOARD_NAME "LaunchPad"
3431
#define MICROPY_HW_MCU_NAME "CC3200"
3532

36-
#define MICROPY_PORT_WLAN_AP_SSID "launchpad-wlan"
37-
#define MICROPY_PORT_WLAN_AP_KEY "micropython"
38-
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
39-
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
40-
4133
#define MICROPY_HW_HAS_SDCARD (0)
4234
#define MICROPY_HW_ENABLE_RNG (1)
4335
#define MICROPY_HW_ENABLE_RTC (1)

cc3200/boards/WIPY-SD/mpconfigboard.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#include "version.h"
29-
3028
#define WIPY_SD
3129

32-
#define BOARD_NAME "WiPy-SD "
33-
#define MICROPY_HW_BOARD_NAME VERSION_E(BOARD_NAME, VERSION_NUMBER)
30+
#define MICROPY_HW_BOARD_NAME "WiPy-SD"
3431
#define MICROPY_HW_MCU_NAME "CC3200"
3532

36-
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"
37-
#define MICROPY_PORT_WLAN_AP_KEY "www.wipy.io"
38-
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
39-
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
40-
4133
#define MICROPY_HW_HAS_SDCARD (1)
4234
#define MICROPY_HW_ENABLE_RNG (1)
4335
#define MICROPY_HW_ENABLE_RTC (1)

cc3200/boards/WIPY/mpconfigboard.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#include "version.h"
29-
3028
#define WIPY
3129

32-
#define BOARD_NAME "WiPy "
33-
#define MICROPY_HW_BOARD_NAME VERSION_E(BOARD_NAME, VERSION_NUMBER)
30+
#define MICROPY_HW_BOARD_NAME "WiPy"
3431
#define MICROPY_HW_MCU_NAME "CC3200"
3532

36-
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"
37-
#define MICROPY_PORT_WLAN_AP_KEY "www.wipy.io"
38-
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
39-
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
40-
4133
#define MICROPY_HW_HAS_SDCARD (0)
4234
#define MICROPY_HW_ENABLE_RNG (1)
4335
#define MICROPY_HW_ENABLE_RTC (1)

cc3200/mods/modpyb.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,6 @@ STATIC mp_obj_t pyb_repl_uart(uint n_args, const mp_obj_t *args) {
233233
}
234234
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_repl_uart_obj, 0, 1, pyb_repl_uart);
235235

236-
/// \function version()
237-
/// Prints the software version (MicroPython + Port)
238-
STATIC mp_obj_t pyb_version(void) {
239-
char version[128];
240-
snprintf(version, sizeof(version), "Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME);
241-
return mp_obj_new_str(version, strlen(version), false);
242-
}
243-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_version_obj, pyb_version);
244-
245236
MP_DECLARE_CONST_FUN_OBJ(pyb_main_obj); // defined in main.c
246237

247238
STATIC const mp_map_elem_t pyb_module_globals_table[] = {
@@ -266,7 +257,6 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
266257
{ MP_OBJ_NEW_QSTR(MP_QSTR_elapsed_micros), (mp_obj_t)&pyb_elapsed_micros_obj },
267258
{ MP_OBJ_NEW_QSTR(MP_QSTR_delay), (mp_obj_t)&pyb_delay_obj },
268259
{ MP_OBJ_NEW_QSTR(MP_QSTR_udelay), (mp_obj_t)&pyb_udelay_obj },
269-
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&pyb_version_obj },
270260

271261
#if MICROPY_HW_ENABLE_RNG
272262
{ MP_OBJ_NEW_QSTR(MP_QSTR_rng), (mp_obj_t)&pyb_rng_get_obj },

cc3200/mods/moduos.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "py/nlr.h"
3333
#include "py/obj.h"
3434
#include "py/objtuple.h"
35+
#include "py/objstr.h"
36+
#include "genhdr/py-version.h"
3537
#include "ff.h"
3638
#include "diskio.h"
3739
#include "sflash_diskio.h"
@@ -40,6 +42,7 @@
4042
#include "random.h"
4143
#include "sd_diskio.h"
4244
#include "mpexception.h"
45+
#include "version.h"
4346

4447
/// \module os - basic "operating system" services
4548
///
@@ -69,6 +72,31 @@ STATIC bool sd_in_root(void) {
6972
// Micro Python bindings
7073
//
7174

75+
STATIC const qstr os_uname_info_fields[] = {
76+
MP_QSTR_sysname, MP_QSTR_nodename,
77+
MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine
78+
};
79+
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_PY_SYS_PLATFORM);
80+
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_PY_SYS_PLATFORM);
81+
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, WIPY_SW_VERSION_NUMBER);
82+
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE);
83+
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME);
84+
STATIC MP_DEFINE_ATTRTUPLE(
85+
os_uname_info_obj,
86+
os_uname_info_fields,
87+
5,
88+
(mp_obj_t)&os_uname_info_sysname_obj,
89+
(mp_obj_t)&os_uname_info_nodename_obj,
90+
(mp_obj_t)&os_uname_info_release_obj,
91+
(mp_obj_t)&os_uname_info_version_obj,
92+
(mp_obj_t)&os_uname_info_machine_obj
93+
);
94+
95+
STATIC mp_obj_t os_uname(void) {
96+
return (mp_obj_t)&os_uname_info_obj;
97+
}
98+
STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
99+
72100
/// \function chdir(path)
73101
/// Change current directory.
74102
STATIC mp_obj_t os_chdir(mp_obj_t path_in) {
@@ -321,6 +349,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mkdisk_obj, os_mkdisk);
321349
STATIC const mp_map_elem_t os_module_globals_table[] = {
322350
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_uos) },
323351

352+
{ MP_OBJ_NEW_QSTR(MP_QSTR_uname), (mp_obj_t)&os_uname_obj },
324353
{ MP_OBJ_NEW_QSTR(MP_QSTR_chdir), (mp_obj_t)&os_chdir_obj },
325354
{ MP_OBJ_NEW_QSTR(MP_QSTR_getcwd), (mp_obj_t)&os_getcwd_obj },
326355
{ MP_OBJ_NEW_QSTR(MP_QSTR_listdir), (mp_obj_t)&os_listdir_obj },

cc3200/mpconfigport.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,11 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
174174
#define MICROPY_PIN_DEFS_PORT_H "pin_defs_cc3200.h"
175175
#define MICROPY_PORT_HAS_TELNET (1)
176176
#define MICROPY_PORT_HAS_FTP (1)
177+
#define MICROPY_PY_SYS_PLATFORM "WiPy"
178+
179+
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"
180+
#define MICROPY_PORT_WLAN_AP_KEY "www.wipy.io"
181+
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
182+
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
177183

178184
#endif // __INCLUDED_MPCONFIGPORT_H

cc3200/qstrdefsport.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Q(micros)
5656
Q(elapsed_millis)
5757
Q(elapsed_micros)
5858
Q(udelay)
59-
Q(version)
6059
Q(flush)
6160
Q(FileIO)
6261
Q(mkdisk)
@@ -78,6 +77,12 @@ Q(heapq)
7877
// for os module
7978
Q(uos)
8079
Q(os)
80+
Q(sysname)
81+
Q(nodename)
82+
Q(release)
83+
Q(version)
84+
Q(machine)
85+
Q(uname)
8186
Q(/)
8287
Q(flash)
8388
#if MICROPY_HW_HAS_SDCARD

cc3200/version.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#ifndef VERSION_H_
2828
#define VERSION_H_
2929

30-
#define VERSION_NUMBER v0.9.0
31-
32-
#define VERSION_PASTE(name, number) name # number
33-
#define VERSION_E(name, number) VERSION_PASTE(name, number)
30+
#define WIPY_SW_VERSION_NUMBER "0.9.1"
3431

3532
#endif /* VERSION_H_ */

0 commit comments

Comments
 (0)