Commit f8168414 authored by Daniel Campora's avatar Daniel Campora
Browse files

cc3200: Implement os.uname() to get details of the OS and hardware.

parent 6fefd5d3
......@@ -43,8 +43,7 @@ Once the software is running, you have two options to access the MicroPython REP
- Through the UART.
**Connect to PORT 22, baud rate = 115200, parity = none, stop bits = 1**
- Through telnet.
* 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
and **ssid = "launchpad-wlan", key = "micropython"** in the case of the Launchpad.
* Connect to the network created by the board (as boots up in AP mode), **ssid = "wipy-wlan", key = "www.wipy.io"**.
* You can also reinitialize the WLAN in station mode and connect to another AP, or in AP mode but with a
different ssid and/or key.
* Use your favourite telnet client with the following settings: **host = 192.168.1.1, port = 23.**
......
......@@ -25,19 +25,11 @@
* THE SOFTWARE.
*/
#include "version.h"
#define LAUNCHXL
#define BOARD_NAME "LaunchPad "
#define MICROPY_HW_BOARD_NAME VERSION_E(BOARD_NAME, VERSION_NUMBER)
#define MICROPY_HW_BOARD_NAME "LaunchPad"
#define MICROPY_HW_MCU_NAME "CC3200"
#define MICROPY_PORT_WLAN_AP_SSID "launchpad-wlan"
#define MICROPY_PORT_WLAN_AP_KEY "micropython"
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
......
......@@ -25,19 +25,11 @@
* THE SOFTWARE.
*/
#include "version.h"
#define WIPY_SD
#define BOARD_NAME "WiPy-SD "
#define MICROPY_HW_BOARD_NAME VERSION_E(BOARD_NAME, VERSION_NUMBER)
#define MICROPY_HW_BOARD_NAME "WiPy-SD"
#define MICROPY_HW_MCU_NAME "CC3200"
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"
#define MICROPY_PORT_WLAN_AP_KEY "www.wipy.io"
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
......
......@@ -25,19 +25,11 @@
* THE SOFTWARE.
*/
#include "version.h"
#define WIPY
#define BOARD_NAME "WiPy "
#define MICROPY_HW_BOARD_NAME VERSION_E(BOARD_NAME, VERSION_NUMBER)
#define MICROPY_HW_BOARD_NAME "WiPy"
#define MICROPY_HW_MCU_NAME "CC3200"
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"
#define MICROPY_PORT_WLAN_AP_KEY "www.wipy.io"
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
......
......@@ -233,15 +233,6 @@ STATIC mp_obj_t pyb_repl_uart(uint n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_repl_uart_obj, 0, 1, pyb_repl_uart);
/// \function version()
/// Prints the software version (MicroPython + Port)
STATIC mp_obj_t pyb_version(void) {
char version[128];
snprintf(version, sizeof(version), "Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME);
return mp_obj_new_str(version, strlen(version), false);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_version_obj, pyb_version);
MP_DECLARE_CONST_FUN_OBJ(pyb_main_obj); // defined in main.c
STATIC const mp_map_elem_t pyb_module_globals_table[] = {
......@@ -266,7 +257,6 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_elapsed_micros), (mp_obj_t)&pyb_elapsed_micros_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_delay), (mp_obj_t)&pyb_delay_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_udelay), (mp_obj_t)&pyb_udelay_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&pyb_version_obj },
#if MICROPY_HW_ENABLE_RNG
{ MP_OBJ_NEW_QSTR(MP_QSTR_rng), (mp_obj_t)&pyb_rng_get_obj },
......
......@@ -32,6 +32,8 @@
#include "py/nlr.h"
#include "py/obj.h"
#include "py/objtuple.h"
#include "py/objstr.h"
#include "genhdr/py-version.h"
#include "ff.h"
#include "diskio.h"
#include "sflash_diskio.h"
......@@ -40,6 +42,7 @@
#include "random.h"
#include "sd_diskio.h"
#include "mpexception.h"
#include "version.h"
/// \module os - basic "operating system" services
///
......@@ -69,6 +72,31 @@ STATIC bool sd_in_root(void) {
// Micro Python bindings
//
STATIC const qstr os_uname_info_fields[] = {
MP_QSTR_sysname, MP_QSTR_nodename,
MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine
};
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_PY_SYS_PLATFORM);
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_PY_SYS_PLATFORM);
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, WIPY_SW_VERSION_NUMBER);
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE);
STATIC const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME);
STATIC MP_DEFINE_ATTRTUPLE(
os_uname_info_obj,
os_uname_info_fields,
5,
(mp_obj_t)&os_uname_info_sysname_obj,
(mp_obj_t)&os_uname_info_nodename_obj,
(mp_obj_t)&os_uname_info_release_obj,
(mp_obj_t)&os_uname_info_version_obj,
(mp_obj_t)&os_uname_info_machine_obj
);
STATIC mp_obj_t os_uname(void) {
return (mp_obj_t)&os_uname_info_obj;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
/// \function chdir(path)
/// Change current directory.
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);
STATIC const mp_map_elem_t os_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_uos) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_uname), (mp_obj_t)&os_uname_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_chdir), (mp_obj_t)&os_chdir_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_getcwd), (mp_obj_t)&os_getcwd_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_listdir), (mp_obj_t)&os_listdir_obj },
......
......@@ -174,5 +174,11 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
#define MICROPY_PIN_DEFS_PORT_H "pin_defs_cc3200.h"
#define MICROPY_PORT_HAS_TELNET (1)
#define MICROPY_PORT_HAS_FTP (1)
#define MICROPY_PY_SYS_PLATFORM "WiPy"
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"
#define MICROPY_PORT_WLAN_AP_KEY "www.wipy.io"
#define MICROPY_PORT_WLAN_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
#define MICROPY_PORT_WLAN_AP_CHANNEL 5
#endif // __INCLUDED_MPCONFIGPORT_H
......@@ -56,7 +56,6 @@ Q(micros)
Q(elapsed_millis)
Q(elapsed_micros)
Q(udelay)
Q(version)
Q(flush)
Q(FileIO)
Q(mkdisk)
......@@ -78,6 +77,12 @@ Q(heapq)
// for os module
Q(uos)
Q(os)
Q(sysname)
Q(nodename)
Q(release)
Q(version)
Q(machine)
Q(uname)
Q(/)
Q(flash)
#if MICROPY_HW_HAS_SDCARD
......
......@@ -27,9 +27,6 @@
#ifndef VERSION_H_
#define VERSION_H_
#define VERSION_NUMBER v0.9.0
#define VERSION_PASTE(name, number) name # number
#define VERSION_E(name, number) VERSION_PASTE(name, number)
#define WIPY_SW_VERSION_NUMBER "0.9.1"
#endif /* VERSION_H_ */
Supports Markdown
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