Test program for Pawn 4 interpreter. Looks for a main.amx on the mbed 'drive', loads it, and calls the main() function within it.
Welcome to the Pawn 4 mbed test program. This program is designed to show off all features of the Pawn mbed port. Currently, it will do the following:
- Create a Pawn VM instance - Add the following modules to the Pawn VM - mbed - console (used only for printf currently) - time (date/time, delay functions) - Look for a main.amx file at the root of the mbed file system. If found, will attempt to load whole file into memory. IMPORTANT: when the program opens the file on the mbed file system, the mbed will unmount itself from any connected PC/Mac, possibly resulting in a rude-looking OS message (I am looking at you OS X). It will reappear when the program closes the main.amx file. - Attempt to execute the main function in the loaded script - When the main routine returns, it will currently sit in a loop blinking LED4. It may be better to simply re-run the main routine. Perhaps a special return value can determine what we do...
Also see the Pawn4 library project for details on how to set up your development environment on the mbed itself and how to build scripts.
Revision 2:4400650fe664, committed 2013-05-22
- Comitter:
- tylerwilson
- Date:
- Wed May 22 16:30:54 2013 +0000
- Parent:
- 1:3b4d6ea39002
- Commit message:
- - Add Timer module to default VM environment; - Add Cleanup calls to the included modules (mbed, console and timer thus far)
Changed in this revision
diff -r 3b4d6ea39002 -r 4400650fe664 Pawn4.lib --- a/Pawn4.lib Wed May 22 12:22:04 2013 +0000 +++ b/Pawn4.lib Wed May 22 16:30:54 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/tylerwilson/code/Pawn4/#cc719e522b5d +http://mbed.org/users/tylerwilson/code/Pawn4/#01588bd27169
diff -r 3b4d6ea39002 -r 4400650fe664 main.cpp --- a/main.cpp Wed May 22 12:22:04 2013 +0000 +++ b/main.cpp Wed May 22 16:30:54 2013 +0000 @@ -10,9 +10,11 @@ #include "mbed.h" +#include "osdefs.h" #include "amx.h" #include "amxaux.h" #include "amxconsole.h" +#include "amxtime.h" #include "amxmbed.h" #include "amxpool.h" @@ -98,6 +100,8 @@ // for print and friends amx_ConsoleInit(&amx); + // for time functions + amx_TimeInit(&amx); // for mbed-specific functions amx_mbedInit(&amx); @@ -115,6 +119,11 @@ pc.printf("amx_Exec returned %d, main returned %d\n\r", err, ret); } + // clean up our extension modules, in reverse order + amx_mbedCleanup(&amx); + amx_TimeCleanup(&amx); + amx_ConsoleCleanup(&amx); + pc.printf("calling auxFreeProgram\n\r"); aux_FreeProgram(&amx); pc.printf("called auxFreeProgram\n\r");
diff -r 3b4d6ea39002 -r 4400650fe664 mbed.bld --- a/mbed.bld Wed May 22 12:22:04 2013 +0000 +++ b/mbed.bld Wed May 22 16:30:54 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file