Since I'm too busy to start (another) blog at the moment, I thought I'd leave some tips and discoveries here..
It turns out, the SIM5320a has a Lua virtual machine onboard which can execute your own applications directly on the chip! I'm working to see if I can simplify my hardware design on my project by eliminating a controller board (currently a Pi). Also, I noticed the SIM5320a has two I2C pins on it which may be available via the Lua libraries, but more of that in a later post. Currently, I'd like to show how I was able to upload HelloWorld.lua to the Fona and execute it. For reference, my SIM5320a breakout board is connected to a Pi Zero, which I am accessing via my Mac and ssh. (I should post that set up, too, which was a bear, a lot harder than for a Pi2 or Pi3...)
1.) SSH into the Pi Zero (named fonaPi.local on my internal network):
- Code: Select all | TOGGLE FULL SIZE
ssh pi@fonaPi.local
2.) Write the HelloWorld.lua program (I used 'vi'. I'm old-school.)
- Code: Select all | TOGGLE FULL SIZE
atctl.setport(1) --Set the serial port that talks over rx/tx pins.
atctl.send("\r\nHello World\r\n") -- Send "Hello World" over the serial port.
atctl.setport(-1) -- Release the port. Dunno if this matters.
It is *important* to note that I ended the file with a carriage return. This makes it easier later.
3.) Check the size of the file on the bash command line:
- Code: Select all | TOGGLE FULL SIZE
ls -al ls -al HelloWorld.lua
Shell output:
- Code: Select all | TOGGLE FULL SIZE
-rw-r--r-- 1 pi pi 211 Oct 10 18:18 HelloWorld.lua
The file is 211 bytes.
4.) See if minicom is installed using the bash command line:
- Code: Select all | TOGGLE FULL SIZE
which minicom
Shell output:
- Code: Select all | TOGGLE FULL SIZE
/usr/bin/minicom
5.) If not installed, install minicom from the command line.
- Code: Select all | TOGGLE FULL SIZE
sudo apt-get install minicom
6.) Connect to the SIM5320a fona board:
- Code: Select all | TOGGLE FULL SIZE
minicom -D /dev/ttyAMA0 -b 115200
Note: It's a pain to get the Pi zero to see /dev/ttyAMA0. I'll describe the instructions in a Pi zero configuration post if requested.
7.) Prepare to upload the file from the minicom terminal:
- Code: Select all | TOGGLE FULL SIZE
AT+CFTRANRX="c:/HelloWorld.lua",211
Response:
- Code: Select all | TOGGLE FULL SIZE
>
Note: It is VERY IMPORTANT not to hit enter or any other key in the terminal window, since that will be sent as part of the file uploaded!
Note: 211 is the number of bytes we found earlier. Make sure it matches the results obtained in step 3.
8.) Upload the file from the minicom command terminal.
Hit 'ctrl+a'
Hit 's'
Response from minicom:
- Code: Select all | TOGGLE FULL SIZE
+-[Upload]--+
| zmodem |
| ymodem |
| xmodem |
| kermit |
| ascii |
+-----------+
9.) Select 'ascii' by arrowing down and hitting enter. You should see your Pi's local directory.
10.) Select 'HelloWorld.lua' by arrowing down the file and hitting 'space'. Then hit 'enter'.
Response (from the SIM):
- Code: Select all | TOGGLE FULL SIZE
OK
11.) Make sure your file is there (Type this in the minicom terminal.):
- Code: Select all | TOGGLE FULL SIZE
AT+FSLS=0
Response:
- Code: Select all | TOGGLE FULL SIZE
+FSLS: FILES:
HelloWorld.lua
12.) Check the file is *completely* there (from the minicom terminal):
- Code: Select all | TOGGLE FULL SIZE
AT+CFTRANTX="C:/HelloWorld.lua"
Response:
- Code: Select all | TOGGLE FULL SIZE
+CFTRANTX: DATA,211
atctl.setport(1) --Set the serial port that talks over rx/tx pins.
atctl.send("\r\nHello World\r\n") -- Send "Hello World" over the serial port.
atctl.setport(-1) -- Release the port. Dunno if this matters.
+CFTRANTX: 0
13.) Run the code from the minicom terminal:
- Code: Select all | TOGGLE FULL SIZE
AT+CSCRIPTSTART="c:/HelloWorld.lua",0
Response:
- Code: Select all | TOGGLE FULL SIZE
OK
Hello World
+CSCRIPT: 0
14.) Check out the Lua supplemental documentation for all the fun stuff you can do!
http://tinyurl.com/jhc4ej6
Note: Maybe somebody at Adafruit can get an updated version of this doc and post it?