Skip to main content
Marc ZK
Associate II
June 26, 2017
Question

Running Python on SPWF04Sx

  • June 26, 2017
  • 5 replies
  • 2084 views
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.
    This topic has been closed for replies.

    5 replies

    Gerardo GALLUCCI
    ST Employee
    June 26, 2017
    Posted on June 26, 2017 at 14:56

    File '2:wind.py', line 1

    I think you are facing a copy/paste error. Please paste script into an editor (e.g. notepad++), and check what you are sending to the module.

    This is what I see:

    at+s.python=wind.py

    AT-S.Launching script:2:wind.py

    AT-S.OK:17104:10

    Ciao

    jerry

    Marc ZK
    Marc ZKAuthor
    Associate II
    June 26, 2017
    Posted on June 26, 2017 at 15:48

    I am already using Notepad++ and there are no cut/paste errors from section 5.2

    I have also tried the code from section 5.1, and this produces the same error.

    Does the cut and pasted code work for you?

    Gerardo GALLUCCI
    ST Employee
    June 26, 2017
    Posted on June 26, 2017 at 15:58

    pdf to module -> error

    pdf to notepad (edit to use TABs) to module -> ok

    Marc ZK
    Marc ZKAuthor
    Associate II
    June 26, 2017
    Posted on June 26, 2017 at 16:30

    It still doesn't work for me.  I tried editing to format the python with both spaces and TABs, neither works for me.

    Even a 1 line .py file with

    print('hello') 

    doesnt work for me 

    AT+S.FSC=hello.py,16  

    AT-S.OK received   

    AT+S.PYTHON=hello.py

    Traceback (most recent call last):

     File '2:hello.py', line 1

    SyntaxError: invalid syntax

    +WIND:0:Console active

    Gerardo GALLUCCI
    ST Employee
    June 26, 2017
    Posted on June 26, 2017 at 20:52

    I have a doubt...

    Are you using STM32 Nucleo as USB2UART bridge?

    Marc ZK
    Marc ZKAuthor
    Associate II
    June 27, 2017
    Posted on June 27, 2017 at 09:03

    yes I am...

    Am i doing something wrong?

    Marc ZK
    Marc ZKAuthor
    Associate II
    June 27, 2017
    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

    Nicholas Yunker
    Associate
    June 30, 2017
    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.