summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--cc3200/mods/modmachine.c12
-rw-r--r--cc3200/mptask.c7
-rw-r--r--tests/wipy/wlan/machine.py42
-rw-r--r--tests/wipy/wlan/machine.py.exp7
-rw-r--r--tests/wipy/wlan/wlan.py2
-rw-r--r--tests/wipy/wlan/wlan.py.exp1
6 files changed, 62 insertions, 9 deletions
diff --git a/cc3200/mods/modmachine.c b/cc3200/mods/modmachine.c
index 514335abbf..228aff0cf9 100644
--- a/cc3200/mods/modmachine.c
+++ b/cc3200/mods/modmachine.c
@@ -134,6 +134,16 @@ STATIC mp_obj_t machine_unique_id(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id);
+STATIC mp_obj_t machine_main(mp_obj_t main) {
+ if (MP_OBJ_IS_STR(main)) {
+ MP_STATE_PORT(machine_config_main) = main;
+ } else {
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
+ }
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(machine_main_obj, machine_main);
+
STATIC mp_obj_t machine_idle(void) {
__WFI();
return mp_const_none;
@@ -162,8 +172,6 @@ STATIC mp_obj_t machine_wake_reason (void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_wake_reason_obj, machine_wake_reason);
-MP_DECLARE_CONST_FUN_OBJ(machine_main_obj); // defined in main.c
-
STATIC const mp_map_elem_t machine_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_machine) },
diff --git a/cc3200/mptask.c b/cc3200/mptask.c
index 82e0425a52..f8060f440b 100644
--- a/cc3200/mptask.c
+++ b/cc3200/mptask.c
@@ -366,10 +366,3 @@ STATIC void mptask_create_main_py (void) {
f_close(&fp);
}
-STATIC mp_obj_t machine_main(mp_obj_t main) {
- if (MP_OBJ_IS_STR(main)) {
- MP_STATE_PORT(machine_config_main) = main;
- }
- return mp_const_none;
-}
-MP_DEFINE_CONST_FUN_OBJ_1(machine_main_obj, machine_main);
diff --git a/tests/wipy/wlan/machine.py b/tests/wipy/wlan/machine.py
new file mode 100644
index 0000000000..2ee5299651
--- /dev/null
+++ b/tests/wipy/wlan/machine.py
@@ -0,0 +1,42 @@
+'''
+machine test for the CC3200 based boards.
+'''
+
+import machine
+import os
+from network import WLAN
+
+mch = os.uname().machine
+if not 'LaunchPad' in mch and not'WiPy' in mch:
+ raise Exception('Board not supported!')
+
+wifi = WLAN()
+
+print(machine)
+machine.idle()
+print(machine.freq() == (80000000,))
+print(machine.unique_id() == wifi.mac())
+
+machine.main('main.py')
+
+rand_nums = []
+for i in range(0, 100):
+ rand = machine.rng()
+ if rand not in rand_nums:
+ rand_nums.append(rand)
+ else:
+ print('RNG number repeated')
+ break
+
+for i in range(0, 10):
+ machine.idle()
+
+print("Active")
+
+print(machine.reset_cause() >= 0)
+print(machine.wake_reason() >= 0)
+
+try:
+ machine.main(123456)
+except:
+ print('Exception')
diff --git a/tests/wipy/wlan/machine.py.exp b/tests/wipy/wlan/machine.py.exp
new file mode 100644
index 0000000000..303a0633a6
--- /dev/null
+++ b/tests/wipy/wlan/machine.py.exp
@@ -0,0 +1,7 @@
+<module 'machine'>
+True
+True
+Active
+True
+True
+Exception
diff --git a/tests/wipy/wlan/wlan.py b/tests/wipy/wlan/wlan.py
index 8d2537511b..922cb5dc6e 100644
--- a/tests/wipy/wlan/wlan.py
+++ b/tests/wipy/wlan/wlan.py
@@ -97,6 +97,8 @@ print(wifi.isconnected() == False)
# test init again
wifi.init(WLAN.AP, ssid='www.wipy.io', auth=None, channel=5, antenna=WLAN.INT_ANT)
+print(len(wlan.mac()) == 6)
+
# next ones MUST raise
try:
wifi.init(mode=12345)
diff --git a/tests/wipy/wlan/wlan.py.exp b/tests/wipy/wlan/wlan.py.exp
index 407c31db98..6d27bb31c0 100644
--- a/tests/wipy/wlan/wlan.py.exp
+++ b/tests/wipy/wlan/wlan.py.exp
@@ -32,6 +32,7 @@ True
True
True
True
+True
Exception
Exception
Exception