cancel
Showing results for 
Search instead for 
Did you mean: 

SPWF04 - Repeatedly delete/create file problem

Richard Bene¨
Associate II
Posted on April 30, 2018 at 16:11

Hello, I would like to share one complication with editing files on SPWF04.

My SPWF04SA is connected via SPI to MCU (STM32F407). SPWF04 webpage should be dynamically updated with data from MCU.

My solution is

  • MCU gets data from its peripherals and creates a JSON string from them
  • MCU updates file 'data.txt' on SPWF04 (this file contains the JSON string)

    • AT+S.FSD (delete old file)
    • AT+S.FSC (create new one with up-to-date content)
  • HTML page 'index.html' on SPWF04 server contains Javacsript, which:
    • In 1 second interval requests the file 'data.txt' from SPWF04 server
    • Parses its content into JSON object
    • Updates values shown on webpage

Actual problem:

So, this works well, content on webpages changes correctly... but not permanently.

After some time (varies between few secs - few minutes), SPWF04 suddenly returns errors 56 and 51 on FSD and FSC commands ('Unable to delete file' and 'Unable to open file').

Then after few seconds SPWF04 restarts, with normal 'startup sequence' -

  • WIND 7 with param 10 (since the console_enabled is set to 1 - UART),
  • WIND 1, WIND 13, WIND 3, WIND 0, WIND 32
  • and then WIND 21 and 35 repeatedly (no WIND 65 or any else error report..)

Sometimes the updating goes correctly for longer time (minutes), but when I refresh html page in browser, it throws this problem.

What I tried

  • Do the same procedure (FSD & FSC) manually over UART console

    • The same result - everything worked, but after some time came 56 and 51 errors.
    • The file 'data.txt' was still there (listed by AT+S.FSL), was possible to print (AT+S.FSP), but impossible to delete or rename (AT+S.FSD, AT+S.FSR)
  • Try to use with or without SD card
    • Same result for both - only with difference location of created file - X with SD card, D (ramdisk) without it..

Aditionaly..

  • I use MCBSTM32F400 development board (STM32F407 as MCU) with NUCLEO-IDW04A1. Connected together by DuPont wires...
  • I use __HAL_SPI_ENABLE(&hspi1); at start of program - without it is problem with SPI clock line - (it's high at begining of byte)
  • When I write commands with optional params (in manual marked as [<param>] instead of <param>) I am sending one byte containing null instead of normal length-content pair
  • When I use command with aditional data (AT+S.FSC), I use the procedure send command - wait for IRQ low - send SYNC - wait for IRQ low - send data
  • I attach log from SALEAE analyzer
  • It is a pity that SPWF04 cannot act as Websocket server... with it it could be much more simple to realize communication between MCU and Javascript content on webpages..

I don't want to put here original source code, since I wrote it in work..

Thank for any reply!

R. Bene�

#web-server #spwf04 #spwf04sa #spi-communication
0 REPLIES 0