cancel
Showing results for 
Search instead for 
Did you mean: 

Running Python on SPWF04Sx

Marc ZK
Associate II
Posted on June 26, 2017 at 14:41

hi

I am using afor SPWF04Sx Wi-Fi module - and am trying to run the example python code provided in the user guide.

I have the SPWF04Sx configured as console 2 (UART and python)

I have created a file called wind.py and copied the code from the WIND example section 5.2 on page 17 of AN49

I have used the command 'AT+S.FSC=wind.py,479' to copy it to the RAM on the SPWF04Sx

I have tried running it by calling 'AT+S.PYTHON=wind.py' but only get the response:

File '2:wind.py', line 1

SyntaxError: invalid systax

I have also tried the basic code in 5.1 and, i have created a one line python file with only print('hello') in it.

This also gets the same SyntaxError error

Any suggestions?

I've also noticed that the CTRL short codes dont work on my system i.e. CTRL-D is not recognised to exit REPL, -and I am unable to use CTRL-E to enter Paste mode. Any ideas on that one?

Note: this post was migrated and contained many threaded conversations, some content may be missing.
13 REPLIES 13
Marc ZK
Associate II
Posted on June 27, 2017 at 13:47

I've retried and have changed the TeraTerm settings from just CR - to sending a CR/LF on each TX.

This has fixed the problem. When I now paste the data, and then re-read it with AT+S.FSP - i get the full file contents as expected and the AT+S.PYTHON commands works properly.

Thank you for your assistance

Posted on June 27, 2017 at 13:04

So I have now been able to get a very simple 14 byte, 1 line file created print('hello').

however, still if i try to copy and paste one of the example apps from th

e basic example section 5.1 on page 17 of AN4964, it fails. (i have also tried other examples)

I first copy the code into notepad++.

I modify the pasted code - to (a) remove the empty lines, and to (b) add indents.. (I am indenting using 4 spaces, not TABs)

The python file ends with a newline (no spaces on the new line) after the final code line of print(a)

a = 0

while True:

    a = a + 1

    if a % 100 == 0:

        print(a)

I save the file - and see that the number of bytes of the file is: 478.  I copy the contents of my python file to the Clipboard

Using TeraTerm, I reset the board and call AT+S.FSC=mywind.py,478<CR> followed by ALT-V CR to paste the clipboard

I let this run (without another CR) .. and later received an AT-S.OK

I then call AT+S.PYTHON=mywind.py and get the following response:

File '2:test.py', line 5

SyntaxError: invalid syntax

Posted on June 27, 2017 at 13:21

What's the output of AT+S.FSP?

Nicholas Yunker
Associate II
Posted on June 30, 2017 at 14:26

Glad to hear you have gotten this working and that it was a simple fix.  Something to keep in mind, a lot of the uPython functionality isn't working yet (basic stuff works but more 'interesting' WiFi stuff doesn't work).  There will be a firmware update for the modules coming out in the next few weeks.  Make sure to talk to your ST Microelectronics rep to get a copy of this firmware beta.