Now able to make dictionary call from lua scripts.
Currently have redefined table that needs to align with shared dictionary files. Next task is to parse shared dictionary files to create tables at runtime.
This commit is contained in:
parent
2fdefde840
commit
4a24f72e3f
|
|
@ -1,10 +1,29 @@
|
||||||
-- main script that runs application logic and flow
|
-- main script that runs application logic and flow
|
||||||
|
|
||||||
|
-- Dictionary table definitions
|
||||||
|
dict = {}
|
||||||
|
dict["DICT_PINPORT"] = 1
|
||||||
|
dict["DICT_IO"] = 2
|
||||||
|
dict["DICT_NES"] = 3
|
||||||
|
dict["DICT_SNES"] = 4
|
||||||
|
dict["DICT_BUFFER"] = 5
|
||||||
|
dict["DICT_USB"] = 6
|
||||||
|
dict["DICT_OPER"] = 7
|
||||||
|
|
||||||
|
pinport = {}
|
||||||
|
pinport["LED_IP"] = 65
|
||||||
|
pinport["LED_OP"] = 66
|
||||||
|
pinport["LED_OFF"] = 67
|
||||||
|
pinport["LED_ON"] = 68
|
||||||
|
|
||||||
|
USB_IN = 0x80 --device to host
|
||||||
|
USB_OUT = 0x00 --host to device
|
||||||
|
|
||||||
|
|
||||||
-- initial function called from C main
|
-- initial function called from C main
|
||||||
function main ()
|
function main ()
|
||||||
print("print from main.\n")
|
-- print dictionary opcode addr miscdata endpt buffer length
|
||||||
print("dict_call ", dict_call( 1, 2, 3, 4), "\n")
|
print("dict_call ", dict_call( 1, dict["DICT_PINPORT"], pinport["LED_OFF"], 0, 0, USB_IN, nil, 1), "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- call functions desired to run when script is called
|
-- call functions desired to run when script is called
|
||||||
|
|
|
||||||
|
|
@ -8,24 +8,27 @@ void init_dictionary( USBtransfer *transfer ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int lua_dictionary_call (lua_State *L) {
|
int lua_dictionary_call (lua_State *L) {
|
||||||
//double d = lua_tonumber(L, 1); /* get argument */
|
int arg1 = luaL_checknumber(L, 1); /* get print argument */
|
||||||
int arg1 = luaL_checknumber(L, 1); /* get argument */
|
int arg2 = luaL_checknumber(L, 2); /* get dictionary argument */
|
||||||
int arg2 = luaL_checknumber(L, 2); /* get argument */
|
int arg3 = luaL_checknumber(L, 3); /* get opcode argument */
|
||||||
int arg3 = luaL_checknumber(L, 3); /* get argument */
|
int arg4 = luaL_checknumber(L, 4); /* get addr argument */
|
||||||
int arg4 = luaL_checknumber(L, 4); /* get argument */
|
int arg5 = luaL_checknumber(L, 5); /* get miscdata argument */
|
||||||
printf("arg1 %d, arg2 %d\n", arg1, arg2);
|
int arg6 = luaL_checknumber(L, 6); /* get endpoint argument */
|
||||||
printf("arg3 %d, arg4 %d\n", arg3, arg4);
|
//int arg7 = luaL_checknumber(L, 7); /* get buffer argument */
|
||||||
|
int arg8 = luaL_checknumber(L, 8); /* get length argument */
|
||||||
|
int rv; //return value
|
||||||
|
|
||||||
|
|
||||||
|
// printf("arg1 %d, arg2 %d\n", arg1, arg2);
|
||||||
|
// printf("arg3 %d, arg4 %d\n", arg3, arg4);
|
||||||
|
|
||||||
check( usb_xfr != NULL, "dictionary usb transfer pointer not initialized.\n")
|
check( usb_xfr != NULL, "dictionary usb transfer pointer not initialized.\n")
|
||||||
|
|
||||||
//dictionary_call_print_option( FALSE, transfer, dictionary, opcode, addr, miscdata, endpoint, buffer, length);
|
//dictionary_call_print_option( FALSE, transfer, dictionary, opcode, addr, miscdata, endpoint, buffer, length);
|
||||||
|
|
||||||
dictionary_call( usb_xfr, DICT_PINPORT, LED_OP, 0, 0, USB_IN,
|
rv = dictionary_call_print_option( arg1, usb_xfr, arg2, arg3, arg4, arg5, arg6, NULL, arg8);
|
||||||
NULL, 1);
|
|
||||||
dictionary_call( usb_xfr, DICT_PINPORT, LED_ON, 0, 0, USB_IN,
|
|
||||||
NULL, 1);
|
|
||||||
|
|
||||||
lua_pushnumber(L, (2*arg1)); /* push result */
|
lua_pushnumber(L, rv); /* push result */
|
||||||
return 1; /* number of results */
|
return 1; /* number of results */
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue