Example Code

Passing data to and from embedded targets using the WIFI connectivity of Toshiba FlashAir SD cards

Code and Documents

Attachment

Overview

Adding WIFI connectivity to an embedded sbRIO (or other targets) requires external hardware. It also requires the code to handle the connection and manage data transfer back to the host. The code attached here takes a different approach by making a WIFI connection, independent of the controller, utilising Toshiba FlashAir SD cards.


Description

The Toshiba FlashAir cards are SD cards which integrate a WIFI connection and simple processor alongside the data storage. Using this connection, data can be retrieved and even uploaded to the card, all without any input from the device into which it has been plugged. They seem to be like the EyeFi Pro cards but rather cheaper. Their main use seems to be targeted at digital cameras but there is no reason they can’t be used in a single-board RIO such as the sbRIO-9636 with which I have tested it.

There are several operating modes for the cards which are directly supported by the configuration software. There is also a ‘station’ mode which is what I have used here. In station mode, the card attaches itself to an existing network, supporting the usual encryption options.

Once it is connected, it can be interrogated using its web interface. There is also an API and it is this that the example below uses to provide programmatic access to the card. The code on the sbRIO knows nothing about this connection and because of this there are caveats as to how it can be used without losing data.

For more details, there is very good documentation on this website...  https://flashair-developers.com/en/documents/api

Steps to Implement or Execute Code

  1. First thing you need to do is configure the FlashAir card. The easiest way to do this is to plug the SD card into your PC and edit the CONFIG file which can be found in the hidden folder SD_WLAN in the root of the card.
  2. Change APPMODE to 5. This sets the card into station mode.
  3. Set APPSSID to the SSID of your Intfrastructure WIFI network
  4. Set APPNETWORKKEY to the WIFI password. Don’t worry, this disappears when you reboot to be replaced with asterisks.
  5. Set APPNAME to the network name you will use to talk to the SD card.
  6. At this point, you may want to add a line UPLOAD=1   This allows you to write to the card as well as read from it.

It is worth mentioning here, the one problem with this approach.

If you modify the card by deleting or writing to it over the network, do be aware that the OS on the target knows nothing about it. As it says on their website, this can result in data corruption if the OS subsequently accesses the card. This is due to the way that the allocation table is cached by the OS. On the sbRIO I found the same thing and have yet to find any mechanism to programmatically force it to re-scan the card. Power cycling clears it of course.

One possibility for safe communication with the RT target would be to overwrite the data in an existing file, thereby avoiding changes in the file structure on the disk. I’ve not tried this yet, however there is no reason in principle why this wouldn’t work. Listing the files transferred successfully would allow the sbRIO to delete those files itself without messing up the allocation table. Flash memory is handled rather differently to disk-drives though so this needs testing.


Requirements

Software

LabVIEW 2014+  (although the same code should work in older versions if converted)


Hardware

Toshiba FlashAir SD card series 2 on 


Additional Images or Video


Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors