Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: ICE-Application/src/Utilities/v7_execute.cpp
- Revision:
- 2:02cb20446785
- Parent:
- 1:b2e90cda7a5a
--- a/ICE-Application/src/Utilities/v7_execute.cpp Tue Jan 24 19:06:45 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -#include <stdio.h> -#include "v7_execute.h" -#include "utilities.h" -#include "rtos.h" - -#ifdef EXECUTE_SCRIPT - -struct v7 *v7; -Mutex v7_mutex; - -void v7_Create_Engine(void) -{ - v7 = v7_create(); - v7_Register_C_Calls(v7); -} - -void v7_Load_Script(const char * scriptString) -{ - enum v7_err rcode; - v7_val_t result; - - osStatus mutex_ret = v7_mutex.lock(); - if( mutex_ret != osOK ) printf("%s:%d: did not lock mutex, ret=0x%x\r\n", __func__, __LINE__, mutex_ret); - rcode = v7_exec(v7, scriptString, &result); - mutex_ret = v7_mutex.unlock(); - if( mutex_ret != osOK ) printf("%s:%d: did not unlock mutex, ret=0x%x\r\n", __func__, __LINE__, mutex_ret); - if( rcode != V7_OK ) - { - printf("%s:%d: Failed to load script: %s (len=%d), ret=%d\r\n", __func__, __LINE__, scriptString, strlen(scriptString), rcode); - } -} - -void v7_Execute_Script( std::string Command, std::string argv[NUM_SCRIPT_ARGS] ) -{ - v7_val_t func, result, args; - double argv_array[NUM_SCRIPT_ARGS]; - - if( Command.size() == 0 ) { - return; - } -// printf("\r%s\r\n", Util_getHeapData().c_str()); - - memset( argv_array, 0, (sizeof(double) * NUM_SCRIPT_ARGS)); - for( int i=0; i<NUM_SCRIPT_ARGS; i++ ) { - if( argv[i].size() != 0 ) { - argv_array[i] = RegisterValueMap[argv[i]].float_value; - } - } - -// printf("Command.size=%d, Command=%s(%s=%2.2f,%s=%2.2f,%s=%2.2f,%s=%2.2f)\r\n", Command.size() ,Command.c_str(), argv[0].c_str(), argv_array[0], argv[1].c_str(), argv_array[1], argv[2].c_str(), argv_array[2], argv[3].c_str(), argv_array[3]); - - osStatus mutex_ret = v7_mutex.lock(); - if( mutex_ret != osOK ) printf("%s:%d: did not lock mutex, ret=0x%x\r\n", __func__, __LINE__, mutex_ret); - - func = v7_get(v7, v7_get_global(v7), Command.c_str(), Command.size()); - - args = v7_mk_array(v7); - for( int i=0; i<NUM_SCRIPT_ARGS; i++ ) { - if( argv[i].size() != 0 ) { -// printf("Pushing %s\r\n", argv[i].c_str()); - v7_array_push(v7, args, v7_mk_string(v7, argv[i].c_str(), argv[i].size(), false)); - } - } - - if (v7_apply(v7, func, V7_UNDEFINED, args, &result) == V7_OK) { -// printf("Result: %g\r\n", v7_get_double(v7, result)); - } else { - printf("Error while calling %s\r\n", Command.c_str()); - } - - mutex_ret = v7_mutex.unlock(); - if( mutex_ret != osOK ) printf("%s:%d: did not unlock mutex, ret=0x%x\r\n", __func__, __LINE__, mutex_ret); -} -#endif \ No newline at end of file