From 302d4bfcc49c69ea8251e1755ba3876555f680aa Mon Sep 17 00:00:00 2001 From: fulup Date: Wed, 9 Aug 2017 18:53:17 +0200 Subject: Not Working LUA user_data --- data/helloworld-lua-script.lua | 2 +- data/onload-control-script.lua | 56 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 7 deletions(-) (limited to 'data') diff --git a/data/helloworld-lua-script.lua b/data/helloworld-lua-script.lua index 8386bc0..7dd0459 100644 --- a/data/helloworld-lua-script.lua +++ b/data/helloworld-lua-script.lua @@ -37,5 +37,5 @@ -- return two arguments on top of status - return true, 1234, "ABCD" + return true, 1234, "ABCD", 5678 diff --git a/data/onload-control-script.lua b/data/onload-control-script.lua index 7ded3be..ac316cd 100644 --- a/data/onload-control-script.lua +++ b/data/onload-control-script.lua @@ -23,14 +23,59 @@ count=0 -- Adjust Volume function of vehicle speed function Adjust_Volume_Speed (speed_meters_second) - message= string.format("**** Adjust_Volume_Speed speed=%d count=%d", speed_meters_second, count); - print (message); + AFB:notice("In Adjust_Volume_Speed") + + print (string.format("***** Adjust_Volume_Speed speed=%d count=%d", speed_meters_second, count)); -- compute volume volume = speed_meters_second * 2 count=count+1 - return true, volume, count + AFB:success (1234, volume, count, 5678) +end + + +function Test_Binder_CB (result, context) + + local myTable= { ["arg1"] = "myString", ["arg2"] = 1234, ["arg4"] = true, ["arg5"] = 3.1416 } + + AFB:notice ("In Test_Binder_CB", result, context) + + AFB:success (1234, "ABCD", myTable, 5678) + +end + +function Test_Binder_Call_Async () + + local query= { + ["arg1"] = "myString", + ["arg2"] = 1234, + ["arg4"] = true, + ["arg5"] = 3.1416, + } + + AFB:service("alsacore","ping", query, Test_Binder_CB, "myContext") + +end + +function Test_Binder_Call_Sync () + + local query= { + ["arg1"] = "myString", + ["arg2"] = 1234, + ["arg4"] = true, + ["arg5"] = 3.1416, + } + + err= AFB:service_sync ("alsacore","ping", query) + + if (err) then + AFB:fail ("AFB:service_call_sync fail"); + else + AFB:success (1234, "ABCD", myTable) + end + + end function Ping_Test(...) @@ -41,10 +86,9 @@ function Ping_Test(...) do print(" -- ", tostring(v)) end - - -- return two arguments on top of status - return true, 1234, "ABCD" + -- push response to client + AFB:success (true, 1234, "ABCD"); end -- cgit 1.2.3-korg